Bitwise Operators
& Bitwise AND Op.
| Bitwise OR
^ Bitwise X-OR (Exclusive OR)
<< Bitwise Left Shift Op.
>> Bitwise Right Shift Op.
~ Bitwise One's Compliment Op. ===> It is UNARY in nature.
NOTE : Bitwise operators OPERATES only upon the INTEGERS(int , char)
1 - ON /TRUE
0 - OFF/FALSE
Truth Table
Bit1 Bit2 Bit1 & Bit2 Bit1 | Bit2 Bit1 ^ Bit2
1 1 1 1 0
1 0 0 1 1
0 1 0 1 1
0 0 0 0 0
Bit ~Bit
1 0
0 1
int a=27, b=22;
int ans = a & b;
printf("Value of ans = %d\n", ans);
a = 27 == 11011
& b = 22 == 10110
-------------------------------------
ans == 10010
int a=27, b=22;
int ans = a | b;
printf("Value of ans = %d\n", ans);
a = 27 == 11011
| b = 22 == 10110
-------------------------------------
ans == 11111
int a=27, b=22;
int ans = a ^ b;
printf("Value of ans = %d\n", ans);
a = 27 == 11011
^ b = 22 == 10110
-------------------------------------
ans == 01101