how does masking works in c++
how can i extract the position of my desire from a series of bits given to me
for instance if
16 in bit is
10000
how can i get the 3rd number
please adivce
|
Go4Expert Founder
|
![]() |
| 29Oct2006,10:43 | #2 |
|
You need to do the Bitwise AND (&) / Bitwise OR (|) to do the masking
Truth table is as follows OR Code:
+-----+-----+-----+ | OP1 | OP2 | O/P | +-----+-----+-----+ | 0 | 0 | 0 | | 0 | 1 | 1 | | 1 | 0 | 1 | | 1 | 1 | 1 | +-----+-----+-----+ Code:
+-----+-----+-----+ | OP1 | OP2 | O/P | +-----+-----+-----+ | 0 | 0 | 0 | | 0 | 1 | 0 | | 1 | 0 | 0 | | 1 | 1 | 1 | +-----+-----+-----+ |

