Speed

Explainer #15 · Electronics & Computers

How does a computer count?

Inside every computer are billions of tiny switches, and each one can only be off or on. Off means 0 and on means 1. To write bigger numbers, the computer lines switches up in a row, and each switch is worth twice as much as the one to its right: 1, 2, 4, 8 and so on. Add up the switches that are on and you get the number, so on-off-on-on is 8 + 2 + 1 = 11. Counting works just like a car's odometer: when a place is full it goes back to zero and passes a carry to the next place. Four switches count from 0 to 15, eight count to 255, and 32 count past four billion.

The principle

A computer counts with switches. Deep inside, a computer is made of billions of tiny electronic switches. In the video we draw four of them as lamps.

Step 1: A switch is off or on. A switch has only two choices. We write off as 0 and on as 1. That’s the only “digit” a computer has to work with.

Step 2: Each lamp is worth double. Put the lamps in a row. The one on the right is worth 1, the next is worth 2, then 4, then 8. Every step to the left doubles the value, just like our normal numbers go ones, tens, hundreds, only with two instead of ten.

Step 3: Add up the lamps that are on. If the 4 and the 1 are on, the number is 5. If the 8, the 2 and the 1 are on, it’s 11. Every pattern of lamps means exactly one number.

Step 4: Count up like a car’s odometer. To add 1, turn on the right lamp. If it’s already on, it goes off and passes a “carry” to the next lamp, the same way 9 rolls over to 10 on an odometer. Doing this again and again counts 0, 1, 2, 3 … all the way to 15.

Step 5: More lamps, bigger numbers. At 15 all four lamps are on. Add 1 more and they all flip off while a new lamp worth 16 turns on. Eight lamps can count to 255, and 32 lamps to more than four billion.

Common myth

Binary is a secret code that only machines understand

Binary isn’t a code or a special computer language. It’s ordinary counting, exactly like the numbers you use every day, just with two digits (0 and 1) instead of ten. Computers use it because a switch that is simply off or on is cheap, tiny and very hard to misread. You can count in binary on your fingers: five fingers, up or down, get you all the way to 31.

How this video was made: Rendered 3D animation, simplified. The switches are drawn as lamps, and real computers flip theirs billions of times per second.

Suggest an improvement
What could be better?

See the privacy page for how this is stored.