C++ examples for Operator:Bit Operator
Operator | Meaning |
---|---|
& | Bitwise AND |
| | Bitwise inclusive OR |
^ | Bitwise exclusive OR |
~ | Bitwise 1's complement |
Truth tables.
Bitwise AND (&)
0 & 0 = 0 0 & 1 = 0 1 & 0 = 0 1 & 1 = 1
Bitwise inclusive OR ( |)
0 | 0 = 0 0 | 1 = 1 1 | 0 = 1 1 | 1 = 1
Bitwise exclusive OR (^)
0 ^ 0 = 0 0 ^ 1 = 1 1 ^ 0 = 1 1 ^ 1 = 0
Bitwise 1's complement (~)
~0 = 1 ~1 = 0