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.
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.
| Character | Denary code | Binary |
|---|---|---|
| A | 65 | 01000001 |
| B | 66 | 01000010 |
| a | 97 | 01100001 |
| 0 | 48 | 00110000 |
| space | 32 | 00100000 |
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.
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.
Quality versus size
In every case, more bits mean better quality but bigger files:
| Increase | Effect on quality | Effect on file size |
|---|---|---|
| Sample rate | Closer to the original sound | Larger |
| Sample resolution | More accurate amplitude, wider dynamic range | Larger |
| Image resolution | More detail, less pixelated | Larger |
| Colour depth | More colours, smoother shading | Larger |
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.