Original Post
Hi all!!
I have a byte to store 2 values (so, 4 bits per var).
for exemple:
int byte = 10010110; // (150)
the first value would be 1001 => 9
the second 0110 => 6
for the first I can get it with opérator >> right?
int var1 = (byte >> 4); // 00001001 => 9
but for the second, the best I have found is:
int var2 = (byte & 1)+(byte & 2)+(byte & 4)+(byte & 8);
My question : Is there a better way to extract the 4 last bits of the byte?
I tried with << and then >> but there is no change