Converting from denary to binary
A method of converting a denary number to binary
There is a very simple method to convert a denaryThe number system most commonly used by people. It contains 10 unique digits 0 to 9. Also known as decimal or base 10. number into a binaryA number system that contains two symbols, 0 and 1. Also known as base 2. number. Let’s take the number 199.
Start by writing out the first few binary place valueThe value of the place, or position, of a digit in a number. (128, 64, 32, 16, 8, 4, 2, 1).
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
Start at the far left point and say “Can 128 be taken away from 199?”. If it can, do that.
199 – 128 = 71. Because 128 could be taken off, put a 1 in the ‘128’ place value column:
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 |
128 | 1 |
---|---|
64 | |
32 | |
16 | |
8 | |
4 | |
2 | |
1 |
Now repeat for 64: 71 – 64 = 7
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 1 |
128 | 1 |
---|---|
64 | 1 |
32 | |
16 | |
8 | |
4 | |
2 | |
1 |
And again for 32: 7 – 32 won’t work, so put a 0 in that place value column.
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 1 | 0 |
128 | 1 |
---|---|
64 | 1 |
32 | 0 |
16 | |
8 | |
4 | |
2 | |
1 |
Try again for 16: 7 – 16 won’t work, so add a 0 to that place value column.
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 1 | 0 | 0 |
128 | 1 |
---|---|
64 | 1 |
32 | 0 |
16 | 0 |
8 | |
4 | |
2 | |
1 |
Next is 8: 7 – 8 won’t work. Add a 0 to the ‘8’ place value column.
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 1 | 0 | 0 | 0 |
128 | 1 |
---|---|
64 | 1 |
32 | 0 |
16 | 0 |
8 | 0 |
4 | |
2 | |
1 |
Try again for 4: 7 – 4 = 3, so add a 1 to the ‘4’ place value column.
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 1 | 0 | 0 | 0 | 1 |
128 | 1 |
---|---|
64 | 1 |
32 | 0 |
16 | 0 |
8 | 0 |
4 | 1 |
2 | |
1 |
Next try 2: 3 – 2 = 1, so add a 1 to the ‘2’ place value column.
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 1 | 0 | 0 | 0 | 1 | 1 |
128 | 1 |
---|---|
64 | 1 |
32 | 0 |
16 | 0 |
8 | 0 |
4 | 1 |
2 | 1 |
1 |
And finally, 1: 1 – 1 = 0 – add a 1 to the ‘1’ place value column.
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 1 | 0 | 0 | 0 | 1 | 1 | 1 |
128 | 1 |
---|---|
64 | 1 |
32 | 0 |
16 | 0 |
8 | 0 |
4 | 1 |
2 | 1 |
1 | 1 |
This means that 199 as a binary number is 1100 0111.
Note that binary numbers are usually written in blocks of four, separated by a space (eg 0111 1011). In denary, numbers are often written in blocks of three (eg 6 428 721).
A quick way to check whether your binary number is likely to be correct is by looking at the last digit. If the denary number was odd, this last binary digit should be a 1. If it was an even number this binary digit should be a 0.