KS3 · Computer Science

Hexadecimal numbers

Which would you rather copy out without a slip: 11111111 10000000 00000000, or FF8000? They're the same three bytes. The short one is hexadecimal, and by the end of this lesson you'll be able to turn one into the other by hand.

Computer Science · Data representation

Four bits, sixteen patterns

8 + 1 = 9

8-bit binary 00001001 = 9 in denary, 0x09 in hex

Denary9Hex0x09
Fill the right-hand four. Then flip the 16.

Start with only the four bits on the right. Switch them on until all four are 1: 1111 is 8 + 4 + 2 + 1 = 15. Every pattern from 0000 to 1111 is a different number, 0 to 15, so four bits give sixteen patterns in all. Now switch on the 16 bit and watch the Hex readout. (The 0x in front of the Hex readout is just a label that says 'this is hex'; the digits after it are the number.)

Watch out: Denary only has ten digits, 0 to 9, so it needs two digits to write 10 to 15. Hex gives each of those values a single digit of its own: A is 10, B is 11, C is 12, D is 13, E is 14 and F is 15.

Where does it sit?

Place the hex numbers

Denary has columns worth 10 and 1. Two-digit hex has columns worth 16 and 1: the right digit counts ones and the left digit counts sixteens. So 2A means 2 sixteens and A (10) ones. Drag each hex number to where it sits among the denary numbers 0 to 256. Each tick is 16, so every tick is one step of the left-hand digit.

Your turn to do the method

Hex to denary, and back again

Convert hex 3C into denary. Then go the other way: convert denary 200 into hex.

  1. 3C: the left digit is 3, so that's 3 sixteens. 3 × 16 = 48.Hex to denary: left digit × 16, then add the right digit.
  2. missing step
Which line is step 2?

Computer Science · Number representation

Binary to hex: split into fours

Binary to hex: split the byte into groups of four bits, starting from the right, and swap each group for its hex digit. Hex to binary: do the reverse and write each hex digit as its four bits. Try the first button: 1011 is 11, which is B, and 0110 is 6, so 1011 0110 is B6. The other buttons are the three bytes of the web colour #FF8000, a bright orange. (This tool labels denary as Decimal; they are two names for ordinary base-10 numbers.)

128
64
32
16
8
4
2
1
Binary
1011 0110
Hexadecimal
0xB6
Decimal
182
128+32+16+4+2=182
Watch out: Group from the right. If a binary number has fewer than eight bits, the left-hand group comes up short: 101101 splits as 10 and 1101. Fill the short group with zeros on the left, 0010 and 1101, which gives 2D.

What's really inside?

Hex on screen, but what's in the computer?

An image editor shows the colour you picked as #FF8000.

So what is the computer actually holding for that colour? Pick the idea closest to what you think.
How sure are you?

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

Binary's shorthand: one digit for every four bits.

What you need to know

  • Hex has sixteen digits: 0 to 9, then A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.
  • In two-digit hex the left digit counts sixteens and the right digit counts ones.
  • One hex digit = four bits (a nibble); two hex digits = one byte, 00 to FF.
  • Computers store binary, never hex. Hex is a shorthand for people.

The big picture

Hexadecimal (hex) is a base-16 number system with sixteen digits, 0 to 9 and then A to F for 10 to 15. Four bits have exactly sixteen patterns, so one hex digit stands for four bits (a nibble) and two digits stand for a byte, 00 to FF. In two-digit hex the left digit counts sixteens and the right digit counts ones. Computers still store everything in binary: hex is a shorter way for people to read and write it, used for things like web colour codes.

Key points

1Hexadecimal is base 16: it uses the digits 0 to 9 and then the letters A to F, which stand for 10 to 15.
2Four bits have 16 possible values, 0000 to 1111 (0 to 15), so each group of four bits (a nibble) matches exactly one hex digit.
3A byte is eight bits, so it takes two hex digits, from 00 up to FF.
4Place values in two-digit hex are 16 and 1, so FF = 15 × 16 + 15 = 255, the largest two-digit hex number.
5Hex to denary: multiply the left digit by 16 and add the right digit. Denary to hex: divide by 16; the whole-number result is the left digit and the remainder is the right digit.
6Binary to hex: split into groups of four bits from the right and swap each group for its hex digit. Hex to binary: write each digit as four bits.
7Computers store and process binary, not hex. People use hex because it is shorter, easier to read, remember and type, and less error-prone, and it converts to binary simply. Web colour codes are a common example.

Worked example

Problem

Convert the binary byte 1110 0101 into hex, then into denary.

⚠ Watch out

Putting a two-digit denary number into one hex place. 200 ÷ 16 = 12 remainder 8, and the 12 must become the single digit C, so 200 is C8 in hex. Writing '128' mixes denary into a hex number and gives the wrong value.

🧠

Memory hook

One hex digit, one nibble, four bits. Two hex digits, one byte. Hex is binary with a shorter name tag: the computer never sees it.

✓

Check yourself

Without looking back: what is hex 4E in denary, and what is 1101 0010 in hex? (Answers: 4 × 16 + 14 = 78, and D2.)

Flashcards

(14)
What is hexadecimal?
A base-16 number system. It uses sixteen digits: 0 to 9, then A to F.
What are the hex digits A, B, C, D, E and F worth in denary?
A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.
In a two-digit hex number, what does each digit count?
The left digit counts sixteens and the right digit counts ones.
What is the largest two-digit hex number, and its denary value?
FF, which is 15 × 16 + 15 = 255.
What is a nibble, and how many values can it hold?
A group of four bits. It has 16 possible values, 0000 to 1111 (0 to 15).
Why does one hex digit stand for exactly four bits?
Four bits make exactly 16 patterns, and hex has exactly 16 digits, so each pattern gets one digit.
How many hex digits does one byte need?
Two. A byte is eight bits, two nibbles, so it runs from 00 to FF.
How do you convert two-digit hex to denary?
Multiply the left digit's value by 16, then add the right digit's value.
How do you convert denary (0 to 255) to hex?
Divide by 16. The whole-number result gives the left digit and the remainder gives the right digit.
What's the method for binary to hex?
Chop it into nibbles, starting at the right-hand end. Each nibble becomes one hex digit.
How do you convert hex to binary?
Replace each hex digit with its four-bit binary value.
Do computers store data in hex?
No. All data is held as binary. Hex is only a way for people to write it.
Why do people use hex instead of binary?
It's much shorter, easier to read, remember and type, less likely to cause mistakes, and simple to convert to and from binary.
Where might you see hex being used?
Colour codes in web design and image editing, where each colour is written as hex digits.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More KS3 Computer Science topics

See the full KS3 Computer Science curriculum →

How this lesson was checked. This KS3 Computer Sciencelesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 1 October 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.