Hexadecimal

💻 Computer Science Years 8–11 Foundation

Base-16 as a compact shorthand for binary, and converting between hex, binary and denary.

Open this lesson, with practice and a printable worksheet →

Binary is how the machine thinks, but for humans it is a nightmare to read: 11111010 is easy to miscopy. So programmers use a shorthand called hexadecimal (base 16) that packs four binary digits into a single symbol. That long byte becomes just FA — two characters instead of eight.

Why this matters: Hex is everywhere you look in computing: colour codes on web pages (#FF5733), memory addresses, MAC addresses and error codes. It is a compact, human-friendly bridge between us and binary, so being fluent in it saves time and prevents mistakes.
1 1 1 1 1 0 1 0 nibblenibble F A =
Split a byte into two nibbles; each nibble is one hex digit. 1111 1010 = FA.

Sixteen digits

Base 16 needs sixteen single symbols. We reuse 0–9 and then borrow the first six letters for ten to fifteen. Think of A–F simply as "the teens' single-character names".

Denary0123456789101112131415
Binary0000000100100011010001010110011110001001101010111100110111101111
Hex0123456789ABCDEF

Binary ↔ hex — the easy direction

1 0 1 10 1 1 1B7=
Split into nibbles: 1011 = B, 0111 = 7, so the byte is B7.

A group of four bits is a nibble, and one nibble is exactly one hex digit. So to convert binary to hex, split into nibbles from the right and translate each using the table. To go back, expand each hex digit into its four bits.

Worked example — convert 10110111 to hex.
Split into nibbles: 1011 and 0111. From the table 1011 = B and 0111 = 7. So the byte is B7.

Hex ↔ denary

16s1s2D2 × 16 = 32D = 1332 + 13 = 45
Left digit × 16, plus the right digit: 2D = 32 + 13 = 45.

A two-digit hex number has a 16s column and a 1s column. Multiply the left digit by 16, add the right digit. To go the other way, divide by 16: the quotient is the left digit and the remainder is the right.

Worked example — convert hex 2D to denary.
D = 13. So 2D = (2 × 16) + 13 = 32 + 13 = 45.
And back: convert denary 200 to hex. 200 ÷ 16 = 12 remainder 8. 12 = C, remainder 8. So 200 = C8. Check: (12 × 16) + 8 = 200. ✓
Common mistake: reading the letters as ordinary text. In hex, A means 10, not the sound "ay", and B7 is a number (183), not two things. Also never split a byte into nibbles from the left if it isn't a full 8 bits — always group in fours starting from the right.
200 ÷ 16 = 12 remainder 812 = C   remainder = 8C8so 200 = C8  ((12×16)+8 = 200)
Denary → hex by dividing by 16: 200 = C8.

Tip: the quickest route between denary and hex is often via binary. Turn the denary into 8-bit binary, split into two nibbles, and read off two hex digits — no division needed.

Get the printable worksheet →
← Binary Arithmetic & Shifts → Characters (ASCII & Unicode)
← Sasta Basta home All subjects