Docs

Topic 1 · Data representation

Representing text, sound, and images

Character sets like ASCII and Unicode, how sound is sampled, and how pixels and colour depth make up an image.

Lesson 3 of 4Syllabus 1.2updated October 31, 2026

Text and character sets

Every character on a keyboard is given a number, and the number is stored in binary. The list of characters and their numbers is a character set.

ASCII uses 7 bits, giving 128 characters: English letters, digits, punctuation, and control codes. Extended ASCII uses 8 bits for 256 characters.

Unicode uses up to 4 bytes per character, so it can represent over a million characters: every writing system, maths symbols, and emoji. The cost is that each character can take more storage than in ASCII.

CharacterDenary codeBinary
A6501000001
B6601000010
a9701100001
04800110000
space3200100000
Codes are in order, so B is one more than A, and lower case is 32 more than upper case.

Sound

Sound is a continuous analogue wave. To store it, the computer measures the wave's height (amplitude) at regular intervals. Each measurement is a sample.

The sample rate is how many samples are taken per second, measured in hertz (Hz). CD audio uses 44,100 Hz. The sample resolution (bit depth) is how many bits store each sample, which sets how many different heights can be recorded.

Drag the sliders. With few samples or few bits, the solid line is a blocky copy of the real wave. Turn both up and it follows the curve closely, but the file needs more bits.

Sampling a sound waveInteractive
12 samples × 3 bits = 36 bits for this window
Higher sample rate and higher resolution give a more accurate recording and a bigger file.

Images

A bitmap image is a grid of dots called pixels. Each pixel's colour is stored as a binary number.

Resolution is the number of pixels, written as width × height. Colour depth is the number of bits per pixel. 1 bit gives 2 colours, 8 bits give 256, and 24 bits give about 16.7 million.

Paint the image below. With a colour depth of 1, black is 1 and white is 0. Switch the colour depth to see how the file size grows even though the picture has the same number of pixels.

An 8 × 8 bitmapInteractive
Colour depth
8 × 8 × 1 = 64 bits = 8 bytes
Click pixels to paint. Each black pixel is a 1, each white pixel a 0.
Image size in bits = width × height × colour depth.

Quality versus size

In every case, more bits mean better quality but bigger files:

IncreaseEffect on qualityEffect on file size
Sample rateCloser to the original soundLarger
Sample resolutionMore accurate amplitude, wider dynamic rangeLarger
Image resolutionMore detail, less pixelatedLarger
Colour depthMore colours, smoother shadingLarger

Key terms

Character set
All the characters a computer can represent, each with a unique binary code.
Sample rate
The number of sound samples taken per second.
Sample resolution
The number of bits used to store each sound sample.
Pixel
The smallest single point of colour in a bitmap image.
Colour depth
The number of bits used to store the colour of each pixel.

Check yourself

The ASCII code for 'C' is 67. What is the code for 'E'?Show answer

69. Codes run in alphabetical order.

Why might a company choose Unicode instead of ASCII?Show answer

Unicode can represent characters from every language and emoji, so text from any country can be stored.

How many colours can a 4-bit colour depth show?Show answer

2⁴ = 16 colours.

Describe one effect of reducing the sample rate of a recording.Show answer

The file gets smaller, but fewer samples are taken so the sound is less accurate and may lose high frequencies.