2029–2031 edition · for exams from June 2029. Students sitting exams up to November 2028 follow the current course.
1. Data representation and logic gates
How everything inside a computer is binary: logic gates, storage units, denary/binary/hex, binary addition, logical and cyclic shifts, two's complement, text, sound and images, and compression including Huffman coding.
What you need to know332 learning objectives, as printed in the syllabus
- 1.1Number systems and logic gatesChanged2026–2028 syllabus: §1.1, §10
Adds logic gate symbols and functions, cyclic shifts and the command word Convert; binary limited to 12 bits; PiB and EiB removed.
Learning objectives (17)
- 1.1.1Know that computers internally represent all data in binary
- 1.1.2Know that data is converted to binary, processed using logic gates
- 1.1.3Identify and use the standard symbols for logic gates
- 1.1.4Demonstrate the function of each logic gate limited to: (a) NOT; (b) AND; (c) OR; (d) NAND; (e) NOR; (f) XOR
- 1.1.5Know how data storage is measured, limited to: (a) bit; (b) nibble; (c) byte; (d) kibibyte (KiB); (e) mebibyte (MiB); (f) gibibyte (GiB); (g) tebibyte (TiB)
- 1.1.6Convert between each data storage measurement in 1.1.5
- 1.1.7Know the base of the denary, binary and hexadecimal number systems
- 1.1.8Convert between: (a) denary and binary; (b) denary and hexadecimal; (c) hexadecimal and binary
- 1.1.9Explain the advantages of using hexadecimal as an understandable representation of binary and identify examples where hexadecimal is used
- 1.1.10Add two positive 8-bit binary integers
- 1.1.11Describe overflow and how it can create errors in binary addition
- 1.1.12Perform logical left and right shifts of multiple places on a positive 8-bit binary integer
- 1.1.13Explain the effects of logical left and right shifts
- 1.1.14Perform cyclic left and right shifts of multiple places on a positive 8-bit binary integer
- 1.1.15Explain the effects of cyclic left and right shifts
- 1.1.16Convert positive and negative binary or denary integers to their two's complement 8-bit representation
- 1.1.17Convert two's complement 8-bit integers back to binary or denary
Logic gates will be limited to a maximum of two inputs
Conversions in both directions, positive integers only, maximum binary number length of 12 bits
- 1.2Text, sound and imagesChanged2026–2028 syllabus: §1.2
Same ideas; file-size calculations for images and sound are no longer required.
Learning objectives (10)
- 1.2.1Know that computers store characters as binary numbers
- 1.2.2Understand that a character set is a set of characters that have corresponding numeric codes
- 1.2.3Describe how a computer represents text using character sets
- 1.2.4Describe the features of the character sets: (a) American Standard Code for Information Interchange (ASCII); (b) Unicode
- 1.2.5Describe the advantages and disadvantages of: (a) ASCII; (b) Unicode
- 1.2.6Describe how a computer represents analogue sound, including: (a) sample rate; (b) sample resolution
- 1.2.7Explain the effects of changing the sample rate and sample resolution
- 1.2.8Know that a bitmap image is made up of pixels
- 1.2.9Describe how a computer uses binary to represent a bitmap image, including: (a) resolution; (b) colour depth
- 1.2.10Explain the effects of changing the resolution or the colour depth on a bitmap image
- 1.3Data compressionChanged2026–2028 syllabus: §1.3
Adds Huffman coding as a lossless method (no Huffman trees); file-size calculations removed.
Learning objectives (5)
- 1.3.1Explain the purpose of data compression for transmission and storage
- 1.3.2Explain the impact of data compression for transmission and storage
- 1.3.3Explain how images, sound and video files are compressed using lossy compression methods
- 1.3.4Explain how text, images, video and sound files are compressed using the lossless compression methods of run length encoding (RLE) and Huffman coding
- 1.3.5Describe the advantages and disadvantages of lossy and lossless compression methods and identify where each method would be appropriate from a given scenario
Candidates will not be required to create or interpret a Huffman tree
Objectives quoted from the 2029–2031 syllabus, Version 1, September 2026; © Cambridge University Press & Assessment.
Notes3every learning objective explained, with worked examples
1.1Number systems and logic gates
Everything a computer stores or processes — numbers, text, sound, pictures, instructions — is held as binary and processed by logic gates. This section gives you the number systems (binary, denary, hexadecimal), the six logic gates, storage units, binary addition and overflow, shifts and two's complement. It is the most calculation-heavy part of Paper 1, so practise the methods until they are automatic.
Why computers use binary
A computer is built from millions of tiny switches (transistors). Each switch has only two states: on or off, so it can store one binary digit (bit): 1 or 0.
- All data — numbers, characters, sound samples, pixel colours and program instructions — must be converted to binary before the computer can store or process it.
- The binary data is then processed using logic gates: circuits that take one or two binary inputs and give one binary output.
- Two states are easy to tell apart reliably, even with electrical noise, which is why binary (not denary) is used inside the hardware.
Logic gates: symbols and functions
You must recognise and draw the standard symbol for each gate and know its truth table. Gates in this section have at most two inputs.
| Gate | What the output does | Truth table (A B → X) |
|---|---|---|
| NOT | Inverts its single input | 0 → 1, 1 → 0 |
| AND | 1 only when both inputs are 1 | 00→0, 01→0, 10→0, 11→1 |
| OR | 1 when at least one input is 1 | 00→0, 01→1, 10→1, 11→1 |
| NAND | NOT AND: 0 only when both inputs are 1 | 00→1, 01→1, 10→1, 11→0 |
| NOR | NOT OR: 1 only when both inputs are 0 | 00→1, 01→0, 10→0, 11→0 |
| XOR | 1 when the inputs are different | 00→0, 01→1, 10→1, 11→0 |
Symbol shapes: NOT is a triangle with a small circle (the bubble) at its point; AND has a flat back and a round front (D-shape); OR has a curved back and a pointed front; XOR is an OR with an extra curved line behind the back. NAND and NOR are AND and OR with a bubble on the output.
The same truth tables in Python, where &, |, ^ work on single bits:
for a in (0, 1):
for b in (0, 1):
print(a, b, 'AND', a & b, 'OR', a | b, 'XOR', a ^ b,
'NAND', 1 - (a & b), 'NOR', 1 - (a | b))Measuring data storage
| Unit | Size |
|---|---|
| bit | one binary digit, 0 or 1 |
| nibble | 4 bits |
| byte | 8 bits |
| kibibyte (KiB) | 1024 bytes (2¹⁰) |
| mebibyte (MiB) | 1024 KiB (2²⁰ bytes) |
| gibibyte (GiB) | 1024 MiB (2³⁰ bytes) |
| tebibyte (TiB) | 1024 GiB (2⁴⁰ bytes) |
Converting: going to a smaller unit, multiply; going to a bigger unit, divide. Bits ↔ bytes uses 8; every step from bytes up uses 1024.
- 3 GiB in MiB: 3 × 1024 = 3072 MiB
- 4 KiB in bits: 4 × 1024 = 4096 bytes; 4096 × 8 = 32 768 bits
- 2 097 152 bytes in MiB: 2 097 152 ÷ 1024 = 2048 KiB; 2048 ÷ 1024 = 2 MiB
- 6 nibbles = 24 bits = 3 bytes
Denary, binary and hexadecimal
The base is how many different digits a number system uses.
- Denary — base 10, digits 0–9.
- Binary — base 2, digits 0 and 1. Place values (right to left): 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048.
- Hexadecimal — base 16, digits 0–9 then A=10, B=11, C=12, D=13, E=14, F=15. One hex digit = exactly one nibble (4 bits).
In the exam binary numbers are at most 12 bits long and conversions use positive integers only.
Worked conversions
Denary → binary (156): write the place values and take away the largest that fits.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 1 | 0 | 0 | 1 | 1 | 1 | 0 | 0 |
156 − 128 = 28, 28 − 16 = 12, 12 − 8 = 4, 4 − 4 = 0 → 10011100.
Binary → hex: split into nibbles from the right: 1001 1100 → 9 and 12 → 9C.
Hex → binary (B7): B = 1011, 7 = 0111 → 10110111.
Hex → denary (B7): 11 × 16 + 7 = 183.
Denary → hex (183): 183 ÷ 16 = 11 remainder 7 → B and 7 → B7.
12-bit example: 2748 = 1010 1011 1100 → hex ABC (10 × 256 + 11 × 16 + 12 = 2748).
Check any answer in Python:
print(bin(156), hex(156), int('10110111', 2), int('B7', 16))
# 0b10011100 0x9c 183 183Why hexadecimal is used
Hexadecimal is a human-friendly way of writing binary — the computer still stores binary.
- It is shorter: 12 binary digits become 3 hex digits, so it is easier to read and remember.
- There are fewer mistakes when people read, copy or type it.
- It converts to and from binary easily — each hex digit is one nibble.
Where it is used: colour codes in HTML/CSS (#FF0000 is red), MAC addresses (00:1A:2B:3C:4D:5E), IPv6 addresses, memory addresses and error codes, and showing memory contents in a debugger.
Adding two 8-bit binary integers
Add column by column from the right, carrying like denary:
| Sum in a column | Write | Carry |
|---|---|---|
| 0 + 0 | 0 | 0 |
| 0 + 1 | 1 | 0 |
| 1 + 1 | 0 | 1 |
| 1 + 1 + 1 (with carry) | 1 | 1 |
Example: 01101101 (109) + 01011011 (91)
carry 1 1 1 1 1 1 1
0 1 1 0 1 1 0 1 (109)
+ 0 1 0 1 1 0 1 1 (91)
= 1 1 0 0 1 0 0 0 (200)Check: 109 + 91 = 200 and 11001000 = 128 + 64 + 8 = 200.
Overflow
An 8-bit register can hold 0 to 255. If the result of an addition is bigger than 255, a ninth bit is needed — this is an overflow error.
Example: 11001000 (200) + 01100100 (100) = 300 = 1 00101100. The register keeps only 8 bits, 00101100 = 44, so the stored answer is wrong.
- Overflow happens because the result needs more bits than the register has.
- The extra carry bit is lost, so the stored value is incorrect; a program using it may crash or give wrong output.
- The CPU sets an overflow flag so the error can be detected.
Logical shifts
A logical shift moves every bit left or right by a number of places. Bits shifted off the end are lost and the empty places are filled with 0.
- Left 2: 00010110 (22) → 01011000 (88) — each left place multiplies by 2, so 2 places = × 4.
- Right 3: 10110000 (176) → 00010110 (22) — each right place divides by 2 (whole-number), so 3 places = ÷ 8.
Effect when bits are lost: 01100101 (101) shifted left 3 → 00101000 (40), not 808 — the 1s pushed off the left end are lost, so the result is wrong. A right shift that loses 1s off the right end loses precision (e.g. 00000111 = 7 right 1 → 00000011 = 3, not 3.5).
x = 0b00010110
print(format((x << 2) & 0xFF, '08b')) # 01011000
print(format(0b10110000 >> 3, '08b')) # 00010110Cyclic (circular) shifts
In a cyclic shift nothing is lost: the bits pushed off one end come back in at the other end.
- Cyclic left 3 of 10110010: the first three bits 101 move to the end → 10010101.
- Cyclic right 2 of 10110010: the last two bits 10 move to the front → 10101100.
Effect: the same bits are kept in a new order, so a cyclic shift is not a multiply or divide; shifting 8 places brings back the original number. It is used where no data may be lost, e.g. in encryption and checksum calculations.
def rotl(x: int, n: int) -> int:
n %= 8
return ((x << n) | (x >> (8 - n))) & 0xFF
print(format(rotl(0b10110010, 3), '08b')) # 10010101Two's complement (8-bit)
Two's complement stores negative integers. The leftmost bit has a negative place value: −128.
| −128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|
The range is −128 to +127. A number starting with 1 is negative; starting with 0 is positive (and is written exactly like ordinary binary).
Denary → two's complement (−45):
- Write +45 in 8-bit binary: 00101101
- Invert every bit: 11010010
- Add 1: 11010011
Check: −128 + 64 + 16 + 2 + 1 = −45. ✓
Two's complement → denary (11101100): −128 + 64 + 32 + 8 + 4 = −20.
Shortcut for negatives: from the right, keep every bit up to and including the first 1, then invert the rest (00101101 → 11010011).
print(format(-45 & 0xFF, '08b')) # 11010011
v = 0b11101100
print(v - 256 if v >= 128 else v) # -20Exam tips
- Show your working for conversions — draw the place-value row; method marks are often available even if one bit is wrong.
- Give binary answers with the number of bits asked for (8-bit = pad with leading 0s).
- For 'describe overflow' say: the result is larger than the register can hold / needs more than 8 bits, the extra bit is lost, so the stored value is wrong.
- For a shift question state the direction, the number of places, what fills the gaps (0 for logical) and what happens to the lost bits.
- For 'advantages of hex' give reasons about people (shorter, fewer errors, easier to read) — not that computers use hex.
- Draw gate symbols clearly: the NOT/NAND/NOR bubble and the extra XOR line are what the mark depends on.
Mistakes that lose marks
- Saying computers 'store data in hexadecimal' — they store binary; hex is only for humans.
- Using 1000 instead of 1024 between bytes, KiB, MiB, GiB and TiB.
- Forgetting the final carry and missing that an overflow happened.
- Filling a cyclic shift with 0s, or losing bits in it — the bits wrap round.
- Inverting the bits for a two's complement number but forgetting to add 1.
- Mixing up NAND and NOR, or AND and OR, in a truth table.
1.2Text, sound and images
Text, sound and images are not numbers, but a computer can only store binary — so each has a way of being turned into binary. This section explains character sets (ASCII and Unicode), how sound is sampled, and how bitmap images are stored as pixels, and what happens to quality and size when you change the settings.
Characters are stored as binary numbers
A character set is a list of characters, each with its own numeric code. To store text, the computer stores the code of each character, in binary.
- Each key press is converted to the character's code, e.g. 'A' = 65 = 01000001.
- The codes are sequential: 'B' = 66, 'C' = 67, so text can be sorted by comparing codes.
- When the text is displayed, the computer looks the code up in the same character set to show the right symbol. Both computers must use the same character set.
print(ord('A'), format(ord('A'), '08b'), chr(66)) # 65 01000001 BASCII and Unicode
| ASCII | Unicode | |
|---|---|---|
| Bits per character | 7 bits (often stored in a byte; extended ASCII uses 8) | up to 32 bits (often 16 or 32; encodings such as UTF-8 use 1–4 bytes) |
| Number of characters | 128 (256 extended) | over a million possible codes |
| What it covers | English letters, digits, punctuation, control codes | characters of almost every language, symbols and emojis |
| Advantage | each character uses less storage, so files are smaller and faster to send | can represent every language and emojis; one worldwide standard |
| Disadvantage | cannot represent most languages or emojis | each character needs more bits, so files are larger |
Unicode's first 128 codes are the same as ASCII, so ASCII text is still valid Unicode.
How sound is represented
Sound is an analogue wave. To store it, the computer samples the wave: it measures the amplitude (height) of the wave at regular time intervals and stores each measurement as a binary number.
- Sample rate — how many samples are taken per second (measured in hertz, e.g. 44 100 Hz).
- Sample resolution — the number of bits used to store each sample (e.g. 16 bits). More bits = more possible amplitude values.
The stored samples are only an approximation of the wave; the gaps between samples and the rounding of each sample lose a little detail.
Changing the sample rate and resolution
| Change | Effect on quality | Effect on file |
|---|---|---|
| Higher sample rate | more samples per second, so the recording is closer to the original wave | larger file |
| Lower sample rate | detail between samples is lost; quality drops | smaller file |
| Higher sample resolution | each sample is more accurate (more amplitude levels), wider dynamic range | larger file |
| Lower sample resolution | amplitudes are rounded more; sound is less accurate | smaller file |
The trade-off is always quality versus file size (and so storage space and transmission time).
Bitmap images: pixels, resolution and colour depth
A bitmap image is a grid of pixels (picture elements). Each pixel is one colour, and that colour is stored as a binary code.
- 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's colour. 1 bit gives 2 colours (black/white), 8 bits give 256 colours, 24 bits give over 16 million colours.
The file stores the colour code of every pixel in order, row by row, plus some extra data about the image (its width, height and colour depth).
Changing the resolution or colour depth
| Change | Effect on the image | Effect on file size |
|---|---|---|
| Higher resolution | more pixels, so more detail and sharper when enlarged | larger |
| Lower resolution | fewer pixels; image looks pixelated (blocky) when enlarged | smaller |
| Higher colour depth | more colours possible, more realistic, smoother shading | larger |
| Lower colour depth | fewer colours; shades look banded | smaller |
Exam tips
- Define sample rate as 'number of samples per second' and sample resolution as 'number of bits per sample' — learn those exact phrases.
- For 'explain the effect' questions give BOTH the quality effect and the file size effect.
- Colour depth is bits per pixel, not 'number of colours' — state the bits, then say what that allows.
- ASCII vs Unicode: compare the number of characters/languages and the storage per character.
Mistakes that lose marks
- Saying a higher sample rate makes the sound louder — it makes it more accurate.
- Confusing resolution (number of pixels) with colour depth (bits per pixel).
- Saying Unicode always uses 16 bits — it can use up to 32 bits per character.
- Writing that ASCII can represent all languages.
1.3Data compression
Compression makes files smaller so they take less storage and can be sent faster. Lossy methods throw away data people will not notice; lossless methods — run length encoding (RLE) and Huffman coding — let the original be rebuilt exactly. You must be able to choose the right method for a scenario.
Purpose and impact of compression
Purpose: reduce the file size.
Impact on storage: smaller files use less storage space on a device or server, so more files fit and storage costs less.
Impact on transmission: smaller files upload and download faster, use less bandwidth and less mobile data, and stream with less buffering. Email attachments may only be sent if under a size limit.
Compressing and decompressing takes some processing time, and lossy compression lowers quality.
Lossy compression
Lossy compression permanently removes data, so the original file cannot be rebuilt exactly. It removes the data people are least likely to notice.
- Images (e.g. JPEG): reduce the colour depth or resolution, and merge pixels of very similar colours into one colour.
- Sound (e.g. MP3): perceptual coding removes sounds the human ear cannot hear (very high or low frequencies) and quieter sounds played at the same time as louder ones; the sample rate or resolution can also be reduced.
- Video (e.g. MP4): compresses each frame like an image and stores only the changes between frames instead of every full frame; frame rate or resolution can be reduced.
Lossless: run length encoding (RLE)
RLE replaces a run of the same repeated value with one copy of the value and a count of how many times it repeats. It works well on data with long runs (simple images, icons) and can make data with few repeats larger.
Text: AAAABBBCCD (10 characters) → 4A 3B 2C 1D (8 symbols).
Image: a row of pixels White ×5, Black ×3, White ×2 (WWWWWBBBWW) → 5W 3B 2W.
Decompressing repeats each value by its count, giving back exactly the original.
from itertools import groupby
def rle(text: str) -> str:
return ''.join(f'{len(list(g))}{ch}' for ch, g in groupby(text))
print(rle('AAAABBBCCD')) # 4A3B2C1DLossless: Huffman coding
Huffman coding gives each character a variable-length binary code: the most frequent characters get the shortest codes, rare ones get longer codes. No code is the start of another code, so the bit stream can be decoded without gaps. (You will be given the codes — you do not need to build or read a Huffman tree.)
Example — the word BANANA: A appears 3 times, N twice, B once. Given codes:
| Character | Frequency | Code |
|---|---|---|
| A | 3 | 0 |
| N | 2 | 10 |
| B | 1 | 11 |
Encoded: B A N A N A → 11 0 10 0 10 0 → 110100100 = 9 bits. In 8-bit ASCII it would need 6 × 8 = 48 bits.
Decoding 110100100: read bits until they match a code — 11 = B, 0 = A, 10 = N, 0 = A, 10 = N, 0 = A → BANANA. Nothing is lost.
Lossy or lossless? Advantages, disadvantages and choosing
| Lossy | Lossless | |
|---|---|---|
| Advantages | much smaller files; faster to send and stream | original file rebuilt exactly; no loss of quality |
| Disadvantages | data is lost permanently; quality is lower; can't be undone | files are not reduced as much |
| Use for | photos on websites, streaming music and video, video calls | text documents, program code, spreadsheets, medical or legal images, anything that must be exact |
In a scenario, ask: must the file be exactly the same afterwards? If yes (text, code, data, evidence) → lossless. If small size matters more and a little quality loss won't be noticed → lossy.
Exam tips
- When explaining a method, say how it works AND that the data is (or is not) lost.
- For RLE questions write each run as count + value in the order the data appears.
- Huffman questions: count the bits of the encoded message and compare with 8 bits per character for ASCII if asked how much it saves.
- For 'which method' questions justify from the scenario (e.g. 'a program file must be identical, so lossless').
Mistakes that lose marks
- Saying lossless compression 'removes unnecessary data' — that is lossy.
- Saying RLE always makes files smaller — with few repeats it can make them larger.
- Giving common characters the longest Huffman codes (it is the opposite).
- Recommending lossy compression for text or program files.
Infographics5download any diagram as PNG or SVG
Number system conversions
Logic gate symbols
Lossless vs lossy compression
Logical and cyclic shifts
Huffman coding
Python for this topic2Python 3.10+, the only language on Paper 2 — runs in your browser
Key terms16use these exact words in the exam
Test yourself
Check you know the 2029–2031 content
Written for the new syllabus only: every card and question traces to a learning objective above. Rounds are random, and marks earn XP on your dashboard.
4 decks · 69 cards · 19 quiz questions.
From the current course
Most of this topic is taught in the 2026–2028 course today. Its notes and past-paper questions still help — skip anything the 2029–2031 syllabus removed (see the notes above).
- 1. Data Representation2026–2028 topic · 160 past-paper questions
- 10. Boolean Logic2026–2028 topic · 92 past-paper questions

