Contents | Prev | Next

8.2.8.5 xor (bitwise)

Description

When the xor operator has operands of integral type then it performs bitwise exclusive or. The result of the operation is of integral type and has its bits set as follows: each bit is one (1) in the result if and only if one of bits in the corresponding position in the operands is one (1) but not both.

Example

   %11100 xor %10111  results in %01011

Binary notation is used in the example above so that you can clearly see the individual bits in the operands and the result. The example above could have been written as

   28 xor 23   results in  11

which is the same thing, but is probably not as clear.

Contents | Prev | Next