HP C/iX Reference Manual (31506-90011)

Chapter 5 79
Expressions
Bitwise Exclusive OR Operator
Bitwise Exclusive OR Operator
The bitwise exclusive OR operator (^) performs the bitwise exclusive OR function on its
operands.
Syntax
exclusive-OR-expression
::=
AND-expression
exclusive-OR-expression
^
AND-expression
Description
The result of the binary operator is the bitwise exclusive OR function of the two operands.
Both operands must be integral types. The usual arithmetic conversions are performed on
the operands. The type of the result is the converted type of the operands. The result is not
an lvalue.
For each of the corresponding bits in the left operand, the right operand, and the result,
the following table indicates the result of an exclusive OR operation.
You can use the exclusive OR operation for complementing bits. If a mask integer is
exclusive OR'd with another integer, each bit position in the mask having a value of one
will cause the corresponding position in the other operand to be complemented.
Example
var1 ^ var2
Table 5-5. C Operator Precedence
Bit in Left
Operand
Bit in Right
Operand
Bit in Result
000
011
101
110