GCSE · Computer Science · OCR · Spec J277

Denary to hexadecimal conversion

How many 16s fit into 180? Have a go. Then work out what to do with the answer, because that count is about to turn into a letter.

Computer Science · Algorithms

Trace table — dry run the code

We're converting 180 from denary to hex. Press Start, then before each Next, guess what's coming.

1number = 180
2256 goes in? If not, skip that column
3How many 16s go in? (divide by 16)
4What's left over? (the remainder)
5Count of 16s becomes one hex digit
6Remainder becomes the final hex digit
7Join them: 16s digit first
256 fits?
16s fit
left over
16s digit
1s digit
Output
Press Start to run the first line.
·

Ready when you are — step through one line at a time.

Predict the next two columns

Hex place values, reading right to left, start 1, 16, and carry on.

The first two hex place values are 1 and 16. What are the next two?

Computer Science · Hex conversion

Is hex just binary with more columns?

You're converting a denary number to hex. You've sorted out which columns you need. Now you're deciding what to put in the 16 column.

Which plan is closest to what you'd do?
How sure are you?

Computer Science · Your turn

Your turn: convert 233

Convert the denary number 233 to hexadecimal.

  1. Does 256 go into 233? No, so the 256 column and any columns to its left aren't needed. That leaves the 16s column and the final column.
  2. missing step
Which line is step 2?

Computer Science · Number representation

Check your conversions

Pick a number, but work out its hex on paper first. Then press it and compare. Ignore the row of 0 and 1 chips (that is the binary form, which this lesson doesn't need), and read the denary and hexadecimal boxes. The 0x in front of the hex answer is a common way of flagging that a number is hexadecimal; the digits after it are the answer. The small letters A to E on the number buttons are just button labels, not hex digits.

128
64
32
16
8
4
2
1
Decimal
100
Hexadecimal
0x64

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

Count how many 16s fit, then turn that count into one hex digit.

What you need to know

  • Hexadecimal is a base-16 number system. It uses the digits 0 to 9 and the letters A, B, C, D, E and F.
  • The values 0 to 9 are straightforward. At 10 you need another character, so 10 is A, 11 is B, and so on.
  • Have a goJo swears the hex digit after 9 is "10". What is it really, and what comes after that?

    A, then B.

    A hex digit is a single character. 10 and 11 are too big to be one digit from 0 to 9, so letters step in: A for 10, B for 11.

  • Hex place values go up by 16 every time, because it's base 16: 1, 16, 256 and 4,096.
  • Denary to hex follows similar rules to denary to binary, but you have 16 digits to juggle, not two.
  • Find the first place value that goes into your number. If 256 won't go in, drop the 256 column and any to its left.
  • Have a goYou're converting 40 to hex. Which of the place values 1, 16, 256 and 4,096 can you ignore?

    256 and 4,096.

    Neither goes into 40. Once 256 won't fit, every column to its left is too big as well, so you only use the 16s and the final column.

  • Don't just put a 1 in the 16 column like binary. Work out how many 16s go in by dividing.
  • Have a goPriya says 50 starts with a 1 in the 16 column, "like binary". How many 16s actually go into 50, and what's left?

    Three 16s (48), with 2 left over.

    A hex column holds a count, not just a 1. 3 × 16 = 48, and a fourth 16 would make 64, which is too big for 50.

  • That count is the digit for the 16 column. Turn it into a letter if it's 10 or more.
  • The remainder is the digit for the final column. So 180 is eleven 16s with 4 left: B4.

The big picture

Hexadecimal is a base-16 number system with the digits 0 to 9 and the letters A to F. To convert a denary number, find the first place value that fits (the columns are 1, 16, 256 and 4,096), divide by 16 to find how many 16s go in, write that count as one hex digit (a letter if it's 10 or more), then write the remainder as the final digit. For example, 180 is eleven 16s with 4 left over, so it is B4.

Key points

1Hexadecimal is base 16: the digits 0 to 9, then A, B, C, D, E and F for the values from 10 up.
2The place values go up by 16 each time: 1, 16, 256 and 4,096.
3To convert from denary, find the first place value that goes into the number and ignore the columns to its left.
4Divide by 16: the number of 16s is the 16-column digit, written as a letter if it is 10 or more.
5The remainder is the final digit. Write the 16s digit first, then the remainder's digit.

Worked example

Problem

Convert the denary number 75 to hexadecimal.

⚠ Watch out

Treating hex like binary and dropping a 1 into the 16 column. Each hex column holds a count from 0 to 15, found by dividing by 16, and a count of 10 or more is written as a letter, not as two digits.

🧠

Memory hook

How many 16s fit? That's your first digit. What's left is your last digit. Eleven sixteens and four left over: B4.

✓

Check yourself

Convert 90 to hex on paper: does 256 fit, how many 16s go in, what's left, and which hex digits do those become? Then press 90 in the converter to check.

Flashcards

(13)
What is hexadecimal?
A base-16 number system. It uses the digits 0 to 9 and the letters A, B, C, D, E and F.
What do the hex letters A and B stand for?
A is 10 and B is 11. The letters carry on in order: C, D, E and F are the next values up to 15.
Why does hexadecimal need letters at all?
Hex has 16 digits, but 0 to 9 only gives ten. Each digit is a single character, so letters cover the values 10 and above.
What are the first four hex place values, right to left?
1, 16, 256 and 4,096.
Why do hex place values go up by 16 each time?
Because hexadecimal is a base-16 number system, so each column is worth 16 times the one to its right.
How is denary to hex like denary to binary, and how is it harder?
The rules are similar, but the maths is a bit more challenging because you're working with 16 digits, not just two.
Which place-value columns do you need for a hex answer?
Find the first place value that goes into the number. If 256 won't go in, the 256 column and any columns to its left aren't needed.
In the 16 column, why isn't it enough to just put a 1?
A hex column holds a count, not just 0 or 1. You work out how many times 16 goes into the number by dividing.
What gives you the digit for the 16 column?
How many times 16 goes into the number. If that count is 10 or more, write it as a letter.
What gives you the final digit of the hex answer?
The remainder after dividing by 16. It is already a hex digit if it is 0 to 9, and a letter if it is 10 or more.
In a two-digit hex answer, which digit goes first?
The 16s digit goes first, on the left, because the 16 column has the bigger place value. The remainder's digit goes last.
The count of 16s comes out as 12. What goes in the 16 column?
C. A count of 10 or more must be a letter: 10 is A, 11 is B, 12 is C.
How do you turn 180 into hex in one line?
16 goes into 180 eleven times with 4 left. 11 is B and 4 stays 4, so it's B4.

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 OCR GCSE Computer Science topics

See the full OCR Computer Science curriculum →

How this lesson was checked. This OCR GCSE Computer Science (specification J277)lesson 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 14 November 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.