C Programming – XOR Bitwise Operation

XOR operator (also called “logical addition”) is defined like this:

a   b   a^b
-----------
0   0    0
0   1    1
1   0    1
1   1    0

So a^0 leaves a intact while a^1 toggles it.

For multiple-bit values, the operation is performed bitwise, i.e. between corresponding bits of the operands.

Leave a Comment