Skip main navigation

Converting Numbers to Binary

Introduce the base 2 numbering system known as binary, and show how to convert our everyday base 10 numbers (denary) into binary and vice versa.
5.4
Wen we count in denary, we begin at 0, count all the way up to 9, then go back to 0 again, but have an additional digit in the next column. Why is it that we have 10 separate symbols to represent all of our numbers? The answer is probably because we have 10 fingers and thumbs, although nobody really knows why. In binary, there are only two digits available, 1 and 0. So as soon as we count up to one, we go back to 0 again, but have an additional digit in the next column. So how can we convert from denary to binary? When you are learning about numbers as a child, you probably use the terms 1s, 10s, 100s and 1000s.
47
These are all powers of 10. We can draw a table using all these values as headings. We can write in a number, in this case, 09032. And we can see that it’s made up of zero 10000s, nine 1,000s, zero 100s, three 10s and two 1s. In binary, we can do the same thing, but using powers of 2. Again, a table can be drawn up using these numbers as headings. As we did with denary, we can write in a binary number such as 10111 Now we can see it is made up of one 16, zero 8s, one 4, one 2, and one 1. So in denary, we have 16 plus 4 plus 2 plus 1 equals 23.
100.2
You’re now going to have a go at doing some binary to denary conversions yourself. So you might like to replay this video and have a look over it again. Pause the video here and practise on the following binary numbers and see if you can work out what they would be in denary.
117.7
Converting numbers back the other way isn’t it much more difficult. If you wanted to convert the number 21 into binary, you start out with an empty table like this. Then look in each of the columns to see what needs to be placed there, using only ones and zeros. In this case you need one 16, zero 8s, one 4, zero 2s, and one 1.
142.1
Reading off from the table, you can see that 21 in binary is 10101. Have a go at converting the following denary numbers into binary. Don’t forget to share your answers and help each other out in the comment section.

In this step we will introduce the base 2 numbering system known as binary, and show how to convert our everyday base 0 numbers (denary) into binary and vice versa.

Binary and denary

Our usual everyday number system is sometimes called ‘denary’. When we count in denary we begin at 0, count all the way up to 9, then go back to 0 again, but have an additional digit in the next column. You could ask yourself, why is it that we have ten separate symbols to represent all our numbers? The answer is most probably because we have ten fingers and thumbs, although it’s not really known.

However, computers use binary, in which we only have two digits available to us, 1 and 0. So, after we count up to 1 we go back to 0 again, but have an additional digit in the next column. A binary digit is commonly known as a bit.

Binary is called base 2 because there are two digits (bits) available with which to count: 0 and 1. The term base 2 also refers to the fact that each binary place is two times bigger than the previous one. Our everday counting, denary, is described as base 10, as we have ten digits available: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.

So how can we convert from one to the other? When you were learning about numbers as a child, you probably used the terms thousand, hundreds, tens, and units (or ones). These are all powers of 10. You can draw a table using all these values as headings.

10⁰ = 1

10¹ = 10

10² = 100

10³ = 1000

10⁴ = 10000

Using these headings you can write in a number, say 09032. Make sure that you use all of the columns that you have digits for, starting at the right-most column, which represents units. In this case 09032 has five digits, so you start filling the table from the right, beginning with the 2 in the units column:

Ten thousands Thousands Hundreds Tens Units
10000 1000 100 10 1
0 9 0 3 2

We can see that it is made up of zero 10000s, nine 1000s, zero 100s, three 10s, and two 1s.

In binary, we can do the same thing, but using powers of 2:

2⁰ = 1

2¹ = 2

2² = 4

2³ = 8

2⁴ = 16

Again, a table can be drawn up using these numbers as headings.

2⁴ = 16 2³ = 8 2² = 4 2¹ = 2 2⁰ = 1
1 0 1 1 1

As we did with denary, we can write in a binary number, such as 10111. Again, we have to make sure that we use the units (2⁰) column, with no gaps. Now we can see that the number represented in binary as 10111 is made up of one 16, zero 8s, one 4, one 2, and one 1. So, in denary, we have 16 + 4 + 2 + 1 = 23.

Try converting the following binary numbers into denary. Share your answers and any problems you have in the comments section below:

  • 1010
  • 1001
  • 10001

Converting numbers back the other way isn’t much more difficult.

If we wanted to convert the denary number 21 into binary, we could start out with an empty table like this:

16 8 4 2 1
         

We need to look in each of the columns to see what needs to be placed there using only ones and zeros. It’s easiest to do this by starting from the left: in this case we would consider the number 21 and look at the table to see which of the columns has the biggest number that is less than 21. This is 16, so our first 1 would be in the 16 column.

Step 1, running total = 16

16 8 4 2 1
1        

Now, we still have 5 left (21 – 16 = 5) so we look to the right of the 16 column. The next column along has an 8 in, which is too big to add on to our 16 and would take us to 24. This means that we put a 0 in the 8 column and look at the next column along. The next column is the 4 column which is useful (as it is less than 5) and gets us closer to our target or 21, so we put a 1 in the 4 column.

Step 2, running total = 20

16 8 4 2 1
1 0 1    

At this stage we have 16 + 4 = 20. We still need 1 to get to 21, so we put a 0 in the 2 column and a 1 in the 1 column. Now we have arrived at 21 and have (1×16) + (0×8) + (1×4) + (0×2) + (1×1) = 21. This is shown in the table below:

Step 3, final total = 21

16 8 4 2 1
1 0 1 0 1

Reading off from the table, we can see that 21 in binary is 10101.

Have a go at converting the following denary numbers into binary:

  • 31
  • 12
  • 64

Don’t forget to share your answers and help each other out in the comments section. Also, describe how you think the binary table may have to be modified if you wanted to represent a binary number with more than 5 bits, for example 101010?

This article is from the free online

Understanding Maths and Logic in Computer Science

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education