Syllabus & Goals 3 min
Cambridge 1.1 · Number systems Paper 1 · Computer Systems
By the end of this lesson you can:
- Convert a denary number to binary using two methods.
- Convert between binary and hexadecimal in groups of four bits.
- State why hexadecimal is used — MAC addresses, IP addresses, HTML colour codes and error codes.
Recap / Warm-Up 5 min
Last lesson you converted binary to denary by adding place values. Now we go the other way, and meet a third system.
Quick starter
Using the headings 128 64 32 16 8 4 2 1, which columns add up to 20?
Reveal the answer
16 + 4 = 20, so 20 in binary is 00010100. That subtraction idea is the first conversion method below.
Key Concept — converting & hexadecimal 14 min
Denary → binary: two methods
Method 1 — subtraction. Take away the largest power of 2 you can, again and again, until you reach 0. Put a 1 in each column you used.
Method 2 — division by 2. Divide the number by 2 repeatedly, writing the remainder each time. Read the remainders from bottom to top.
The hexadecimal (base 16) system
Hexadecimal — hex for short — is a base 16 system, so it needs 16 digits: 0–9 then A B C D E F.
| Binary | Hex | Denary | Binary | Hex | Denary |
|---|---|---|---|---|---|
| 0000 | 0 | 0 | 1000 | 8 | 8 |
| 0001 | 1 | 1 | 1001 | 9 | 9 |
| 0010 | 2 | 2 | 1010 | A | 10 |
| 0011 | 3 | 3 | 1011 | B | 11 |
| 0100 | 4 | 4 | 1100 | C | 12 |
| 0101 | 5 | 5 | 1101 | D | 13 |
| 0110 | 6 | 6 | 1110 | E | 14 |
| 0111 | 7 | 7 | 1111 | F | 15 |
Why bother with hex? Four real uses
A computer only works in binary, but long binary numbers are hard for people to read. Hex is shorter — one hex digit replaces four bits — so engineers use it for:
- Error codes — shown in hex, pointing to a memory location.
- MAC addresses — 48 bits as six pairs of hex digits.
- IP addresses — IPv6 is a 128-bit number written in hex.
- HTML colour codes —
#RRGGBB, two hex digits each for red, green and blue.
#FF9966 means red = FF (255), green = 99 (153), blue = 66 (102). Two hex digits per colour, six in total.Diagram · Advaslearning Hub (replace with a researched colour-picker screenshot in production)Worked Example 12 min
(a) Denary 142 → binary
Method 1 (subtraction): 142 = 128 + 8 + 4 + 2.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 1 | 0 | 0 | 0 | 1 | 1 | 1 | 0 |
So 142 = 10001110.
(b) Binary 101111100001 → hex
Split into groups of four from the right, then read each group from the table:
1011 1110 0001 → B E 1 → hex BE1.
(c) Hex 45A → denary
Multiply each digit by its column value (256, 16, 1), remembering A = 10:
(4 × 256) + (5 × 16) + (10 × 1) = 1024 + 80 + 10 = 1114.
The same idea as an algorithm
Cambridge pseudocode
// Convert a positive denary number to 8-bit binary (division-by-2 method)
DECLARE Number, Index : INTEGER
DECLARE Bits : ARRAY[1:8] OF INTEGER
Number ← 142
FOR Index ← 8 TO 1 STEP -1
Bits[Index] ← Number MOD 2
Number ← Number DIV 2
NEXT Index
OUTPUT "The 8 bits, most significant first:"
FOR Index ← 1 TO 8
OUTPUT Bits[Index]
NEXT IndexThe same algorithm in Python (IDLE)
# Convert a positive denary number to binary (division-by-2 method) number = 142 bits = [] while number > 0: bits.insert(0, number % 2) number = number // 2 print("Binary is", bits)
Output
Binary is [1, 0, 0, 0, 1, 1, 1, 0]
Try It Yourself 12 min
Goal: Convert the denary number 59 to an 8-bit binary number.
Hint: 59 = 32 + 16 + 8 + 2 + 1.
Goal: Convert the binary number 10111110 to hexadecimal.
Hint: split into 1011 and 1110 first.
Goal: Convert the hex number C8F to denary, showing your working.
Hint: C = 12 and F = 15.
📝 Exam Practice 10 min
Convert the binary number 11001010 to hexadecimal.
Mark scheme
1100 1010→CA(1).
Identify two uses of the hexadecimal number system.
Mark scheme
- Any two of: MAC addresses · IPv6 / IP addresses · HTML colour codes · error codes · assembly / machine code (1 each, max 2).
Explain why programmers often use hexadecimal instead of binary.
Mark scheme
- One hex digit represents four binary digits, so hex is shorter (1).
- Shorter numbers are easier for people to read / write / remember, with fewer errors (1).
Recap & Key Terms 3 min
Convert denary to binary by subtraction or by dividing by 2. Hexadecimal is base 16 (0–9, A–F); four bits make one hex digit, so binary ↔ hex is just grouping in fours. Hex is used for MAC/IP addresses, HTML colours and error codes.
- Hexadecimal number system
- A base 16 system using the digits 0–9 and letters A–F.
- MAC address
- A 48-bit number (six pairs of hex digits) that uniquely identifies a device's network interface card.
- HTML colour code
- A six-digit hex value
#RRGGBBgiving the red, green and blue parts of a colour. - Nibble
- A group of 4 bits — exactly one hexadecimal digit.
Homework 1 min
Task (≤ 15 min): (a) Convert 200 to binary. (b) Convert that binary number to hex. (c) Convert hex 7D4 to denary.
Model answer
- (a) 200 = 128 + 64 + 8 =
11001000 - (b)
1100 1000→C8 - (c) (7 × 256) + (13 × 16) + (4 × 1) = 1792 + 208 + 4 = 2004