Binary & Decimal Numbers

The numbering system you and I use normally is called the decimal system, as it goes up in multiples of 10.

However, as we learnt last lesson, computers use the binary system, where numbers go up in multiples of 2.

It’s important that when learning binary, we know how to convert numbers between binary and decimal.

In this lesson, we’ll learn about:

  1. The difference between binary and decimal.
  2. How to convert decimal numbers to binary.
  3. How to convert binary numbers to decimal.
Media Attachments: Presentation

1. The Difference Between Binary & Decimal

Let’s think about the number 12. It’s actually two separate numbers – 1 & 2. However, they belong to different columns.

TENSONES
12

The number 12 Can be thought of as ONE TEN and TWO ONEs.

In the decimal system, each column goes up in multiples of 10. Each column can be given a value of 0-9 (10 possible values).

TEN THOUSANDSTHOUSANDSHUNDREDSTENSONES
0-9 0-9 0-9 0-9 0-9

So let’s look at the number 4096.

TEN THOUSANDSTHOUSANDSHUNDREDSTENSONES
04096

As you can see, we have:

  • 0 ten thousands
  • 4 thousands
  • 0 hundreds
  • 9 tens
  • 6 ones

This should all be pretty familiar to you from primary school and key stage 3.

Binary numbers work very similarly, except the columns increase in multiples of two and each column can only store a 0 or 1.

1286432168421
0-10-10-10-1 0-1 0-1 0-1 0-1

Notice how each column is simply a multiple of 2, as shown in figure 1.

A diagram showing how each column in binary is 2 x the previous one
Figure 1 – each column in binary is 2x the previous one.

It is important that you get your columns drawn out first, remember the smallest numbers are on the RIGHT and the numbers go up by multiples of 2 RIGHT TO LEFT.

The smallest number in a binary sequence is known as the “least significant bit”. The largest number is known as the “most significant bit”.

Whenever beginning any of your binary maths, always write your numbers down in the right order and you can’t miss!

Further Thought

If the binary system goes up in 2’s, what is the Ternary and Quaternary systems? Why might they be used?

2. Converting Decimal to Binary

In order to do this, you need to ask yourself the following question:

Can I take away my binary column from my decimal number and be left with a positive?

Or

Can my binary column fit into my decimal number?

Let’s take a look at the decimal number 25. We are going to convert it into a 6-bit binary number.

Firstly we need to put our binary columns down, as it is going to be 6 bits, we need 6 columns:

32168421
 

Step 1

Start with the 32 column (our most significant bit). Can 32 fit into 25?

No, so we don’t have any of these, so we put 0 in the 32 column.

32168421
0

Step 2

Move onto the 16 column. Can 16 fit into 25?

Yes, so we have one of these, so we put 1 in the 16 column.

32168421
01

Now we have to take 16 away from 25. 25 – 16 = 9.

Step 3

Move onto the 8 column. Can 8 fit into 9?

Yes, so we have one of these, so we put 1 in the 8 column.

32168421
01 1

Now we have to take 8 away from 9. 9 – 8 = 1.

Step 4

Move onto the 4 column. Can 4 fit into 1?

No, so we don’t have one of these, so we put a 0 in the 4 column.

32168421
01 10

Step 5

Move onto the 2 column. Can 2 fit into 1?

No, so we don’t have one of these, so we put a 0 in the 2 column.

32168421
01 100

Step 6

Move onto the 1 column (our least signiciant bit). Can 1 fit into 1?

Yes, so we have one of these, so we put a 1 in the 1 column.

32168421
01 1001

Now we have to take 1 away from 1. 1 – 1 = 0.

And our conversion is now finished!

Basically, you need to keep taking away until you reach zero, and your final number MUST be either a 0 or a 1. If you end up with anything other than 0 or 1 then your maths has gone wrong.

So, the number 25 in 6-bit binary is 011001 which is correct.

You must always give your answer in the required number of bits. Your exam will usually want your answer in 8 bits.

The number 25 in 8-bit binary is:

1286432168421
0001 1001

In decimal, if a number starts with a 0 it is usually ignored, for example, we never say “I’ll have 05 bags of crisps”. However, in binary, it is important that these are put down as you are then using the required number of bits.

Further Thought

Why do you think it is important to always include any zeros that precede a binary number, even though they are never used?

3. Converting Binary to Decimal

In order to convert from binary to decimal, we take our binary number and put it in the columns.

Let’s take the number 25 again. In 6-bit binary we saw that this is 011001.

32168421
01 1001

To convert this back into decimal, we need to work out which columns have a ONE in them.

1681
1 11

Then we simply need to add up these column heading values.

16+8+1=25.

And that’s all it takes.

This works for any number. For example:

1286432168421
1011 1010

Pick all the 1’s.

128321682
111 11

Add them up.

128+32+16+8+2=186.

Further Thought

How would you convert numbers greater than 8 bits?

Lesson Summary

So to summarise what we’ve learnt in this lesson:

  • The decimal number system is based on a counting system where columns go up by multiples of 10.
  • The binary number system is based on a counting system where columns go up by multiples of 2.
  • To convert decimal to binary keep taking away until you reach zero.
  • To convert binary to decimal, add up all the binary columns that contain a 1.
  • When converting decimal to binary you should only have a 1 or a 0 in each column.