Skip main navigation

Working with Binary

In this step, you are going to look at working with binary. As you are probably aware, a Turing machine is capable of operating using only two symbols - 1 and 0 - and the rather bold statement was made that, using just these symbols, it can do any computation! How can this be? How can you even add up two numbers, say 12 and 6, if you only have the ability to use 1s and 0s?

In this step, you are going to look at working with binary.

As you are probably aware, a Turing machine is capable of operating using only two symbols – 1 and 0 – and the rather bold statement was made that, using just these symbols, it can do any computation!

 

How can this be? How can you even add up two numbers, say 12 and 6, if you only have the ability to use 1s and 0s?

 

To answer this question, you first need to take a brief look at the nature of numbers. When you were learning to do basic arithmetic, when you were a child, you probably learned about counting in ones, tens, hundreds, and thousands.

 

This is called base 10, or denary. When writing down numbers, you begin at 0, count up to 9, then go back to 0 again, but add an additional digit in the next column.

 

Animated GIF showing numbers counting up in denary.

 

You could ask yourself: Why have ten separate symbols to represent all our numbers? Why not five? Then counting would look like this:

 

Animated GIF showing numbers counting up in base 5. This means that after the number 04, the next number is 10, and after 14 the next number is 20.

 

The answer is most probably because you have ten fingers and thumbs, although it’s not really known. Some cultures around the world count in different bases, and most people in the world are fairly happy using base 12 and base 60 when telling the time.

 

The Turing machine uses base 2, or what is often called binary. Here’s an example of counting in binary

 

Animated GIF showing binary numbers counting up, from 0 to 1 to 1 0 to 1 1 to 1 0 0 to 1 0 1 to 1 1 0 to 1 1 1 to 1 0 0 0 and so on.

 

This is exactly what the Turing machine did.

 

So to answer the original question – how could a Turing machine add the numbers 12 and 6? – the answer is that the machine would use the binary representations of these numbers.

 

Converting Binary to Denary

 

Here’s an example of simultaneously counting in both binary and denary.
Animated GIF showing numbers counting up simultnaeously in both binary and denary.

 

So how can you convert from one to another?

 

I said earlier that when you were learning about numbers as a child, you probably used the terms ones, tens, hundreds, and thousands. These are all powers of 10.

 

Graphic showing the powers of ten: 10 to the 0 equals 1, 10 to the 1 equals 10, 10 to the 2 equals 100, etc.

 

You can then arrange these values horizontally to be used as headings.

 

The powers of ten laid out horizontally from right to left.

 

Now you can write in a number — in this case 09032 — and you can see that it is made up of 0 × 10000, 9 × 1000, 0 × 100, 3 × 10, and 2 × 1:

 

The powers of ten and beneath them the denary digits 0 9 0 3 2.

 

In binary, you can do the same thing, but using powers of 2.

 

Graphic showing the powers of 2: 2 to the 0 equals 1, 2 to the 1 equals 2, 2 to the 2 equals 4, etc.

 

Again, the values can be arranged as headings.

 

Powers of 2 laid out horizontally from right to left.

 

As you did with denary, you can write in a binary number such as 10111.

 

Powers of two with the binary values 1 0 1 1 1 beneath them.

 

You can now see it is made up of 1 × 16, 0 × 8, 1 × 4, 1 × 2, and 1 × 1. So if this was in denary, it would be the number 23.

 

Animated graphic showing how the binary values can be multiplied by the powers of two as above to calculate the denary value.

 

Have a practice with the following binary numbers and see if you can work out what they would be in denary. There’ll be a quiz on this in the next section.

 

1010
1001
10001

 

Converting numbers back the other way isn’t much more difficult. If you want to convert the number 21 into binary, you would do it like this:

 

Animated graphic showing how the denary number can be divided by the powers of two, with the remainder used for the next division, to turn a denary number into a binary number.

 

You keep dividing the number by a power of 2, and then using the remainder for the next division.

 

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.

 

7
15
40

You can challenge your peers to do more binary to denary and denary to binary calculations and discuss your answers and observations.

This article is from the free online

How Computers Work: Demystifying Computation

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