Article
Converting decimal numbers to binary
To turn the number 45 into binary, ask one question: which binary place values add up to 45? There are two reliable ways to find out. Pick the one you like best, and use the other to check your work.
Method 1: take the biggest place you can
Write the binary place values: 128, 64, 32, 16, 8, 4, 2, 1. Start at the left. For each place:
- If the place value is less than or equal to what is left, write 1 and subtract the place value.
- If not, write 0 and keep what is left.
When you reach the 1s place, nothing should be left. Here it is for 45:
| Place value | Does it fit in what is left? | Bit | Left after |
|---|---|---|---|
| 128 | No (128 is more than 45) | 0 | 45 |
| 64 | No | 0 | 45 |
| 32 | Yes | 1 | 13 |
| 16 | No (16 is more than 13) | 0 | 13 |
| 8 | Yes | 1 | 5 |
| 4 | Yes | 1 | 1 |
| 2 | No | 0 | 1 |
| 1 | Yes | 1 | 0 |
Read the Bit column from top to bottom: 00101101. The two zeros at the start are leading zeros. They do not change the value, so you can write the answer as 101101.
Check it by adding the places that have a 1: 32 + 8 + 4 + 1 = 45. Good.
Method 1 for each place
Take the biggest place
for example 128
compareDoes it fit in what is left?
yes: write 1 and subtract it. No: write 0
next place downStop after the 1s place
nothing should be left
Check your understanding
Which binary number is equal to the decimal number 20?
Method 2: halve again and again
Divide the number by 2. Write down the remainder, which is the amount left over (it is always 0 or 1). Then divide the answer by 2 again. Keep going until the answer is 0. Here it is for 13:
13 ÷ 2 = 6 remainder 1
6 ÷ 2 = 3 remainder 0
3 ÷ 2 = 1 remainder 1
1 ÷ 2 = 0 remainder 1Now read the remainders from the bottom up: 1101. Check: 8 + 4 + 1 = 13.
Method 2 in four moves
Divide by 2
write the remainderRemainder is 0 or 1
divide the answer againStop when the answer is 0
Read the remainders bottom up
13 gives 1101
Why does this work? The first remainder tells you whether the number is odd, and that is exactly what the 1s place stores. Dividing by 2 then drops the 1s place and moves every other place one step to the right. So the next remainder is the old 2s place, then the old 4s place, and so on.
Check your understanding
Which binary number is equal to the decimal number 37?
Worked example: 77 by Method 1
The place values 128, 64, 32, 16, 8, 4, 2, 1 give:
- 128 does not fit in 77, so write 0.
- 64 fits. Write 1. Left: 77 − 64 = 13.
- 32 and 16 do not fit in 13. Write 0 and 0.
- 8 fits. Write 1. Left: 5.
- 4 fits. Write 1. Left: 1.
- 2 does not fit. Write 0.
- 1 fits. Write 1. Left: 0.
The bits are 01001101, which is 1001101 without the leading zero. Check: 64 + 8 + 4 + 1 = 77.
Common mistakes
- Reading the remainders from the top down in Method 2. You must read them from the bottom up, or the number comes out backwards.
- Skipping a place. Every place needs a bit, even when it is 0. Missing a 0 shifts all the other digits.
- Starting with the smallest place in Method 1. Start with the biggest place that fits.
- Not checking. Add the places with a 1 at the end. If you do not get the number you started with, find the mistake.
On the exam
You will be given a small decimal number, often below 100, and asked for its binary form. Many learners find Method 1 faster. Always add up your answer as a final check.
Key words
Convert: change a number from one number system to another.
Remainder: what is left over after a division.
Leading zero: a 0 at the left end of a number. It does not change the value.