GCSE · Computer Science · OCR · Spec J277

Binary to hexadecimal conversion

Hex looks like a secret code: A7, 3C, D6. The secret is that each character is just four binary digits in disguise.

Computer Science · Data representation

Flip four bits, watch the hex digit

8 + 2 = 10

4-bit binary 1010 = 10 in denary, 0xA in hex

Decimal value10Hex0xA
Challenge: find the pattern that gives F, then the one that gives 9.

Tap the bits to make any pattern from 0000 to 1111. The decimal value and the hex digit follow along. The 0x in front of the hex digit is just a flag saying 'this is hexadecimal'.

Before you go on

How do you write ten in hex?

Your friend is counting up in hexadecimal. They reach 9 and are not sure what comes next.

Which is closest to what you think right now?
How sure are you?

Your turn to finish it

Binary to hex, one nibble at a time

Convert the binary number 11010110 to hexadecimal.

  1. Start with 11010110. It is 8 bits long, so it makes two nibbles.
  2. missing step
Which line is step 2?

Computer Science · Number representation

Now go the other way: hex to binary

To turn hex into binary, take each hex digit on its own, find its decimal value, then write that value as 4 bits using the place values 8, 4, 2 and 1. Pick Hex A7 and compare each nibble with its digit.

128
64
32
16
8
4
2
1
Decimal
167
Binary
1010 0111
Hexadecimal
0xA7

Check the working

Where does this hex to binary go wrong?

A pupil converts the hexadecimal number 3C to binary. One line of the working has a mistake. Which line?

A pupil's working — which line goes wrong?

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

Chop binary into groups of four bits and each group becomes exactly 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.
  • Up to 9, hex looks like everyday numbers. At 10 another character is needed: 10 is A, 11 is B, and so on.
  • Four binary digits correspond to one hexadecimal digit.
  • A group of 4 binary digits is called a nibble.
  • Have a goSam says both 1101 and 11010 are nibbles, and is very confident about it. One of those is not. Which one?

    11010

    A nibble is a group of exactly 4 binary digits. 11010 has five, so it cannot be a nibble.

  • Binary to hex: split the number into 4-bit nibbles, working from the right (the least significant bit).
  • Find each nibble's decimal value by adding the place values 8, 4, 2 and 1 that sit under a one.
  • Have a goFind the decimal value of the nibble 1001. Which place values count?

    8 + 1 = 9

    Only the place values over a one count. The 4 and the 2 sit over zeros, so they are left out.

  • Turn each nibble's value into its hex digit, then join the digits in order.
  • Hex to binary: take each hex digit on its own and find its decimal value.
  • Write each value as a 4-bit binary number using the place values, then join the nibbles.
  • Have a goWrite the hex digit 5 as a 4-bit binary number. Which place values do you switch on?

    0101 (the 4 and the 1)

    4 + 1 = 5, so the 4 and the 1 are on. The leading 0 keeps it at 4 bits.

The big picture

Hexadecimal is a base-16 number system that uses the digits 0 to 9 and the letters A to F. Four binary digits match one hex digit, so you convert by splitting binary into nibbles from the right, turning each nibble into a hex digit and joining them. To go back, turn each hex digit into four bits.

Key points

1Hexadecimal is base 16: the digits 0 to 9, then A to F for the values 10 to 15.
2One nibble (4 bits) matches exactly one hex digit.
3Binary to hex: split into nibbles from the right, add the place values under the ones, swap each value for its hex digit and join them.
4Hex to binary: find each digit's decimal value, write it as a 4-bit nibble, then join the nibbles.

Worked example

Problem

Convert the hexadecimal number B2 to binary.

⚠ Watch out

Writing the values ten, eleven and so on as two-character numbers in hex. Every hex digit is a single character, so ten is A, eleven is B and fifteen is F.

🧠

Memory hook

One hex digit, one nibble: four bits in, one character out.

✓

Check yourself

Without looking back, say why four bits make exactly one hex digit. Then convert 10010011 to hexadecimal, nibble by nibble.

Flashcards

(10)
What is hexadecimal?
A base-16 number system that uses the digits 0 to 9 and the letters A, B, C, D, E and F.
Which hex character stands for the value ten?
A. The values 0 to 9 look as usual, but at 10 another character is needed, so 10 is A, 11 is B and so on.
What are the hex digits for the values 11 and 15?
11 is B and 15 is F.
How many binary digits correspond to one hexadecimal digit?
Four.
What is a group of 4 binary digits called?
A nibble.
Why split a binary number into nibbles before converting to hex?
Each nibble matches one hex digit, so each can be converted separately and the results recombined.
Binary to hex: where do you start splitting into nibbles?
From the right, at the least significant bit.
How do you find the decimal value of a nibble?
Add up the place values (8, 4, 2, 1) that sit under a one. Ignore the places under a zero.
You have the decimal value of a nibble. What next?
Swap it for its hex digit, then join the digits in order.
Hex to binary: how many bits does each hex digit become?
Always 4, even for a small digit. The hex digit 1 has value 1, so it is written 0001, keeping its leading zeros.

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.