Reputation: 39
I want to know if I am doing bitwise AND in a right way.
If we have:
231 & 0xFB7F
I am doing the following:
11100111 & 1111101101111111 = 1100111
is it correct?
Upvotes: 0
Views: 2160
Reputation: 7118
Correct!
231 in decimal = 1110 0111 in binary = 0000 0000 1110 0111
in binary (shown in 4-bit group for convenience)
0xFB7F in hex = 1111 1011 0111 1111
When you do bit wise-AND this becomes
0000 0000 0110 0111 in binary
= 67 in deciomal
Upvotes: 1