Skip to content

Ten Fingers, Two Wires

Why we count in tens and the machine counts in twos, and how a row of switches spells an ordinary number.

  • Foundations

Decimal uses ten digits. Binary uses just two. The place-value idea stays the same: a digit’s position tells us what it is worth.

Ten is a habit

We count in tens. Three hundred and sixty-five is 3 hundreds, 6 tens and 5 ones. Each place is worth ten times the place to its right.

Decimal is a familiar choice, but it is not the only one. Nothing about the numbers requires groups of ten.

The machine has two

A bit is a binary digit: 0 or 1. We draw those two possibilities as a switch, off or on.

That is a model for the information. Electronic circuits represent the digits with physical states: the Spectrum manual describes low and high voltage. The bit is the information; the voltage is how a circuit represents it.

One bit cannot say much. To count past one the machine does what you do when you run out of fingers on one hand. It uses more.

Counting past one

Line up several bits and give each one a place. Each place has two states rather than ten, so each place is worth twice the one to its right. The places run 1, 2, 4, 8, 16, doubling as you go left.

Read the switches 1 0 1. That is one 4, no 2, and one 1. Together they make 5.

Write BIN in front of a row of switches to write a number the machine’s way:

Code
SHOW BIN 101
Output
5

The pattern is the number. BIN does no sum you could not do yourself. It reads the switches the machine’s way and shows you the answer in yours.

Turn another switch on

You can watch place value work. Add a switch on the left, in the 8s place:

Code
SHOW BIN 1101
Output
13

Five became thirteen. The new switch sits in the 8s place, so it added eight. Every switch is worth its own place and nothing else.

Work back from a number

To write 45 in binary, try the places from largest to smallest. We do not need 128 or 64. Take 32, leaving 13; take 8, leaving 5; take 4, leaving 1; then take 1.

Code
Places: 128 64 32 16 8 4 2 1
Bits:     0  0  1  0 1 1 0 1

So 45 is BIN 00101101: 32 + 8 + 4 + 1. Check a conversion by adding the selected places back together. We wrote eight digits to show an eight-bit pattern.

Eight of them make a byte

Bits rarely travel alone. The machine handles them in eights, and eight bits have a name you will meet on every page from here. They are a byte.

How high can eight switches count? Turn them all on:

Code
SHOW BIN 11111111
Output
255

128, 64, 32, 16, 8, 4, 2, 1. Add those up and you get 255. Eight bits give 256 patterns, including all zeros. Read as unsigned whole numbers, with no minus sign, they cover 0 through 255. A different reading can give the same bits another meaning; Unit 4 introduces a signed reading.

BIN marks how we write a number, not how much memory we reserve. BIN 101 and BIN 00000101 both mean 5. Leading zeros help us show a chosen width, but do not change the value or allocate storage.

Does BIN 00000101 hold a bigger number than BIN 101? Can BIN 100000000 fit in one unsigned byte?

Both first patterns mean 5. The second question has a different answer: BIN 100000000 is 256, which needs nine binary digits and does not fit in our eight-bit unsigned field. A number being valid notation does not make it fit every storage choice. What a real program does with an out-of-range value is a separate rule to check.

When it’s wrong, see why

  • A digit that isn’t 0 or 1. A switch has two states, so those are the only digits BIN takes. A 2 in the row is not a binary number.
  • The number is far bigger or smaller than you expected. You may be reading the row backwards. The rightmost switch is the 1s, and the places grow as you move left.
  • A leading zero did nothing. That is correct. BIN 0101 and BIN 101 are the same number, the way 0007 and 7 are.

What you’ve learnt

  • We count in tens out of habit, not because numbers demand it.
  • A bit is a binary digit, 0 or 1; the switch is our picture of it.
  • Each place is worth twice the one to its right, so a row of switches spells an ordinary number.
  • Eight bits make a byte: 256 patterns, read here as unsigned 0 to 255.
  • BIN marks binary notation; leading zeros change its written width, not its value.

What’s next

You can write a number in twos as well as tens. In Unit 2 we add a third way of writing one, and see why programmers reach for it constantly.