How do computers count with only 0 and 1?
Inside every computer, numbers are stored as patterns of on and off. Drop marbles into a wooden machine and watch it count, carry and add, just like a processor does.
Controls
Watch it work
A short film of this machine in action. Watch it, then try the challenges yourself.
What you're seeing
The machine has eight rockers in a row. Each one shows 0 or 1, and each is worth twice as much as the one to its right: 1, 2, 4, 8, 16, 32, 64 and 128. Add up the place values of the rockers showing 1 and you get the number on the counter.
Drop a marble into the 1s chute and it adds 1. When a rocker already shows 1, the marble flips it back to 0 and rolls on to the next rocker. That hand-off is called a carry, just like carrying a 1 when you add 9 + 1 = 10.
Try this
0 of 4 solved- Drop marbles into the 1s chute one at a time and count to 16. What happens to the rockers at 16?Start from 0 (press Reset).
- Show a number between 10 and 18, like your age, using one marble for each 1 in its binary pattern.Pick chutes, not the 1s chute over and over.
- Make 5, then add 3, using 4 marbles or fewer. Watch the carries.5 = 4 + 1, and 3 = 2 + 1.
- What's the biggest number the eight rockers can show? Make it.Every rocker shows 1.
Why it works
A rocker can only be in two positions, so it can only store 0 or 1. With one rocker you can count to 1; each extra rocker doubles how far you can count. Eight rockers make 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 = 256 different patterns, the numbers 0 to 255.
Adding works by carrying. A rocker showing 1 that gets one more can't show 2, so it goes back to 0 and passes 1 to the next place, which is worth double. A computer's adder circuit does exactly this with electric switches instead of rockers, billions of times a second.
Go deeper AGES 14–16
In binary each place is worth twice the place to its right. Read a pattern by adding the place values that show 1:
On your machine right now:
= 0 = 0
marbles used since reset: 0
Eight bits make one byte, which can hold 2⁸ = 256 values. Drop one more marble when every rocker shows 1 and they all flip to 0 while the last carry falls off the end into the cup: this is called overflow, and real programs have to watch out for it.