KeyStage

Key Stage 3 computing · Data representation

KS3 binary and text: how computers store letters with ASCII

A computer can only store two states, on and off, written as 1 and 0. In Key Stage 3 children learn how whole numbers are written in binary, how to convert between binary and ordinary decimal numbers, how to add in binary, and how letters, digits and symbols are given number codes so that text can be stored. They also meet simple Boolean logic, the AND, OR and NOT rules that underlie computer circuits and programs.

Binary, text and ASCII, explained

Every computer is built from switches that are either on or off, so all information has to be turned into patterns of two symbols, 1 and 0. Each one is called a bit (a binary digit), and a group of eight bits is called a byte. Binary is a place-value system just like the decimal system your child knows, except that each column is worth double the one to its right instead of ten times. From the right, the columns are worth 1, 2, 4, 8, 16, 32, 64 and 128. So 00001101 means 8 + 4 + 1, which is 13.

Children practise converting both ways: binary to decimal by adding up the column values that have a 1 in them, and decimal to binary by working left to right through the column values, writing a 1 when the value fits into what is left and a 0 when it does not. They also add in binary, using the rules 0 + 0 = 0, 0 + 1 = 1, and 1 + 1 = 10 (a 0 in this column and a 1 carried into the next one, the same idea as exchanging in decimal addition). For example, 0101 + 0011 = 1000, which is 5 + 3 = 8.

Text is stored by giving every character its own number, and then storing that number in binary. The agreement about which number belongs to which character is called a character set. A well-known one is ASCII, which uses 7 bits to give 128 characters: capital A is 65, B is 66, and so on; lower-case a is 97; the digit 0 is 48; the space is 32. Unicode is a much larger character set that gives a code to letters in the world’s writing systems, to symbols and to emoji, and its first 128 codes match ASCII. Using more bits for each character means more different characters can be represented, but the same piece of text then takes up more space.

The same part of the programme of study covers simple Boolean logic, which also works with 1s and 0s. Boolean values are only true or false. AND is true only if both inputs are true, OR is true if at least one is true, and NOT flips true to false. Children meet these in programming conditions and in simple logic circuits, often alongside this topic, and schools choose how far to take them.

The important message is that the computer never stores the letter shapes. It stores numbers, and a font and a screen turn those numbers back into shapes for us. Once children grasp this, many other things become easier to understand, including why a text file can get garbled when two systems use different character sets, and why pictures and sound need a similar system of their own.

Words your child will hear

Bit
A single binary digit, 0 or 1. It is the smallest unit of data.
Byte
A group of eight bits. One byte has 256 possible patterns, from 00000000 to 11111111.
Binary
A number system with only two digits, where each column is worth double the one to its right.
Character set
An agreed list that gives each character, such as a letter or symbol, its own number code.
ASCII
An early and widely used character set of 128 characters, covering English letters, digits and common symbols.
Unicode
A much larger character set covering most of the world’s writing systems and emoji.
Boolean
To do with true or false values and the logic rules AND, OR and NOT.

What the National Curriculum says

In Key Stage 3, pupils should be taught to:

  • Understand how instructions are stored and executed within a computer system; understand how data of various types (including text, sounds and pictures) can be represented and manipulated digitally, in the form of binary digits
  • Understand simple Boolean logic [for example, AND, OR and NOT] and some of its uses in circuits and programming; understand how numbers can be represented in binary, and be able to carry out simple operations on binary numbers [for example, binary addition, and conversion between binary and decimal]

Objectives from the National Curriculum in England, © Crown copyright, used under the Open Government Licence v3.0.

A worked example

Using ASCII, where H has the code 72 and i has the code 105, write the word “Hi” as two bytes of binary.

  1. Write out the eight column values, from the left: 128, 64, 32, 16, 8, 4, 2, 1. Every byte is built from these.
    128  64  32  16  8  4  2  1
  2. Convert 72 first. 128 does not fit into 72, so write 0. 64 fits, so write 1, leaving 72 − 64 = 8. 32 and 16 do not fit into 8, so write 0 for each. 8 fits exactly, so write 1, leaving 0. The remaining columns are all 0.
    128  64  32  16  8  4  2  1
      0   1   0   0  1  0  0  0
  3. Convert 105. 128 does not fit, so 0. 64 fits, so 1, leaving 41. 32 fits, so 1, leaving 9. 16 does not fit, so 0. 8 fits, so 1, leaving 1. 4 and 2 do not fit, so 0 for each. 1 fits, so 1.
    128  64  32  16  8  4  2  1
      0   1   1   0  1  0  0  1
  4. Check each answer by adding the columns back up. 64 + 8 = 72, and 64 + 32 + 8 + 1 = 105, so both are right.

“Hi” is stored as 01001000 01101001, two bytes. The first holds 72 for H and the second holds 105 for i.

Common mistakes and how to help

Thinking the computer stores the shape of each letter

When we see text on screen we see shapes, so it feels as though that is what is kept.

What helps: The file holds only numbers. Change the font and the same numbers are drawn with different shapes. Showing a text file with the font changed makes this clear.

Giving letters codes based on alphabet position, such as A = 1

It is the first code system that comes to mind, and puzzles with A = 1 are popular.

What helps: ASCII starts capital A at 65 because the earlier codes are used for digits, punctuation and control characters. Capital and lower-case letters have different codes, with a difference of 32.

Confusing the character ‘5’ with the number 5

On the page they look identical, so children assume one stored value does both jobs.

What helps: The digit character 5 has the ASCII code 53 and is stored as text. The number 5 is stored as 101. Programs have to convert one into the other, which is why typed input is read as text first.

Reading binary place values wrongly, such as treating 1000 as one thousand or reversing the columns

Children are used to decimal columns of ones, tens and hundreds, and read left to right out of habit.

What helps: Write the column values over the digits every time until it is automatic, and always start from the right with 1. Then 1000 is one 8 and nothing else, which is 8.

How to help at home

  • Write a secret message. Agree a code with your child using numbers for letters, either simple or ASCII-like, and swap short messages to decode. Ask why both people need exactly the same table.
  • Count in binary on your fingers. Each finger is a bit, up to 31 on one hand with the thumb as 1 and the little finger as 16. Ask for your age or the day of the month, and check the answer by adding the raised fingers.
  • Send a message by torch. A torch, like a bit, is either on or off. Ask how you could send the letter H using its ASCII code and only long and short flashes, and how many flashes the word “Hi” would need if every letter used 8 bits (16).
  • Spot garbled text. If a message or web page ever shows empty boxes or odd symbols instead of letters, ask your child why. Usually the device does not have that character in its font, or the text was read using a different character set from the one it was saved in.

More on data representation

Everything in Key Stage 3 computing

Updated .