Data representation · GCSE & A Level

Binary and Hex Quiz

Practise converting between binary, denary and hexadecimal, then move on to binary arithmetic, shifts, masks and negative numbers. Reach a score of 20 to earn a medal.

8
4
2
1

1
0
1
1
  1. 1 Pick a quiz above
  2. 2 Choose a difficulty
  3. 3 Type one digit per box and press Submit
Enter submits your answerTyping a digit moves to the next box

How to convert between binary, denary and hex

Every quiz above uses a few simple methods. Here they are with worked examples, using 8-bit numbers like the GCSE exam.

Binary to denary

Write the place values 128, 64, 32, 16, 8, 4, 2, 1 above the bits. Add up the place values wherever there is a 1.

1 0 1 1 0 1 0 1
128 + 32 + 16 + 4 + 1 = 181

Denary to binary

Work from the left. If the place value fits into what's left, write 1 and subtract it; otherwise write 0.

200 = 128 + 64 + 8
= 1 1 0 0 1 0 0 0

Binary and hex

Hexadecimal is base 16, using 0 to 9 then A to F for 10 to 15. Each hex digit matches exactly 4 bits (a nibble), so split the byte in half and convert each part.

1011 0101
1011 = 11 = B, 0101 = 5 → B5

Denary and hex

Divide by 16. The answer is the first hex digit and the remainder is the second.

181 ÷ 16 = 11 remainder 5
11 = B → B5

Binary addition

Add column by column from the right: 0 + 0 = 0, 1 + 0 = 1, 1 + 1 = 0 carry 1, and 1 + 1 + 1 = 1 carry 1. If the answer needs more than 8 bits, it causes an overflow error.

Binary shifts

A left shift moves every bit left and multiplies the number by 2 for each place. A right shift divides by 2 for each place, losing any bits that fall off the end.

Frequently asked questions

Why do computers use binary?

Computers are built from switches that are either on or off, which maps directly onto the two digits 1 and 0.

Why do programmers use hexadecimal?

Hex is much shorter than binary and easy to convert, because each hex digit is exactly 4 bits. It's used for colour codes, memory addresses and error codes.

What is the largest number you can store in 8 bits?

255, which is 11111111 in binary and FF in hex. That gives 256 different values including 0.

How do I win a medal?

Each right answer adds a point and each wrong one takes one away. Reach a score of 20 to earn a medal for that quiz and difficulty.

More from Learn Computing

Using this with a class?

Run a whole lesson with them, free

Learn Computing has complete interactive courses for OCR A Level Computer Science, Creative iMedia and the Cambridge Advanced National in IT. You see every student's work live, send feedback into the lesson, and track progress across the course. Students log in with cards you print, with no email addresses needed.

An OCR GCSE Computer Science (J277) course is on the way. Sign up below for one email a month and hear when it opens.

Revising?

Free revision, topic by topic

Revision pages for the course you are taking, free and with no account needed.

Exam guides: how to revise for GCSE Computer Science and what's in the Creative iMedia R093 exam.