Hexadecimal
What hexadecimal is
Hexadecimal (hex) is a base-16 number system. Everyday numbers use base 10 (digits 0–9); binary uses base 2 (0 and 1); hex uses sixteen symbols: 0 1 2 3 4 5 6 7 8 9 A B C D E F.
The letters stand for the denary values that are too big for a single digit:
| Denary | Binary | Hex | Denary | Binary | Hex | |
|---|---|---|---|---|---|---|
| 0 | 0000 | 0 | 8 | 1000 | 8 | |
| 1 | 0001 | 1 | 9 | 1001 | 9 | |
| 2 | 0010 | 2 | 10 | 1010 | A | |
| 3 | 0011 | 3 | 11 | 1011 | B | |
| 4 | 0100 | 4 | 12 | 1100 | C | |
| 5 | 0101 | 5 | 13 | 1101 | D | |
| 6 | 0110 | 6 | 14 | 1110 | E | |
| 7 | 0111 | 7 | 15 | 1111 | F |
Why hex is used
Computers work in binary, but long binary strings are hard for people to read and easy to mis-copy. Hex is a compact, human-friendly shorthand:
- One hex digit = exactly 4 bits (one nibble).
- Two hex digits = 1 byte (8 bits).
So the byte 11111010 becomes just FA — far quicker to read, write and spot errors in. You'll see hex in:
- Colour codes —
#FF0000is red (FF = 255 red, 00 green, 00 blue). - Memory addresses — e.g.
0x7FFF. - MAC addresses — e.g.
00:1B:44:11:3A:B7. - Error/debugging codes and machine code.
Converting between the bases
Binary → Hex
Split the binary into nibbles of 4 bits (from the right), then convert each nibble:
1111 1010
F A → FA
If the left-hand group has fewer than 4 bits, pad with leading zeros: 101110 → 0010 1110 → 2E.
Hex → Binary
Convert each hex digit into its 4-bit group:
2 D → 0010 1101
Hex → Denary
Multiply the first digit by 16 and add the second:
2D = (2 × 16) + 13 = 32 + 13 = 45
Denary → Hex
Divide by 16. The whole-number answer is the first digit; the remainder is the second:
45 ÷ 16 = 2 remainder 13 → 2D
Worked example
Convert the byte 11001111 to hex.
1. Split into nibbles: 1100 1111
2. Convert: 1100 = 12 = C, 1111 = 15 = F
3. Answer: CF
Common mistakes
- Forgetting to pad the left nibble with zeros (e.g. writing
101as5from1 01instead of0101). - Mixing up that A = 10, not 1, and F = 15, not 16.
- Splitting nibbles from the left instead of the right on odd-length binary.
Exam tips
- Memorise the four "letter" values: A=10, B=11, C=12, D=13, E=14, F=15.
- Most hex questions are just two separate nibble conversions joined together — do them one nibble at a time.
- Show the nibble split in your working; you often get a mark for method even if the final digit is wrong.
Key facts to remember
- Hex is base 16; digits
0–9thenA–F. - 1 hex digit = 4 bits (a nibble); 2 hex digits = 1 byte.
- Used for colour codes, memory/MAC addresses and machine code because it is shorter and less error-prone than binary.