TactivergeLite

Lite / Discovering How the World Works / Week 15

Converting: binary to decimal and back

A robot's register shows 1001 1100. Is the motor speed high or low? First you need to translate.

About 30 min · 3 goals · Reviewed by the founders' mentors · Full interactive version

Why should I care?

Engineers constantly translate between how humans write numbers and how machines store them, when setting registers, reading sensor data or debugging. A quick, reliable method beats guessing.

Predict

What is 13 in binary?

  1. 1011
  2. 1101
  3. 1110
Guess first, then reveal

1101. 13 = 8 + 4 + 1, so the 8, 4 and 1 places are on and the 2 place is off. 1011 is 11 and 1110 is 14.

Discover

Open the Virtual Computer Build, Level 1. Show 13, 6 and 9 on the 4-bit register, then read 1010 and 0111 back into numbers. Before each one, say your answer, then check it on the lamps.

What the interactive shows (text version)

The Virtual Computer Build's Level 1 shows a 4-bit register as four lamps labelled 8, 4, 2 and 1. Turning lamps on shows a number: 13 is 8, 4 and 1 on (1101); 6 is 4 and 2 (0110); 9 is 8 and 1 (1001). Reading 1010 gives 10 and 0111 gives 7.

You can also open the interactive on the full site when you have a faster connection.

Understand

Binary → decimal: add the places

Write the place values above the bits, then add the place values that sit over a 1. For 1001 1100: places 128, 64, 32, 16, 8, 4, 2, 1. The 1s are under 128, 16, 8 and 4. Total: 128 + 16 + 8 + 4 = 156.

Decimal → binary: biggest place that fits

  1. Find the biggest place value that fits into your number. Put a 1 there.
  2. Subtract it.
  3. Repeat with what's left. Any place you skip gets a 0.

22: 16 fits (22 − 16 = 6). 8 doesn't (0). 4 fits (6 − 4 = 2). 2 fits (2 − 2 = 0). 1: 0. So 22 = 10110.

Always check by going back

Convert your answer back: 10110 → 16 + 4 + 2 = 22. ✔ It takes seconds and catches most mistakes. Engineers call this a round-trip check.

Explain it another way

Intuitive

Decimal → binary is like paying an amount with coins of 16, 8, 4, 2 and 1, always using the biggest coin you can first. The binary number is a list of which coins you used.

Technical

Another method is repeated division by 2: the remainders, read from last to first, are the bits. 13 ÷ 2 = 6 r1, 6 ÷ 2 = 3 r0, 3 ÷ 2 = 1 r1, 1 ÷ 2 = 0 r1 → 1101.

Mathematical

Every whole number has exactly one binary form, because each place value is bigger than all the smaller ones added together (8 > 4 + 2 + 1). So the 'biggest first' method never gets stuck.

Applied

In the Virtual Computer Build, numbers in memory are shown as lamps. Translating them is the first skill you need to follow a program as it runs.

Worked example 1

Convert 37 to binary.

32 fits (37 − 32 = 5). 16: 0. 8: 0. 4 fits (5 − 4 = 1). 2: 0. 1 fits (0 left). So 37 = 100101. Check: 32 + 4 + 1 = 37 ✔.

Worked example 2

Convert 0110 1001 to decimal.

Ones are under 64, 32, 8 and 1: 64 + 32 + 8 + 1 = 105.

Common mix-ups

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

Practice 4. Which is 9 in binary?
Practice 5. A classmate says 20 is 10010 in binary. What does a round-trip check show?

Apply it

Write your birthday (day and month) as binary numbers. Then encode a 3-digit secret number for a friend in binary and ask them to decode it and check by converting back.

Reflect

Which direction of conversion do you find easier, and what trick helps you with the harder one?

Write your answer on paper or in your own notes. Lite never stores what you write.

← Counting with only 0 and 1Running out of bits: overflow →