Common Bit Manipulations And Knowledge
Set Negation: all_bits ^ A
Get Lowest Set Bit of A Number x: x & ~(x - 1)
Judge if a number is power of 2: n > 0 and n & -n (-n = ~(n - 1))
Get lower bits of a number one by one: i = (i - 1) & n
The & and | operators have lower precedence than comparison operators.
If you want to write completely portable C/C++ code, be sure to use unsigned types, particularly if you plan to use the top-most bit.