A worked example
Convert 5210 to binary
Step 1: Write down the number to be converted
52
Step 2: Divide it by 2 (because 2 is the base of the binary system), write the whole number part of the answer underneath and the remainder 0 or 1 alongside
52
26 0
Step 3: Divide the answer (26) by 2 and record the remainder (0) as before
52
26 0
13 0
Step 4: Divide the 13 by 2 and write down the answer (6) and the remainder (1)
52
26 0
13 0
6 1
Step 5: 2 into 6 goes 3 remainder 0
52
26 0
13 0
6 1
3 0
Step 6: Dividing 3 gives an answer of 1 and a remainder of 1
52
26 0
13 0
6 1
3 0
1 1
Step 7: Finally, dividing the 1 by 2 will give 0 and a remainder of 1
52
26 0
13 0
6 1
3 0
1 1
0 1
Step 8: We cannot go any further with the divisions because all the answers will be zero from now on. The binary number now appears in the remainder column. To get the answer read the remainder column from the bottom UPWARDS
52
26 0 = 1101002
13 0 ↑
6 1 ↑
3 0 ↑
1 1
0 1
Method
1 Divide the denary number by 2 – write the whole number result underneath and the remainder in a column to the right.
2 Repeat the process until the number is reduced to zero.
3 The binary number is found by reading the remainder column from the bottom upwards.
Another example
Here is one for you to try. If you get stuck, the solution is given below. Convert 218710 to a binary number
2187
1093 1 = 1000100010112
546 1 ↑
273 0 ↑
136 1 ↑
68 0 ↑
34 0
17 0
8 1
4 0
2 0
1 0
0 1
Doing it by calculator: Many scientific calculators can do the conversion of denary to binary for us. Unfortunately, they are limited to quite low numbers by the number of digits able to be seen on the screen. To do a conversion, we need:
1 A scientific calculator that can handle different number bases.
2 The instruction booklet.
3 About half an hour to spare – or a week if you have lost the instructions.
The exact method varies but on my elderly Casio it goes something like this:
To tell the calculator that the answer has to be in binary I have to press mode mode 3 then the ‘binary’ key.
It now has to be told that the input number is decimal. This is the exciting key sequence logic logic logic 1 now just put in our number 52 and press the = key and out will pop the answer 110100.
If we look at a denary number like 8328, we see that it contains two eights. Now these two figures look identical however closely we examine them, but we know that they are different. The 8 on the right-hand end is really 8 but the other one is actually 8000 because it is in the thousands column.
The real value of a digit is dependent on two things: the digit used and the column in which it is placed.
In the denary system, the columns, starting from the right, are units, tens, hundreds, thousands etc. Rather than use these words, we could express them in powers of ten. A thousand is 10×10×10=10³ and in a similar way, a hundred is 10², ten is 10¹ and a unit is 100. Each column simply increases the power applied to the base of the number system. Columns in a binary world also use the base raised to increasing powers as we move across the columns towards the left. So we have:
2³ 2² 2¹ 20
The denary equivalent can be found by multiplying out the powers of two. So 2³ is 2×2×2 = 8 and 2²=4, 2¹=2 and finally 20=1. Starting from the right-hand side, the column values would be 1, 2, 4, 8 etc. Let’s use this to convert the binary number 1001 into denary.
Method
Step 1: Write down the values of the columns
8 4 2 1
Step 2: Write the binary number underneath
8 4 2 1
1 0 0 1
Step 3: Evaluate the values of the columns
8 × 1 = 8
4 × 0 = 0
2 × 0 = 0
1 × 1 = 1
Step 4: Add up the values
8 + 1 = 9
As we have seen, all the columns containing a binary 0 can be ignored because they always come out to 0 so a quicker way is to simply add up all the column values where the binary digit is 1.
Method
1 Write down the column values for the binary system using the same number of columns as are shown in the binary number.
2 Enter the binary number, one bit under each column heading.
3 Add the values of each column where a 1 appears in the binary number. Calculator note: This is much the same as we saw the previous conversion. To tell the calculator that the answer has to be in decimal I have to press mode mode 3 then the ‘decimal’ key.
It now has to be told that the input number is binary. This is done by the key sequence logic logic logic 3 now just put in our binary number 1001 and press the = key and out will pop the answer 9.
Another example
Once again, here is one for you to try. If you have problems, the answer follows.
Convert 1011001012 to a denary number
Step 1: Write down the column values by starting with a 1 on the right-hand side then just keep doubling as necessary
28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
---|---|---|---|---|---|---|---|---|
256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Step 2: Enter the binary number under the column headings
256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|---|
1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 |
Step 3: Add up all the column values where the binary digit is 1
256 + 64 + 32 + 4 + 1 = 357
So, 1011001012 = 35710 or just 357 since denary can be assumed in this case.
All the information entering or leaving a microprocessor is in the form of a binary signal, a voltage switching between the two bit levels 0 and 1. Bits are passed through the microprocessor at very high speed and in large numbers and we find it easier to group them together.
Nibble
A group of four bits handled as a single lump. It is half a byte.
Byte
A byte is simply a collection of 8 bits. Whether they are ones or zeros or what their purpose is does not matter.
Word
A number of bits can be collected together to form a ‘word’. Unlike a byte, a word does not have a fixed number of bits in it. The length of the word or the number of bits in the word depends on the microprocessor being used.
If the microprocessor accepts binary data in groups of 32 at a time then the word in this context would include 32 bits. If a different microprocessor used data in smaller handfuls, say 16 at a time, then the word would have a value of 16 bits. The word is unusual in this context in as much as its size or length will vary according to the situations in which it is discussed. The most likely values are 8, 16, 32 and 64 bits but no value is excluded.