# 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.

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

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

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.

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.

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

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:

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

Again, the values can be arranged as headings.

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

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.

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:

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.