Skip to content

Practice problems

Binary and hex practice problems

Binary writes every number with just two digits, 0 and 1, because a wire can be only off or on. These ten problems read binary as decimal, write decimal as binary, find how far n bits can count, and finish with hexadecimal, the shorthand programmers use. Type your answer to check it, and open the working whenever you want it.

The method

Each bit is worth twice the one to its right. Add the place values that have a 1:

1010 = 8 + 0 + 2 + 0 = 10
  • Decimal to binary: take the biggest place value that fits, write a 1, subtract, and move down a place
  • n bits make 2n values, from 0 to 2n − 1
  • Hexadecimal: each digit is worth 16 times the one to its right, with A–F standing for 10–15

The problems

Type your answer and tap Check. Every one has the working, step by step.

  1. Problem 1 of 10

    What is binary 1110 in decimal?

    Show the working
    1. Write the place values 8, 4, 2 and 1 above the bits, then add the ones that have a 1 under them.
    2. 1110 = 8 + 4 + 2 + 0 = 14

    Answer: 14

  2. Problem 2 of 10

    What is binary 10110 in decimal?

    Show the working
    1. Five bits have place values 16, 8, 4, 2 and 1.
    2. 10110 = 16 + 0 + 4 + 2 + 0 = 22

    Answer: 22

  3. Problem 3 of 10

    What is the byte 11001010 in decimal?

    Show the working
    1. Eight bits have place values 128, 64, 32, 16, 8, 4, 2 and 1.
    2. The 1s sit under 128, 64, 8 and 2.
    3. 128 + 64 + 8 + 2 = 202

    Answer: 202

  4. Problem 4 of 10

    Write decimal 12 in binary. Type the binary digits, like 101.

    Show the working
    1. Take the biggest place value that fits and subtract: 8 fits, leaving 4. Then 4 fits, leaving 0.
    2. That's a 1 under 8 and 4 and a 0 under 2 and 1: 1100

    Answer: 1100

  5. Problem 5 of 10

    Write decimal 37 in binary. Type the binary digits.

    Show the working
    1. 32 fits, leaving 5. 16 and 8 don't fit. 4 fits, leaving 1. 2 doesn't fit. 1 fits, leaving 0.
    2. So the 1s go under 32, 4 and 1: 100101

    Answer: 100101

  6. Problem 6 of 10

    Write decimal 200 in binary, as a full byte. Type the binary digits.

    Show the working
    1. 128 fits, leaving 72. 64 fits, leaving 8. 32 and 16 don't fit. 8 fits, leaving 0.
    2. The 1s go under 128, 64 and 8, and the other places are 0: 11001000

    Answer: 11001000

  7. Problem 7 of 10

    What is the largest number 6 bits can hold?

    Show the working
    1. n bits make 2ⁿ values, and one of them is 0, so the largest is 2ⁿ − 1.
    2. 2⁶ − 1 = 64 − 1 = 63. As a check, 111111 = 32 + 16 + 8 + 4 + 2 + 1 = 63.

    Answer: 63

  8. Problem 8 of 10

    A counter must count from 0 up to 500. What is the fewest bits it needs?

    Show the working
    1. Find the smallest n where 2ⁿ − 1 reaches 500.
    2. 8 bits reach only 2⁸ − 1 = 255. 9 bits reach 2⁹ − 1 = 511, which is enough: 9 bits.

    Answer: 9

  9. Problem 9 of 10

    What is hexadecimal 3C in decimal?

    Show the working
    1. Each hex digit is worth 16 times the one to its right, and A–F stand for 10–15. So C is 12.
    2. 3C = 3 × 16 + 12 = 48 + 12 = 60

    Answer: 60

  10. Problem 10 of 10

    Stretch: what is hexadecimal 1A4 in decimal?

    Show the working
    1. Three hex digits have place values 256, 16 and 1. A is 10.
    2. 1A4 = 1 × 256 + 10 × 16 + 4 × 1
    3. 256 + 160 + 4 = 420

    Answer: 420

Build it in a free lesson

“Binary and logic levels” is lesson 1 of 6 in Logic Grid, Electronics World 7. Free with an account. Lessons unlock in order, so you’ll do the 42 before it first.

Free lesson

Now build it yourself

Each lesson comes in three short parts: see the idea, try it on a live board, then build it yourself, with quick checks as you go.

Try it yourself: free lesson

“Binary and logic levels” is lesson 1 of 6 in Logic Grid, Electronics World 7. Free with an account. Lessons unlock in order, so you’ll do the 42 before it first.

Or start from the very first lesson, no account needed

Check it with a calculator

The ideas behind it

Questions people ask

How do I convert binary to decimal?

Write the place values above the bits, starting with 1 on the right and doubling each step left: 1, 2, 4, 8, 16 and so on. Add the place values that have a 1 under them. So 1010 is 8 + 2 = 10.

How do I convert decimal to binary?

Take the biggest place value that fits, write a 1 there and subtract it. Move to the next place value down: a 1 if it fits into what's left, a 0 if not. Repeat until you reach the 1s place. So 9 is 8 + 1, which is 1001.

Why is the largest 8-bit number 255 and not 256?

8 bits make 2⁸ = 256 different values, but one of them is 0. So they count from 0 to 255. In general, n bits hold 0 to 2ⁿ − 1.

What is hexadecimal for?

Each hex digit stands for exactly four bits, using 0–9 then A–F for 10–15. That makes long binary numbers short and easy to read: the byte 1111 1111 is just FF, which is 255.

More practice