AND, OR, XOR, NOT and shifts in binary, decimal and hex.
Decimal, 0x hex, 0b binary or 0o octal. Values wrap to the selected width.
Most significant bit on the left.
| Operation | Binary | Decimal | Hex | |
|---|---|---|---|---|
AND A & B | 0000 1000 | 8 | 0x08 | |
OR A | B | 0000 1110 | 14 | 0x0E | |
XOR A ^ B | 0000 0110 | 6 | 0x06 | |
NOT A ~A | 1111 0011 | 243 | 0xF3 | |
NOT B ~B | 1111 0101 | 245 | 0xF5 | |
Left shift A << 2 | 0011 0000 | 48 | 0x30 | |
Right shift A >> 2 | 0000 0011 | 3 | 0x03 | |
Unsigned right shift A >>> 2 | 0000 0011 | 3 | 0x03 |
Shifts are logical on the unsigned 8-bit value, so >> and >>> agree here; bits shifted past the width are discarded.