Operator | Operation | Syntax | Description | |||
---|---|---|---|---|---|---|
& |
Bitwise AND | a & b |
Copies bit to result if 1 in both operands | |||
| | Bitwise OR | a | b | Copies bit to result if 1 in either operand | |||
^ |
Bitwise XOR | a ^ b |
Copies bit to result if 1 in only one operand | |||
~ |
Bitwise Complement | ~a |
Returns inverted bits of a | |||
<< |
Bitwise Shift Left | a << b |
Shifts a to the left by b bits; b must be an integer | |||
>> |
Bitwise Shift Right | a >> b |
Shifts a to the right by b bits; b must be an integer |