Cambridge IGCSE Computer Science (0478) · lesson 2 of 35 · 30 min
Why Hexadecimal?
Binary numbers become very long very quickly. A single byte is 8 bits; a memory address might be 32 or 64 bits. Hexadecimal (hex, base-16) is a compact shorthand: one hex digit represents exactly 4 binary bits (a nibble), so an 8-bit byte is always exactly 2 hex digits.
Hex uses digits 0–9 and letters A–F to represent values 0–15:
- Denary
- Binary
- Hex
- 0
- 0000
- 0
- 1
- 0001
- 1
- 2
- 0010
- 2
- 3
- 0011
- 3
- 4
- 0100
- 4
- 5
- 0101
- 5
- 6
- 0110
- 6
- 7
- 0111
- 7
- 8
- 1000
- 8
- 9
- 1001
- 9
- 10
- 1010
- A
- 11
- 1011
- B
- 12
- 1100
- C
- 13
- 1101
- D
- 14
- 1110
- E
- 15
- 1111
- F
Conversion Methods
Binary → Hex: Split the binary number into groups of 4 bits from the right. Convert each group to its hex digit.
Hex → Binary: Replace each hex digit with its 4-bit binary equivalent.
Hex → Denary: Multiply each digit by its power of 16 and sum.
Denary → Hex: Divide repeatedly by 16, recording remainders.
Worked Examples
Convert binary 11010110 to hex
Split into nibbles: 1101 | 0110
1101 = D, 0110 = 6
11010110 = D6
Convert hex 3F to denary
3 × 16¹ + F(15) × 16⁰
48 + 15 = 63
Convert denary 200 to hex
200 ÷ 16 = 12 remainder 8 → digit: 8
12 ÷ 16 = 0 remainder 12 → digit: C
Read remainders bottom to top:
200 = C8
Where Is Hex Used?
Memory addresses: 0x00FF3A20 is easier to read than 32 binary digits. Colour codes in HTML/CSS: #FF5733 means R=255, G=87, B=51. MAC addresses: 00:1A:2B:3C:4D:5E. Error codes and debugging output in operating systems. IPv6 addresses use hex groups separated by colons.
What is the hex equivalent of binary 10101010?
- AA
- AB
- BA
- BB
Answer: AA
1010=A, 1010=A → AA.
What is hex 1F in denary?
- 15
- 25
- 31
- 16
Answer: 31
1×16 + 15 = 31.
How many bits does one hex digit represent?
- 2
- 3
- 4
- 8
Answer: 2
One hex digit = one nibble = 4 bits.
Previous lesson: Binary number system and place value
Back to Cambridge IGCSE Computer Science (0478)
Next lesson: Binary addition and overflow