Bit Tricks — Watch Operations on a 32-bit Integer

Edit the number, pick an operation, and step through it bit by bit. Lit cells are 1, dark cells are 0. Two's complement; bit 0 is on the right.

step 0

Bit cells (positions 31 → 0)

dec = 44
hex = 0x2C
bin = 101100
popcount = 3
bit = 1 bit = 0 isolated lowest set bit target bit i

Operation & running count

Press Step to begin. Choose an operation above; the cells animate one transformation per step.
Self-contained visualization. Values are 32-bit unsigned; negation -x is computed mod 232 (two's complement). The Kernighan popcount loop runs x &= x-1 once per set bit. See junior.md and professional.md for proofs that x & (x-1) clears, and x & -x isolates, the lowest set bit.