Bitwise operators work on the binary representation: & AND, | OR, ^ XOR, ~ NOT, << left shift, >> right shift.
1Tricks
x << n = x × 2ⁿ; x >> n = x ÷ 2ⁿ (for non-negative x)
x & 1 tests the lowest bit (odd/even)
x & (x − 1) clears the lowest set bit; it is 0 for powers of two
x ^ x = 0; XOR can swap values