VCF

Unit 0 · What a computer actually does

How a computer stores a letter as a number

Underneath, a computer only has switches, so every letter is stored as a number. An agreed table maps numbers to characters: when you press B, the computer stores 66.

The mix-up

What people often think

“A computer understands words and letters directly.”

What the tutor says

Underneath, a computer only has switches, so every letter is stored as a number. When you type B, it stores 66.

If the computer only has switches, what has to happen when you press the B key?

How it works

A computer never sees the shape of a letter. When you press a key, the keyboard sends a code, and the computer keeps a number. A shared table, such as ASCII and the Unicode standard built on it, says which number stands for which character. In that table A is 65, B is 66 and H is 72.

Later letters do not need more space. One byte can hold any number up to 255, and B is only 66, so it fits in the same eight switches as A. Only the pattern changes.

Everything else a computer stores follows the same idea. Colours, sounds and photos are long runs of numbers, and a program decides what those numbers mean.

An example

What worksExample
H  →  72  →  0 1 0 0 1 0 0 0
           (64 + 8)
The letter H is stored as 72: the 64 switch and the 8 switch are on.

Close cousins of this mix-up

The tutor watches for these in the same lesson.

  • “Later letters need more switches.”

    One byte holds any number up to 255, and B is only 66. The same eight switches just need a different pattern.

Practise it with a tutor watching

Bits and switches

Turn a row of on and off switches into a number and a letter.

15 minutes See it Build it Break it Say it
Start the lesson

Free, no account needed.