04 Try it yourself Interactive

Eight cells, and the decimal moving with them

Each cell is one bit — tall means 1, short means 0 — and the label under it is the bit index, so bit 0 sits on the right. The amber band marks the position in play. Watch Decimal now in the stat row: binary and decimal move together on every press. Press Next one step at a time; the second tab runs Brian Kernighan instead.

Four bit operations
check, set, clear, toggle one bit
n is 0–255 (eight bits). The bit index is 0–7.
Press Next to begin. Each press moves one step.


      
Decimal now
Focus bit
Set bits0
Ops0
step 0 / 0