The fourth bit in element 75?
if((MyArray[75] & 8) > 0) // bit is on
else // bit is off
The operator and allows you to use the value as a mask.
xxxxxxxx = ?
00001000 = 8 &
----------------
0000?000 = 0 | 8
This method can be used to collect any of the bit values ββusing the same technique.
1 = 00000001
2 = 00000010
4 = 00000100
8 = 00001000
16 = 00010000
32 = 00100000
64 = 01000000
128 = 10000000
source
share