For those of you that read the game forum here, you might have seen that I have been interested in how speed up some graphics functions I have.
From reading this article I learned that it is possible to take two 16bit variables and store them in a 32 bit variable. But I am not really sure how to do this, so here are some questions:
When you assign the two variables to the bit one, is it done like this:
The first 16bit variable is stored in the front, and the second in the back? So the two variables are not added together, they are just stored in the same place.
100 and 100 would not be 200, but 100100?
I have made a small test program where I try to place two chars in one int, but I cant get it to work. Could anyone give me a helping hand or point me to a place where I can read up on this?Code:¦ size of 32bit ¦ / \ / \ ¦ size of 16bit ¦ ¦ size of 16bit ¦
Thank youCode:#include "stdafx.h" #include <iostream> using namespace std; int main () { char a = 0; char b = 25; char c = 50; char d = 75; int test = b | (c << 4); test = test * 2; cout <<" size of char = " << sizeof(char) << endl; cout <<" size of int = " << sizeof(int) << endl; cout << " a = " << (int)a << endl; cout << " b = " << (int)b << endl; cout << " c = " << (int)c << endl; cout << " d = " << (int)d << endl; cout << endl; cout << "b = " << (test >> 8) << endl; cout << "c = " << (test >> 4) << endl; system("Pause"); return 0; }