| 3.9.1.The Bitwise Operators |
|
|
- The bitwise operators act directly upon the bits of their operands.
- They are defined only for integer operands.
- They cannot be used on bool, float, or double.
|
The Bitwise Operators |
| Operator | Result | | & | Bitwise AND | | | | Bitwise OR | | ^ | Bitwise exclusive OR (XOR) | | > | Shift right | | < | Shift left | | ~ | One's complement (unary NOT) |
|
| p | q | p & q | p | q | p ^ q | ~p | | 0 | 0 | 0 | 0 | 0 | 1 | | 1 | 0 | 0 | 1 | 1 | 0 | | 0 | 1 | 0 | 1 | 1 | 1 | | 1 | 1 | 1 | 1 | 0 | 0 |
|