Node:Bitwise operators, Next:Shift operations, Previous:Machine-level operators, Up:Machine-level operators
Bitwise operators
C provides the following operators for handling bit patterns:
<<- Bit-shift left by a specified number of bit positions
>>- Bit-shift right by a specified number of bit positions
|- Bitwise inclusive OR
^- Bitwise exclusive OR
&- Bitwise AND
~- Bitwise NOT
<<=- Bit-shift left assignment (var = var << value)
>>=- Bit-shift right assignment (var = var >> value)
|=- Inclusive OR assignment (var = var | value)
^=- Exclusive OR assignment (var = var ^ value)
&=- AND assignment (var = var & value)
The meaning and syntax of these operators is given below.
Don't confuse bitwise operators (such as bitwise AND, &) with
logical operators (such as logical AND, &&). Bitwise operators
operate on each bit in the operand individually.