The bitwise operators perform bitwise AND, bitwise inclusive OR, left shift, right shift, and one’s complement (unary).
Bitwise AND | & | Masks off the specified bits |
---|---|---|
Bitwise inclusive OR | | | Turns on the specified bits |
Bitwise exclusive OR | ^ | Sets to 1 each bit position where the operands have different bits, and sets to 0 each bit position where the operands have the same bits. |
Bitwise 1’s complement | ~ | Changes each 1-bit into a 0-bit and vice-versa. |
Left Shift | << | Shifts to the left the left operand by the number of bit positions indicated by the right operand. |
Right Shift | >> | Shifts to the right the left operand by the number of bit positions indicated by the right operand. |