HP 3000 Manuals

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


HP C/iX Reference Manual

Bitwise AND Operator 

The bitwise AND operator (&) performs a bitwise AND operation on its
operands.  This operation is useful for bit manipulation.

Syntax 

     AND-expression ::=
         equality-expression 
         AND-expression & equality-expression 

Description 

The result of the binary & operator is the bitwise AND 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 a
bitwise AND operation.

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

Examples 

     var1 & var2



MPE/iX 5.0 Documentation