F
felixnielsen
If im not mistaken, a char variable allocates 1 byte of memory, as it
is the case with a bool variable.
I need 2 bool and 1 char variable which only need to contain a value
between 0 and 63 (times 256^3 :O)
When you consider that it makes it makes perfect sence with bit
manipulation, in case you dont understand what i mean let me give an
example.
to store a value between 0 and 63 you need only 6 bits. Lets say we
wanna store the value 27 0001 1011.
We dont need to store value greater than 63, so we can strip the 2 top
bits.
0110 11
Then lets say we wanna store a true and a false bool
1 (true)
0 (false)
And then we simply put it all together:
27 true false
011011 + 1 + 0 = 0110 1110
or another example could be to store 64 bool expressions in one
longlong?
it is ofcourse possible just to do the math but it aint allways easy
;-)
So, how to manipulate the bits?
Regards
Zacariaz
is the case with a bool variable.
I need 2 bool and 1 char variable which only need to contain a value
between 0 and 63 (times 256^3 :O)
When you consider that it makes it makes perfect sence with bit
manipulation, in case you dont understand what i mean let me give an
example.
to store a value between 0 and 63 you need only 6 bits. Lets say we
wanna store the value 27 0001 1011.
We dont need to store value greater than 63, so we can strip the 2 top
bits.
0110 11
Then lets say we wanna store a true and a false bool
1 (true)
0 (false)
And then we simply put it all together:
27 true false
011011 + 1 + 0 = 0110 1110
or another example could be to store 64 bool expressions in one
longlong?
it is ofcourse possible just to do the math but it aint allways easy
;-)
So, how to manipulate the bits?
Regards
Zacariaz