Computers store everything in binary, so each letter, digit and symbol is given a number. A character set is the agreed list.
Character set (AQA): “a collection of characters (letters, numbers, symbols, etc.) that a computer system can process and use to represent text, with each character assigned a unique numerical code.”
Codes are grouped and run in sequence. In ASCII, 'A' is 65, 'B' is 66, 'C' is 67, and so on up to 'Z' at 90.
The same is true for lower case ('a' is 97, 'b' is 98…) and for digits ('0' is 48, '1' is 49…).
So if you know the code for the first character in a group, you can work out the rest: count on from it.
Upper and lower case letters have different codes: 'a' (97) is 32 more than 'A' (65).
The character '7' has the code 55. It is not the number 7.
Group
First character and code
Example
Digits
'0' = 48
'5' = 48 + 5 = 53
Capital letters
'A' = 65
'H' = 65 + 7 = 72
Lower case letters
'a' = 97
'k' = 97 + 10 = 107
Worked exampleGiven that 'A' is 65, find the code for 'K'.
K is the 11th letter, so it is 10 places after AA is 0 places after A
65 + 10 = 75codes run in sequence
75
Exam tipCount carefully from the first letter: 'A' is 0 places on, not 1. And check the case: the code for 'd' is not the code for 'D'.
Character set
A collection of characters (letters, numbers, symbols, etc.) that a computer system can process and use to represent text, with each character assigned a unique numerical code.
Character code
The number given to one character in a character set.
3.3.5 Character encoding
7-bit ASCII
ASCII (AQA): “a character encoding system that uses a 7-bit notation that allows for the representation of 128 unique characters.”
7 bits give 27 = 128 different codes: 0 to 127.
ASCII covers the English alphabet in both cases, the digits 0–9, punctuation, the space (32) and some control codes.
To convert a character to binary: find its decimal code (from a table or by counting on), then write it as a 7-bit binary number.
To convert binary to a character: turn the 7-bit number into decimal, then look up or count to the character.
Some books and videos mention 8-bit “extended ASCII”. AQA's ASCII is 7-bit.
Character
Decimal
7-bit binary
space
32
0100000
'0'
48
0110000
'A'
65
1000001
'C'
67
1000011
'a'
97
1100001
'z'
122
1111010
Worked exampleDecode the 7-bit ASCII codes 1001000 1101001.
1101001 = 64 + 32 + 8 + 1 = 105the same place values
72 is 'H' (65 + 7); 105 is 'i' (97 + 8)count on from 'A' and 'a'
Hi
Exam tipGive ASCII codes as 7 bits. AQA's reports say many students thought ASCII was 8-bit, and an answer padded to 8 bits with an extra 0 at the front was marked wrong.
ASCII
A character encoding system that uses a 7-bit notation that allows for the representation of 128 unique characters.
3.3.5 Character encoding
Unicode
128 characters is enough for English, but not for the world's other alphabets, or for maths symbols and emoji. Unicode was introduced to fix that.
Purpose: to represent the characters of many different alphabets (such as Greek, Arabic, Chinese and Hindi) and special symbols, “allowing a far greater range of characters.”
AQA's vocabulary: Unicode was “introduced to support a wider range of characters due to increased communication across countries.” It can use up to 32 bits per character.
Unicode now defines well over 100,000 characters. You don't need to learn a number.
Unicode uses the same codes as ASCII up to 127, so 'A' is still 65. Text in ASCII is still valid in Unicode.
Advantages over ASCII: many more characters, so text in any language, and emoji, can be stored and shared between countries and devices.
Disadvantage: a character can need more bits than in ASCII, so text files can be larger.
You don't need to know about UTF-8, UTF-16 or other versions of Unicode.
ASCII
Unicode
Bits per character
7
Up to 32 (often more than ASCII)
Number of characters
128
Well over 100,000
Languages
English
Most of the world's writing systems
Codes 0–127
The ASCII codes
The same as ASCII
Exam tip“Unicode uses fewer bits than ASCII” and “all ASCII codes are different in Unicode” are both false. If a question asks for an advantage and a disadvantage, give one of each, and say why it matters.
Unicode
A character set introduced to support a wider range of characters due to increased communication across countries; it can use up to 32 bits per character.
3.3.6 Representing images
Pixels and bitmap images
A bitmap image is a grid of dots. Each dot is a pixel, and each pixel's colour is stored as a binary code.
Pixel: short for picture element. “A pixel is a single point in an image.”
Bitmap (AQA): “images are broken down into a rectangular grid of pixels. Each pixel will have its own colour value.”
The screen shows the image by lighting each pixel in its stored colour, row by row.
Image size is given in pixels as width × height. A 640 × 480 image is 640 pixels wide and 480 pixels high.
Number of pixels = width × height. 640 × 480 = 307,200 pixels.
More pixels in the same space show more detail, but need more bits to store.
Exam tipDefine a pixel as “a single point in an image”. AQA's mark schemes rejected “a square of colour” and “a block of colour”.
Pixel
Short for picture element. A single point in an image.
Bitmap
An image broken down into a rectangular grid of pixels, each with its own colour value.
Image size
The width × height of an image in pixels.
3.3.6 Representing images
Colour depth
Colour depth is the number of bits used to represent each pixel. It sets how many colours the image can use.
Each extra bit doubles the number of colours.
Minimum colour depth for n colours: the smallest number of bits d where 2d is at least n.
3 colours need 2 bits (2 bits give 4 codes; 1 bit gives only 2).
5 colours need 3 bits. 9 colours need 4 bits. 2 colours need just 1 bit.
Adding a colour only makes the file bigger if it needs an extra bit: going from 5 to 8 colours still needs 3 bits; going from 8 to 9 needs 4.
Colour depth (bits)
Number of colours = 2depth
1
2
2
4
3
8
4
16
8
256
24
16,777,216 (about 16.7 million)
Worked exampleAn image uses 20 different colours. What is the minimum colour depth?
24 = 16, which is less than 204 bits aren't enough
25 = 32, which is at least 205 bits are enough
5 bits
Exam tipThe commonest slips in AQA's reports: giving the number of colours as the colour depth (5 colours → “5 bits”), and saying 2 colours need 2 bits. Always ask “how many bits give at least this many codes?”
Colour depth
The number of bits used to represent each pixel.
3.3.6 Representing images
Converting between bitmaps and binary
You may be given a bit pattern and asked to draw the image, or given an image and asked for its bit pattern. Work row by row, from the top left.
Split the bit pattern into groups of colour depth bits. Each group is one pixel.
Use the image width to split the pixels into rows: an 8-pixel-wide, 1-bit image has 8 bits per row.
Use the key to turn each code into a colour, or each colour into a code.
For an image to bit pattern: write the code for each pixel, left to right, then the next row.
With a colour depth of 1 bit, each pixel is one bit: here 0 is white and 1 is blue.
With a colour depth of 2 bits, each pixel takes two bits, and a key says which code is which colour.
Worked exampleA 2-bit image is 3 pixels wide. Key: 00 white, 01 red, 10 green, 11 black. Row 1 is 110011. What colours are the pixels?
Split into 2-bit groups: 11 | 00 | 11colour depth is 2 bits
11 = black, 00 = white, 11 = blackuse the key
Black, white, black
Exam tipRead which code goes with which colour from the key in the question: don't assume 0 is white.
3.3.6 Representing images
Calculating image file sizes
For AQA, a bitmap's file size depends only on the number of pixels and the colour depth.
Size in bits = W × H × D (width in pixels × height in pixels × colour depth in bits).
Size in bytes = (W × H × D) ÷ 8.
Then ÷ 1000 for kilobytes and ÷ 1000 again for megabytes (see the topic on number bases and units). AQA rejects 1024.
Doubling the width doubles the file size. Doubling both the width and the height gives 4 times the pixels, so 4 times the size.
Raising the colour depth from 4 to 8 bits doubles the size. Real image files also hold extra data (metadata), but AQA's calculations ignore it.
Worked exampleA 40 × 30 image uses 16 colours. Calculate its size in bytes.
16 colours need 4 bits (24 = 16)find the colour depth first
40 × 30 = 1200 pixelsW × H
1200 × 4 = 4800 bits× D
4800 ÷ 8 = 600 bytes8 bits in a byte
600 bytes
Worked exampleA photo is 1200 × 800 pixels with a colour depth of 24 bits. Calculate its size in MB.
Exam tipPaper 2 has no calculator. Show every step: if the final answer is wrong, the working can still earn most of the marks.
3.3.7 Representing sound
Sampling sound
Sound is analogue: a continuous wave that can take any value. Computers can only store and process digital (binary) data, so sound must be converted.
Analogue (AQA): “continuous data – can take any value in a given range.”
A microphone turns sound into an analogue electrical signal. An analogue to digital converter (ADC) takes samples of it at regular intervals.
A sample is a measure of amplitude at a point in time. Each sample is rounded to a whole number and stored in binary.
Sampling rate: “the number of samples taken in a second”, measured in hertz (1 hertz = 1 sample per second). 44,100 Hz means 44,100 samples every second.
Sample resolution: “the number of bits per sample”. 16 bits gives 216 = 65,536 possible amplitude values; 8 bits gives 256.
A higher sampling rate captures the wave's changes more closely; a higher resolution records each amplitude more precisely. Both make the digital sound closer to the original, and both make the file larger.
Sampling: the amplitude is measured at regular points in time and each measurement is stored as a binary number.
Exam tipSampling rate must say “per second”. Sample resolution is the number of bits per sample, not “the quality”. And when asked to define hertz, don't define sampling rate: 1 hertz means once per second, so in sound it is 1 sample per second.
Analogue
Continuous data that can take any value in a given range.
Sample
A measure of amplitude at a point in time.
Sampling rate
The number of samples taken in a second, usually measured in hertz (1 hertz = 1 sample per second).
Sample resolution
The number of bits per sample.
3.3.7 Representing sound
Calculating sound file sizes
Every second, the sound file stores (sampling rate) samples, each (resolution) bits long.
Exam tipUnder half of students got full marks on AQA's most recent sound calculation. Write the formula, put the numbers in, and convert units one step at a time.