particular bit of an operand is ON or OFF.
For example, say the bit pattern is 10010100 and you
want to check whether a particular bit of an operand is ON or OFF (i.e., 0 or 1). To do so we will
create a mask (i.e., we will keep the fourth bit of this mask as 1 and all others 0s) and then bitwise
AND the two as follows:
10010100 (the given number)
00010000 (the 8-bit mask)
00010000 (result)
This means the result is 0001000 after ANDing and that is 16 in decimal. This further implies that
the fourth bit is ON.
NOTE
Inside your system the bit pattern is numbered from 0 to 7 but from right to left rather
than from left to right.
Do'stlaringiz bilan baham: |