bit pattern 00100000. Bitwise exclusive OR (XOR) Operator (^) The Bitwise XOR operator is used to perform an exclusive OR operation between two bit
patterns.
Please note that the XOR operator returns 1 only if one of the two bits is 1.
Table 2.9
shows its truth table.
Table 2.9 Bitwise XOR Operator. A B A ^ B 0
0
0
0
1
1
1
0
1
1
1
0
Also note that the XOR operator is used to toggle a bit ON or OFF. For example,
If numb1 = 12
and numb2 = 24
then (numb1 ^ numb2) yields
00001100
`00011000
00001000 (result)
This yields 20 (decimal).
One (1s) Complement Operator The bitwise 1s complement operator complements every bit of the bit pattern (i.e., 0s replaced by 1s
and vice versa). Its truth table is shown in
Table 2.10
.