C language |
Let consider 8-bit binary number,
Binary(8 bit) = 0000 1101
suppose we want check 3rd bit is on or off(on=1 & off=0), just like this,
0000 1100 (Decimal=13)
&
0000 0100 (Decimal=4,we are checking 3rd bit so it is 1)
----------
0000 0100 (Decimal=4)
----------
If we got some value then checking bit is on,otherwise off.
In C language,
if(13&4)
print("The third bit is on");
else
print("The third bit is off");
You may also like this post : Dangling Pointer
0 comments:
Post a Comment