Why Hexadecimal?
Binary is the language computers speak, but binary numbers get very long very quickly. The number 255 in binary is 11111111 — eight digits just for a relatively small number. Imagine trying to read, type, or debug a 32-bit memory address written entirely in 0s and 1s. You would almost certainly make a mistake.
This is where hexadecimal (hex for short) comes in. Hexadecimal is a base-16 number system. It uses 16 digits:
- The familiar digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
- Plus the letters A, B, C, D, E, F to represent the values 10 through 15
| Letter | A | B | C | D | E | F |
|---|---|---|---|---|---|---|
| Value | 10 | 11 | 12 | 13 | 14 | 15 |
The magic of hex is that one hex digit represents exactly 4 binary bits (a nibble). This means you can convert between hex and binary very quickly, without doing any arithmetic. Two hex digits represent a full byte (8 bits), and the longest numbers become short and manageable.
Where is hex used in real life?
- Colour codes in web design (e.g.
#FF5733) - Memory addresses (e.g.
0x7FFF5A2C) - MAC addresses for network devices (e.g.
AA:BB:CC:DD:EE:FF) - Error codes (e.g. the famous Windows “blue screen” stop codes like
0x0000007E) - Assembly language and low-level programming
The Hex-Binary-Denary Connection
The table below is the foundation of all hex work. It shows every possible value for a single hex digit alongside its binary and denary equivalents. You do not need to memorise the entire table for the exam, but you should be very comfortable looking up or working out any row.
| Denary | Binary (4-bit) | 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 |
Converting Hex to Binary
This is the easiest conversion of all. Simply replace each hex digit with its 4-bit binary equivalent. That is it — no arithmetic required.
Example 1: Convert hex A7 to binary.
A 7
| |
1010 0111
A7 in binary = 10100111
A = 1010, 7 = 0111. Join them together: 10100111.
Example 2: Convert hex 2F to binary.
2 F
| |
0010 1111
2F in binary = 00101111
2 = 0010, F = 1111. Join them together: 00101111.
Converting Binary to Hex
This is the reverse of the method above. Split the binary number into groups of 4 bits (nibbles), starting from the right, and convert each nibble to its hex digit.
Example 1: Convert binary 10110011 to hex.
1011 0011
| |
B 3
10110011 in hex = B3
Split: 1011 = B, 0011 = 3. Answer: B3.
Example 2: Convert binary 11101010 to hex.
1110 1010
| |
E A
11101010 in hex = EA
Split: 1110 = E, 1010 = A. Answer: EA.
Converting Hex to Denary
Each hex digit has a place value, just like in denary and binary. For a two-digit hex number, the left digit is in the 16s column and the right digit is in the 1s column. Multiply each digit by its place value and add the results.
Example 1: Convert hex 2F to denary.
Place values: 16 1
Hex digits: 2 F (F = 15)
Calculation: (2 × 16) + (15 × 1)
= 32 + 15
= 47
2F in denary = 47
Example 2: Convert hex B8 to denary.
Place values: 16 1
Hex digits: B 8 (B = 11)
Calculation: (11 × 16) + (8 × 1)
= 176 + 8
= 184
B8 in denary = 184
Converting Denary to Hex
To convert denary to hex, divide by 16. The quotient (whole number part) becomes the first hex digit, and the remainder becomes the second hex digit.
Example: Convert denary 94 to hex.
94 ÷ 16 = 5 remainder 14
Quotient: 5 → hex digit 5
Remainder: 14 → hex digit E
94 in hex = 5E
Check: 5 × 16 + 14 = 80 + 14 = 94. Correct!
- Convert hex C4 to binary. (C = 1100, 4 = 0100, so C4 = 11000100)
- Convert binary 11110001 to hex. (1111 = F, 0001 = 1, so 11110001 = F1)
- Convert hex 5E to denary. (5 × 16 + 14 = 80 + 14 = 94)
- Convert denary 200 to hex. (200 ÷ 16 = 12 remainder 8, so 200 = C8)
- Convert hex 3A to binary, then to denary. (3A = 00111010 = 58)
Hex in the Real World
Hex Colour Codes in Web Design
One of the most visible uses of hexadecimal is in web design. In HTML and CSS, colours are defined using a # symbol followed by six hex digits in the format #RRGGBB:
- The first two digits (RR) set the amount of Red
- The middle two digits (GG) set the amount of Green
- The last two digits (BB) set the amount of Blue
Each pair ranges from 00 (none of that colour, which is 0 in denary) to FF (maximum of that colour, which is 255 in denary). By mixing different amounts of red, green, and blue, you can create over 16.7 million different colours (256 × 256 × 256 = 16,777,216).
| Hex Code | Red | Green | Blue | Colour |
|---|---|---|---|---|
#FF0000 | FF (255) | 00 (0) | 00 (0) | Pure Red |
#00FF00 | 00 (0) | FF (255) | 00 (0) | Pure Green |
#0000FF | 00 (0) | 00 (0) | FF (255) | Pure Blue |
#FFFFFF | FF (255) | FF (255) | FF (255) | White |
#000000 | 00 (0) | 00 (0) | 00 (0) | Black |
#FF5733 | FF (255) | 57 (87) | 33 (51) | Warm Orange |
Notice how hex makes colour codes compact and easy to read. Writing the same information in binary would mean 24 binary digits for every single colour — far too long to work with practically.
Hex Memory Addresses
Every byte stored in a computer’s RAM has a unique memory address. These addresses are written in hexadecimal because hex is far more compact and readable than binary.
Consider this comparison:
Hex: 0x7FFF5A2C (8 digits)
Binary: 01111111111111110101101000101100 (32 digits!)
Denary: 2147465772 (10 digits)
The hex version is short, easy to read, and trivially converts to binary when needed. This is why programmers, debuggers, and operating systems all display memory addresses in hex. When you see addresses like 0x0040A000 or 0xDEADBEEF, the 0x prefix tells you the number is hexadecimal.
MAC Addresses
Every network device (your laptop’s Wi-Fi card, your phone’s Bluetooth chip, your router) has a unique identifier called a MAC address (Media Access Control). MAC addresses are written as six pairs of hex digits separated by colons or hyphens:
AA:BB:CC:DD:EE:FF
Each pair = 1 byte (8 bits)
6 pairs = 6 bytes = 48 bits total
In binary, the same address would be:
10101010:10111011:11001100:11011101:11101110:11111111
The hex format is clearly much easier for network engineers to read, copy, and troubleshoot. The first three pairs typically identify the manufacturer (e.g. Apple, Samsung, Intel), and the last three pairs are unique to the individual device.
0x0000007E). Many software licence keys use hex digits. Even some playful programmers use hex to write words — 0xDEADBEEF, 0xCAFEBABE, and 0xBAADF00D are all famous hex values used as debugging markers in real software! Java class files, for example, always begin with the “magic number” 0xCAFEBABE.
Interactive Exercises
Exercise 1: Hex to Binary Converter
Convert the following hexadecimal value to its 8-bit binary equivalent.
Exercise 2: Hex to Denary Converter
Convert the following hexadecimal value to its denary (decimal) equivalent.
Exercise 3: Hex Colour Mixer
Enter hex values (00 to FF) for each colour channel and watch the colour update in real time. Experiment to discover how red, green, and blue combine!
- Can you make pure yellow? (Hint: yellow = red + green, no blue)
- Can you make a nice sky blue?
- What happens when all three channels have the same value?
- Try making your school’s uniform colour!
Test Yourself
Click on each question to reveal the answer. Try to work it out yourself first!
Answer: 3 = 0011, D = 1101. Join them: 00111101.
Answer: Split into nibbles: 0101 = 5, 1110 = E. Answer: 5E.
Answer: 9 × 16 + 12 × 1 = 144 + 12 = 156.
Answer: 171 ÷ 16 = 10 remainder 11. 10 = A, 11 = B. Answer: AB. Check: 10 × 16 + 11 = 160 + 11 = 171. Correct!
Answer:
Red: 2E = 2 × 16 + 14 = 32 + 14 = 46
Green: 86 = 8 × 16 + 6 = 128 + 6 = 134
Blue: C1 = 12 × 16 + 1 = 192 + 1 = 193
This is a medium blue colour with low red, moderate green, and high blue.
Answer: Hexadecimal is used because it is much more compact and readable than binary. A 32-bit binary memory address would be 32 digits long, but the same address in hex is only 8 digits. Hex also converts easily to and from binary (each hex digit = 4 bits), so programmers can quickly switch between the two systems when needed. This reduces the chance of errors when reading or typing addresses.
Answer:
To binary: F = 1111, F = 1111. FF = 11111111.
To denary: 15 × 16 + 15 = 240 + 15 = 255.
Significance: 255 is the largest value that can be stored in a single byte (8 bits). This is why colour channels in hex colour codes range from 00 to FF — each channel is exactly one byte. It is also the maximum value for many settings in computing, such as subnet masks in networking (255.255.255.0).
Key Vocabulary
Make sure you know all of these terms for your exam:
| Term | Definition |
|---|---|
| Hexadecimal | A base-16 number system using digits 0–9 and letters A–F. Used as a compact, human-friendly shorthand for binary. |
| Nibble | A group of 4 bits (half a byte). One nibble can represent exactly one hexadecimal digit, with values from 0 to F (0–15 in denary). |
| Hex Colour Code | A six-digit hexadecimal value preceded by # (e.g. #FF5733) used in web design to define colours. The six digits represent Red, Green, and Blue components in pairs. |
| Memory Address | A unique identifier for a specific location in a computer’s RAM. Typically written in hexadecimal with a 0x prefix for readability. |
| MAC Address | Media Access Control address — a unique 48-bit identifier assigned to every network interface, written as six pairs of hex digits (e.g. AA:BB:CC:DD:EE:FF). |
| RGB | Red, Green, Blue — the colour model used in screens and digital displays. Each component is stored as a value from 0 to 255 (00 to FF in hex). |
Exam Tips
- Forgetting that A–F represent 10–15. If a question asks you to convert hex B to denary, the answer is 11, not “B.”
- Not padding to 4 bits. When converting hex 3 to binary, write 0011, not just 11. You need all four bits for each nibble.
- Mixing up the direction. Read the question carefully — “hex to binary” and “binary to hex” require opposite steps.
- Forgetting to show working. Always write out the nibble breakdown or place value calculation. Method marks are available even if the final answer is wrong.
Past Paper Questions
Try these exam-style questions, then click to reveal the mark scheme answer.
Convert the denary number 200 to hexadecimal. Show your working. [2] marks
Mark scheme:
- 200 ÷ 16 = 12 remainder 8 (1)
- Answer: C8 (1)
Convert the hexadecimal number 3F to denary. [2] marks
Mark scheme:
- 3 × 16 = 48, F (15) × 1 = 15 (1)
- Answer: 63 (1)
Give two reasons why hexadecimal is used in computing instead of binary. [2] marks
Mark scheme:
- Hexadecimal is shorter / easier for humans to read and write than long binary strings (1)
- Each hex digit represents exactly 4 binary digits, making conversion between hex and binary straightforward (1)
Why Hex Matters
Hexadecimal is one of those topics that might seem abstract at first, but once you start noticing it, you see it everywhere:
- Every website you visit uses hex colour codes in its CSS. Inspect any web page and you will find values like
#333333or#4361eethroughout the stylesheet. - Every device on your network has a MAC address written in hex. Check your phone’s settings — you will find it under “About” or “Network.”
- Every programmer encounters hex when debugging, reading error messages, or working with low-level code.
- Every pixel on your screen has its colour defined by three hex pairs — right now, as you read this text.
The key takeaway is that hex is not a separate number system that computers use — computers always use binary. Hexadecimal is a tool for humans, a shorthand that makes binary manageable. Learning to convert fluently between hex, binary, and denary is an essential skill that will come up in your exam and serve you well if you continue into programming, networking, or cyber security.
Video Resources
Further Reading
- 101 Computing — Hex-Binary Conversions — Interactive tools for practising hex and binary conversions
- BBC Bitesize — Hexadecimal — Clear explanations with practice questions from the BBC
- BBC Bitesize — Edexcel GCSE Computer Science — Full specification coverage for data representation
- GCSE Topic 2: Data Representation — Interactive revision tools and binary activities