3.4.8 Bitwise operators

Bitwise operators perform bitwise AND (&) and OR (|) operations.

Organization of this subsection
(1) Format
(2) Description

(1) Format

Bitwise AND

expression & expression

Bitwise OR

expression | expression

(2) Description

Either or both of the operands for a bitwise operator must be the integer type. Bitwise operators perform normal arithmetic conversion according to the data type.

The following explains the bitwise operators.

OperatorDescription
&The bitwise AND operator compares a bit of the first operand with the corresponding bit of the second operand. If both the bits are 1, the resulting bit is set at 1. If not, the resulting bit is set at 0.
|The bitwise OR operator compares a bit of the first operand with the corresponding bit of the second operand. If one of both the bits is 1, the resulting bit is set at 1. If not, the resulting bit is set at 0.