Mission 1 · Spec 3.3.1 & 3.3.3
Why computers think in binary
Number bases, and the units we use to measure data: bits, nibbles, bytes, kilobytes and beyond.
- Starter 5 min
- Learn 10 min
- Lab 15 min
- Quiz 10 min
- Exam 10 min
Three light switches
You have three light switches in a row. Each one is either on or off. How many different patterns can you make? Write them all down before you reveal.
Reveal
8 patterns: 000 001 010 011 100 101 110 111. Every extra switch doubles the number of patterns, so n switches give 2n patterns. A computer is billions of tiny switches (transistors), which is exactly why it stores everything in binary.
Key ideas
Denary (base 10)
Digits 0–9. Place values go up in powers of 10: 1, 10, 100, 1000. Also called decimal.
Binary (base 2)
Digits 0 and 1. Place values go up in powers of 2: 1, 2, 4, 8, 16, 32, 64, 128. Computers use binary for all data and instructions.
Hexadecimal (base 16)
Digits 0–9 then A–F (A = 10 … F = 15). Place values: 1, 16, 256.
Why do we use hex?
It is a shorthand for humans. One hex digit represents exactly 4 bits, so it is shorter, easier to read and remember, and people make fewer mistakes copying it. Computers do not store or process hex.
Units of information
| Unit | Equals | Example |
|---|---|---|
| bit | a single 0 or 1 | one switch |
| nibble | 4 bits | one hex digit |
| byte | 8 bits | one character of text (roughly) |
| kilobyte (kB) | 1,000 bytes | a short email |
| megabyte (MB) | 1,000 kB | a photo |
| gigabyte (GB) | 1,000 MB | a film |
| terabyte (TB) | 1,000 GB | a hard drive |
AQA uses the SI prefixes, which go up in powers of 10 (1 kB = 1,000 bytes). You may see 1,024 elsewhere: those power-of-2 units are properly called kibibytes and mebibytes, and you do not need them for the exam.
Pattern counter
Unit ladder
Exam-style questions
1. Explain why programmers often use hexadecimal instead of binary.
[2 marks]Mark scheme
- Easier for humans to read / understand / remember (1)
- Shorter, so fewer mistakes when writing or copying it (1)
- Each hex digit maps to exactly 4 bits, so it converts easily to binary (1)
- Max 2. Do not accept "hex uses less memory" or "computers use hex".
2. Put these in order from smallest to largest: 3,000,000 kB, 1 TB, 1 GB, 2,000 MB
Mark scheme
- 1 GB, 2,000 MB, 3,000,000 kB, 1 TB (1). Working: 2,000 MB = 2 GB; 3,000,000 kB = 3 GB; 1 TB = 1,000 GB.
3. A system uses 5 bits for each code. How many different codes can it represent?
[1 mark]Mark scheme
- 32 (25) (1)
TUTOR NOTES
- Misconception: 1 kB = 1,024 bytes. For AQA it is 1,000. Credit students who know the history, but drill the SI version.
- Misconception: "the computer stores hex". Hex is only a human-friendly view of binary.
- Hook: ask what 16 switches could represent (65,536 patterns: every Unicode character in the Basic Multilingual Plane).
- Extension: how many bits would you need to give every student in the school a unique ID?
Mission 2 · Spec 3.3.2
Converting between bases
Move confidently between denary (0–255), 8-bit binary and 2-digit hex (00–FF), in every direction.
- Starter 5 min
- Learn 15 min
- Lab 15 min
- Quiz 10 min
- Exam 10 min
Birthday in binary
Take the day of the month you were born (1–31). Using only the numbers 16, 8, 4, 2 and 1, each at most once, which ones add up to it?
Reveal the trick
If you were born on the 22nd: 16 + 4 + 2 = 22. Write a 1 under each number you used and a 0 under the rest: 16 8 4 2 1 → 1 0 1 1 0. You just wrote 22 in binary.
Methods
Binary → denary
Write the place values above the bits. Add up the place values that have a 1.
128 64 32 16 8 4 2 1
1 0 0 1 0 1 1 0
= 128 + 16 + 4 + 2 = 150
Denary → binary
Work left to right. If the place value fits into what is left, write 1 and subtract it; otherwise write 0.
99 → 64 ✓ (35) 32 ✓ (3) 16 ✗ 8 ✗ 4 ✗ 2 ✓ (1) 1 ✓
= 0110 0011
Binary ↔ hex
Split the byte into two nibbles. Convert each nibble (8 4 2 1) to one hex digit.
1011 1110 → 11 | 14 → BE
Hex ↔ denary
Left digit × 16, plus right digit. To go back, divide by 16: the whole number is the left digit, the remainder is the right.
7A = 7×16 + 10 = 122
200 ÷ 16 = 12 r 8 → C8
The 16 nibbles you need to know
Bit flipper
Click the bits to switch them on and off.Exam-style questions
1. Convert the binary number 1101 0110 into denary.
Mark scheme
- 214 (1). 128 + 64 + 16 + 4 + 2
2. Convert the hexadecimal number 3C into (a) binary and (b) denary.
Mark scheme
- (a) 0011 1100 (1)
- (b) 60 (1). 3 × 16 + 12
3. Convert the denary number 199 into hexadecimal. Show your working.
[2 marks]Mark scheme
- Working, e.g. 199 ÷ 16 = 12 remainder 7, or 1100 0111 split into nibbles (1)
- C7 (1)
TUTOR NOTES
- Misconception: dropping leading zeros. AQA asks for 8-bit answers: 5 is
0000 0101. - Misconception: converting hex digits in the wrong order, or writing "12" instead of "C".
- Tip: get students to write the place-value header (128 … 1) at the top of every answer. It earns method marks.
- Extension: what is the largest number 2 hex digits can hold, and why is it the same as 8 bits?
Mission 3 · Spec 3.3.4
Binary arithmetic
Add up to three 8-bit numbers with carries, and use binary shifts to multiply and divide by powers of 2.
- Starter 5 min
- Learn 10 min
- Lab 20 min
- Quiz 10 min
- Exam 10 min
Add like it's primary school
Work out 478 + 356 in columns, and circle every carry. Now imagine you only had the digits 0 and 1. When would you need to carry?
Reveal
478 + 356 = 834, with carries out of the units and tens columns. In binary you carry whenever a column adds up to 2 or more, because 2 is written 10.
The four rules of binary addition
- Work from right to left, just like denary. Write carries under or above the next column.
- With three numbers a column can reach 4 or 5. 4 is
100: write 0 and carry 2 (a 1 two columns along). - If the answer needs a 9th bit, it will not fit in 8 bits. That is called overflow.
Binary shifts
Shift left by n
Every bit moves n places left. Zeros fill in on the right. The number is multiplied by 2n.
0000 1101 (13) « 2 → 0011 0100 (52)
Shift right by n
Every bit moves n places right. Zeros fill in on the left. The number is divided by 2n, and any bits that fall off are lost, so the result is rounded down.
0001 0111 (23) » 1 → 0000 1011 (11)
Shifts are used because they are a very fast way for a processor to multiply or divide by 2, 4, 8, 16 …
Column adder
Click any input bit to change it, then step through.Shift machine
Exam-style questions
1. Add the binary numbers 0101 1011 and 0011 0110. Give your answer in binary.
Mark scheme
1001 0001(2)- 1 mark if only one bit is wrong, or for correct carries shown
- Check: 91 + 54 = 145
2. Add together 0001 1010, 0010 0101 and 0000 1111.
Mark scheme
0100 1110(3)- Max 2 if one bit is wrong; max 1 if two bits are wrong
- Check: 26 + 37 + 15 = 78
3. 0001 0110 is shifted left by 2 places. Give the result in binary, and state the effect on the value.
Mark scheme
0101 1000(1)- The number is multiplied by 4 (22 → 88) (1)
4. 1011 0101 is shifted right by 3 places, giving 22. Explain why the result is not exactly 181 ÷ 8.
Mark scheme
- The three rightmost bits (101) are lost / fall off the end (1)
- So the fractional part is lost and the result is rounded down; 181 ÷ 8 = 22.625 (1)
TUTOR NOTES
- Misconception: 1 + 1 + 1 = "10 with a carry". It is 11: write 1, carry 1.
- Misconception: left and right mixed up. Anchor it: "left makes it larger".
- Exam habit: always convert both numbers and the answer to denary to check. It takes 20 seconds.
- Extension: what happens to 1100 0000 shifted left by 1? Link it to overflow.
Mission 4 · Spec 3.3.5
Characters and codes
How text becomes numbers: character sets, ASCII, Unicode, and the trick of working out one code from another.
- Starter 5 min
- Learn 10 min
- Lab 15 min
- Quiz 10 min
- Exam 10 min
Crack the code
A = 1, B = 2, C = 3 … What does 8 9 7 8 spell? Now: why would a computer need more than 26 codes?
Reveal
HIGH. A computer also needs lower case, digits, punctuation, spaces and control codes (like "new line"), and letters from every other language. That full list of characters with their codes is called a character set.
Key ideas
Character set
A list of characters a computer can use, each mapped to a unique binary code.
ASCII
Uses 7 bits per character, so 27 = 128 characters. Enough for English letters, digits, punctuation and control codes.
Unicode
Uses more bits per character, so it can represent many more characters: every major writing system, symbols and emoji. The first 128 codes are the same as ASCII.
Trade-off
Unicode supports far more characters, but text stored in it can take more space than ASCII.
Codes are in order
| Character | Denary | Binary (7-bit) | Pattern |
|---|---|---|---|
| A | 65 | 100 0001 | B = 66, C = 67 … |
| a | 97 | 110 0001 | lower case = upper case + 32 |
| 0 | 48 | 011 0000 | the digit '7' is 55, not 7 |
| space | 32 | 010 0000 | a space is a character too |
In the exam you will be given one code and asked for another. Count along the alphabet: if 'C' is 67, then 'H' is 67 + 5 = 72.
Text x-ray
Type anything and see it the way the computer does.Intercepted transmission
Exam-style questions
1. The ASCII code for 'E' is 69. What is the ASCII code for 'H'?
[1 mark]Mark scheme
- 72 (1)
2. The character 'm' has the denary code 109. Give the denary code for 'M'.
[1 mark]Mark scheme
- 77 (1). Upper case is 32 less than lower case.
3. How many bits are needed to store the text EXAM PAPER using 7-bit ASCII?
Mark scheme
- 70 (1). 10 characters including the space × 7 bits.
4. Compare ASCII and Unicode.
[3 marks]Mark scheme
- ASCII uses 7 bits / can represent 128 characters (1)
- Unicode uses more bits per character, so can represent many more characters (1)
- Unicode includes characters from other languages / symbols / emoji (1)
- The first 128 Unicode codes are the same as ASCII (1)
- Unicode text may take more storage space (1)
- Max 3
TUTOR NOTES
- Misconception: ASCII is 8-bit. For AQA it is 7-bit (128 characters).
- Misconception: the digit '5' has code 5. It is 53, because digits start at 48.
- Misconception: forgetting spaces when counting characters.
- Extension: why does upper case to lower case only change one bit? (32 is a single place value.)
Mission 5 · Spec 3.3.6
Pictures made of numbers
Bitmaps, pixels, resolution and colour depth, and how to calculate the size of an image file.
- Starter 5 min
- Learn 10 min
- Lab 20 min
- Quiz 10 min
- Exam 10 min
Zoom in
If you zoom right into a photo on your phone, what do you eventually see? How could you describe what you see using only numbers?
Reveal
Tiny squares of solid colour called pixels. Give each colour a binary code, then list the code of every pixel, row by row. That list is a bitmap.
Key ideas
Pixel
The smallest single element of an image: one dot of one colour ("picture element").
Resolution
The number of pixels in the image, given as width × height, e.g. 1920 × 1080.
Colour depth
The number of bits used for each pixel. With n bits you get 2n colours.
The effect
More pixels or a bigger colour depth gives a better-quality image, and a bigger file.
file size (bytes) = that ÷ 8
Example: 100 × 50 pixels with 8-bit colour → 100 × 50 × 8 = 40,000 bits = 5,000 bytes = 5 kB.
Pixel studio
Paint on the grid. Then drop the colour depth or resolution and watch what you lose.Exam-style questions
1. An image is 200 pixels wide and 100 pixels high, with a colour depth of 4 bits. Calculate the file size in bytes. Show your working.
[2 marks]Mark scheme
- 200 × 100 × 4 = 80,000 bits (1)
- ÷ 8 = 10,000 bytes (1)
2. How many different colours can be shown with a colour depth of 6 bits?
[1 mark]Mark scheme
- 64 (1)
3. Explain the effect of increasing the colour depth of an image.
[2 marks]Mark scheme
- More colours can be represented / more bits per pixel, so the image is higher quality / more realistic (1)
- The file size increases (1)
4. Define the terms pixel and resolution.
[2 marks]Mark scheme
- Pixel: the smallest single element / dot of colour in an image (1)
- Resolution: the number of pixels in an image / width × height in pixels (1)
TUTOR NOTES
- Misconception: forgetting to divide by 8 when the question asks for bytes.
- Misconception: confusing colour depth (bits) with number of colours. 8 colours needs 3 bits, not 8.
- Lab prompt: switch to 8 × 8 then back to 16 × 16. Why doesn't the robot's detail come back? (Data thrown away can't be recovered.)
- Extension: what is the minimum colour depth for 100 colours? (7 bits, as 26 = 64 is too few.)
Mission 6 · Spec 3.3.7
Sampling sound
Turning a smooth analogue wave into digital numbers: sample rate, sample resolution and file size.
- Starter 5 min
- Learn 10 min
- Lab 20 min
- Quiz 10 min
- Exam 10 min
Flip-book sound
A flip-book shows movement using separate still drawings. How could you record a smooth, continuous sound using separate numbers? What would make the recording more accurate?
Reveal
Measure the height (amplitude) of the sound wave again and again, at regular intervals, and store each measurement as a binary number. Measuring more often, and more precisely, makes the recording closer to the real sound.
Key ideas
Analogue → digital
Sound is an analogue wave. To store it, the amplitude is measured at regular intervals and each measurement is stored in binary.
Sample
One measurement of the amplitude of the sound wave at a point in time.
Sample rate
The number of samples taken each second, measured in hertz (Hz). CD audio uses 44,100 Hz.
Sample resolution
The number of bits used for each sample. More bits means more possible amplitude values.
Increasing the sample rate or the sample resolution makes the recording closer to the original sound, and makes the file bigger.
Sampling scope
Listen to the difference
File size calculator
Exam-style questions
1. A 10-second sound clip is recorded with a sample rate of 16,000 Hz and a sample resolution of 8 bits. Calculate the file size in kilobytes. Show your working.
[3 marks]Mark scheme
- 16,000 × 8 × 10 = 1,280,000 bits (1)
- ÷ 8 = 160,000 bytes (1)
- ÷ 1,000 = 160 kB (1)
2. Define sample rate and sample resolution.
[2 marks]Mark scheme
- Sample rate: the number of samples taken per second (1)
- Sample resolution: the number of bits used to store each sample (1)
3. Describe the effect of increasing the sample rate of a recording.
[2 marks]Mark scheme
- The recording is more accurate / closer to the original sound / better quality (1)
- The file size increases (1)
TUTOR NOTES
- Misconception: forgetting to multiply by the number of seconds (and converting minutes to seconds).
- Misconception: "sample rate is how many bits". Hz means per second.
- Lab prompt: at 1 bit the wave becomes a square wave. Why? (Only two levels exist.)
- Extension: why can't you hear a difference above about 44,100 Hz? (Human hearing tops out around 20,000 Hz.)
Mission 7 · Spec 3.3.8
Squeezing data
Why we compress data, and two lossless methods you must know: run length encoding and Huffman coding.
- Starter 5 min
- Learn 15 min
- Lab 20 min
- Quiz 10 min
- Exam 10 min
Say it shorter
Read this aloud in as few words as possible: WWWWWWWWWWBBBWWWWWWWWWW
Reveal
"10 W, 3 B, 10 W." You just did run length encoding. Morse code uses the other big idea: common letters like E (·) get short codes and rare ones like Q (– – · –) get long ones. That is the idea behind Huffman coding.
Key ideas
Why compress?
Smaller files use less storage space, transfer faster, and use less bandwidth when sent over a network.
Run length encoding (RLE)
Replaces runs of the same value with frequency/data pairs. 0000011100 → 5 0 3 1 2 0. Works best with long runs; with few runs it can make data bigger.
Huffman coding
Builds a tree from how often each character appears. Frequent characters get short codes, rare ones get longer codes.
Reading a Huffman tree
Start at the root. Follow the branches to the character, writing 0 for each left branch and 1 for each right branch.
ASCII bits = number of characters × 7
RLE workbench
Click the pixels to make runs.Huffman tree builder
You won't be asked to build a tree in the exam, but building one makes reading them easy.Exam-style questions
1. The Huffman tree below was built for the text SEASHELLS.
(a) Give the Huffman code for S. [1]
(b) Calculate the number of bits needed to store SEASHELLS with this tree. [2]
(c) How many bits are saved compared with 7-bit ASCII? [1]
Mark scheme
2. Use run length encoding to compress this bit pattern into frequency/data pairs: 0000011100000011
Mark scheme
5 0 3 1 6 0 2 1(2)- 1 mark for two or three pairs correct
3. Give two reasons why data is compressed.
[2 marks]Mark scheme
- Uses less storage space (1)
- Faster to transmit / less bandwidth needed / quicker to download (1)
4. Explain why RLE would not reduce the size of the pattern 01010101.
Mark scheme
- There are no runs / every run has length 1 (1)
- Each bit becomes a frequency/data pair, so more data is stored than the original (1)
TUTOR NOTES
- Misconception: counting the number of different codes instead of multiplying each code length by its frequency.
- Misconception: writing RLE pairs as data then frequency. AQA wants frequency first.
- Lab prompt: type a message with every letter different. Why does Huffman barely help?
- Extension: both methods here are lossless. What would lossy compression throw away in an image or a song?