Grade 7 Computer Science · How a computer holds information

Everything is numbers

The meaning does not live in the data but in the program that reads it.

One number, three meanings

The number 65 can be an age, the letter A, or the strength of red at a dot in a picture. In storage there is no difference between the three. So who decides which it is — and why does a file opened in the wrong program look like gibberish without being damaged?

A computer holds text, pictures, music and films — and all of them, without exception, are stored as numbers. That sounds like a technical fact one could skip, and it in fact explains half of what seems odd in working with computers.

Exactly the same storage; the program is what decides what it says.
The reader’s assumptionWhat the number looks like
This is a numberA quantity, an age, a mark
This is a letter’s codeA character in a text
This is a colour strengthA shade of a dot in a picture

Why this brings us back to types

In the unit on values we saw that a type decides what an operation does — that adding two numbers is not like joining two texts. Now it can be seen why: the type is exactly the assumption the program holds about what the numbers say. There is no physical difference between the two in storage; the whole difference is in the interpretation the program applies to them. That is why mixing types gives an odd result rather than an error — the operation was carried out, only under an assumption other than the one you meant.

Example 1 — a file in the wrong program

  1. The file holds numbers, like every file.
  2. The program assumes they are letters’ codes.
  3. But they were written as colour strengths.
  4. The output is gibberish, and the file is perfectly fine.

Example 2 — why an extension does not change a kind

  1. The extension tells the program which assumption to take.
  2. It does not change the numbers in the file.
  3. Changing it changes only the assumption.
  4. And the content stays exactly as it was.
A file opened in the wrong program is not damaged — it is read under a different assumption.