HP 3000 Manuals

Bitwise Exclusive OR Operator [ HP C/iX Reference Manual ] MPE/iX 5.0 Documentation


HP C/iX Reference Manual

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.

-----------------------------------------------------------------------------------------------
|                                |                           |                                |
|      Bit in Left Operand       |   Bit in Right Operand    |         Bit in Result          |
|                                |                           |                                |
-----------------------------------------------------------------------------------------------
|                                |                           |                                |
|               0                |             0             |               0                |
|                                |                           |                                |
-----------------------------------------------------------------------------------------------
|                                |                           |                                |
|               0                |             1             |               1                |
|                                |                           |                                |
-----------------------------------------------------------------------------------------------
|                                |                           |                                |
|               1                |             0             |               1                |
|                                |                           |                                |
-----------------------------------------------------------------------------------------------
|                                |                           |                                |
|               1                |             1             |               0                |
|                                |                           |                                |
-----------------------------------------------------------------------------------------------

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



MPE/iX 5.0 Documentation