Daylila
How computers actually work

Lesson 2 of 13

Counting in twos: binary

Explain how a handful of on/off switches counts to any number using place values of 1, 2, 4, 8…, and read a small binary number.

01 · Learn · the idea

An old car odometer has a row of wheels, each showing 0 to 9. The right-hand wheel ticks up — 7, 8, 9 — and when it passes 9 it rolls back to 0 and nudges the wheel on its left up by one. That’s how we count past a single digit: run out of symbols, carry one to the next column. A computer counts the same way. It just has only two symbols to play with — 0 and 1 — so its wheels roll over twice as often.

In the last lesson we said a row of switches can stand for a number. This lesson is the how. Once you see it, “binary” stops being a mystery and becomes just… counting, with two fingers instead of ten.

Our numbers are secretly columns of powers

Look hard at the number 305. The 5 is worth five. The 0 is worth zero tens. The 3 is worth three hundreds. Each column is worth ten times the one to its right: ones, tens, hundreds, thousands. We call it base ten because we have ten symbols (0–9) and each column is a power of ten. Nobody taught it as “powers of ten” — you just learned it as place value. But that’s what it is.

There’s nothing sacred about ten. We use it because we have ten fingers. A computer has two states per switch, so it counts in base two: each column is worth twice the one to its right. Ones, twos, fours, eights, sixteens — the powers of two.

Reading a binary number

In binary, a switch in each column is either off (0) or on (1). On means “yes, add this column’s value.” Off means “no, skip it.” To read the number, add up the values of the columns that are switched on.

Take four switches showing 1 1 0 1. Write the column values above them, biggest on the left:

  8   4   2   1
  1   1   0   1

The 8 is on, the 4 is on, the 2 is off, the 1 is on. Add the ones that are on: 8 + 4 + 1 = 13. That’s it. 1101 in binary is 13 in our usual numbers. Not a code to memorise — a sum you do.

Go the other way and it’s just as plain. To write 13 in binary, ask each column from the left: does 8 fit in 13? Yes — switch it on, 5 left over. Does 4 fit in 5? Yes — on, 1 left. Does 2 fit in 1? No — off. Does 1 fit in 1? Yes — on. Reading the switches top to bottom: 1101. You’ll do exactly this, by hand, in the lab.

How far can a few switches count?

With four switches the smallest number is 0000 (everything off) = 0, and the largest is 1111 (everything on) = 8 + 4 + 2 + 1 = 15. So four bits cover 0 to 15 — sixteen different values. Each switch you add doubles the range, because it adds a new column worth as much as all the others put together. Five bits reach 31, six reach 63, and so on.

Eight switches in a row is special enough to have a name: a byte. Its columns are 128, 64, 32, 16, 8, 4, 2, 1. All on is 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. So one byte holds any value from 0 to 255 — 256 possibilities. That number, 256, turns up everywhere in computing, and now you know why: it’s just two, multiplied by itself eight times, one doubling per bit.

Worked example: a byte counts to 100

Suppose a byte needs to hold the number 100. Walk the columns from the biggest:

  • 128 fits in 100? No → 0.
  • 64 fits in 100? Yes → 1, leaving 36.
  • 32 fits in 36? Yes → 1, leaving 4.
  • 16 fits in 4? No → 0. 8 fits in 4? No → 0.
  • 4 fits in 4? Yes → 1, leaving 0.
  • 2? No → 0. 1? No → 0.

Read the switches: 0 1 1 0 0 1 0 0. Check it: 64 + 32 + 4 = 100. The byte is just a tally of which powers of two add up to your number. Every number has exactly one such tally, which is why this works without ambiguity.

The same trick, all the way up

This is the whole of it. There is no separate, cleverer machinery for big numbers. A computer that needs to count higher than 255 just uses more bytes — two bytes reach 65,535, four bytes reach over four billion. It is always the same move: another column, worth double, switched on or off.

It’s worth noticing what you just did. You read a number the way the machine does, using nothing but on, off, and addition. The gap between you and the computer here isn’t intelligence — it’s speed and patience. It never tires of adding columns, and it never makes a slip. Hold that, because the next lesson takes these plain numbers and shows how the same bits can become a letter, a colour, or a sound — once everyone agrees what the number is supposed to mean.

02 · Try · the lab

03 · Check · quick quiz

1. Why does a computer count in base two (binary) instead of base ten like we do?

  • Because binary numbers are shorter to write
  • Because each switch has only two states — on or off — so each column is a power of two
  • Because two is a luckier number than ten in engineering
  • Because base ten was patented and computers had to avoid it
Answer

Because each switch has only two states — on or off — so each column is a power of two — We use base ten because we have ten fingers; a computer uses base two because each switch holds one of two states. The counting rule is identical — run out of symbols, carry to the next column — there are just fewer symbols.

2. The four switches read 1 0 1 1, with column values 8, 4, 2, 1 from the left. What number is that?

  • 1011
  • 11
  • 8
  • 4
Answer

11 — Add the columns that are switched on: 8 + 0 + 2 + 1 = 11. Reading binary is just adding up the place values where the switch is on.

3. You add one more switch to the left of a row of bits. What happens to the range of numbers you can count to?

  • It goes up by one
  • It doubles, because the new column is worth as much as all the others combined plus one
  • It stays the same — extra switches are spares
  • It goes up by ten
Answer

It doubles, because the new column is worth as much as all the others combined plus one — Each new column is worth double the last, so adding a bit doubles the range. That's why 8 bits (a byte) reach 255 and why '256' shows up everywhere — it's two doubled eight times.

4. A single byte is eight bits. What is the largest number one byte can hold?

  • 100
  • 128
  • 255
  • 1000
Answer

255 — All eight switches on gives 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. So a byte holds 0 to 255 — 256 different values in total.