Bitwise Operators
Operator | Description |
---|---|
g & h |
Binary AND |
g | h |
Binary OR |
g ^ h |
Binary XOR |
g ~ h |
Binary one's complement |
g << h |
Binary shift left |
| g >> h
| Binary shift right |
let (g, h) = (0x1, 0x2);
let bitwise\_and = g & h; // => 0
let bitwise\_or = g | h; // => 3
let bitwise\_xor = g ^ h; // => 3
let right\_shift = g >> 2; // => 0
let left\_shift = h << 4; // => 32
Comments