Data representation
Many devices (such as hair straighteners or games consoles) make use of the following symbols:
The 1 means on and the 0 means off. The symbols represents a two-state system, where only 1 or 0 can be used. This is known as binary.
Binary numbers
Normally, people use a denary number system. The denary system is based around the number ten and uses the symbols 0-9. Numbers are written in columns of units, tens, hundreds, thousands and so on.
Binary is based around the number two and only uses the symbols 0 and 1. Processors are only capable of handling these binary values. It is necessary to understand how to convert numbers from denary to binary and vice versa.
Example of converting from binary to denary
The binary number 10101101 represents the denary number 173.
To understand why 10101101 is the same as 173, look at the following table:
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
(27) | (26) | (25) | (24) | (23) | (22) | (21) | (20) |
1 | 0 | 1 | 0 | 1 | 1 | 0 | 1 |
ON | OFF | ON | OFF | ON | ON | OFF | ON |
128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
(27) |
(26) |
(25) |
(24) |
(23) |
(22) |
(21) |
(20) |
1 |
0 |
1 |
0 |
1 |
1 |
0 |
1 |
ON |
OFF |
ON |
OFF |
ON |
ON |
OFF |
ON |
Where a 1 is found under a value, that value is said to be on, where a 0 is found it is off. If you total all the values that are on, the answer is 173:
128 + 32 + 8 + 4 + 1 = 173
Example of converting from denary to binary
If given a denary value and asked to convert to binary, follow the steps shown below. In this example, the denary value is 87.
Step 1 Write out the following denary values across your page:
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
Step 2 Start at the left-hand side and work your way across the columns until you find the first number that is less than or equal to the number you are converting. Place a 1 underneath ths number.
If finding 87, you would place a 0 under 128, as 128 is not less than or equal to 87. You would place a 1 underneath 64 as it is less than or equal to 87.
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 1 |
128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
0 |
1 |
Step 3 When you place a 1 in a column it shows that this number is 'on'. You need to subtract this number from the number you are converting.
In this example subtract 64 from 87, as 64 is ‘on’.
87 – 64 = 23
This gives you a new value to find (23 in this example). Move to the next column on the right, and repeat Step 2 to find the next number that is less than or equal to your new value. Place a 0 under any numbers that aren't less than or equal and a 1 under the first number that is less than or equal to your new value.
In this example you would place a 0 under 32 and then a 1 under 16.
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 1 | 0 | 1 |
128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
0 |
1 |
0 |
1 |
23-16 = 7
Now you are left with the number 7. Repeat Step 2. As 8 is not less than or equal to 7, a 0 can be placed underneath the number 8 column. The number 4 is less than 7, so a 1 is placed underneath the number 4.
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 1 | 0 | 1 | 0 | 1 |
128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
0 |
1 |
0 |
1 |
0 |
1 |
Repeat Step 3:
7 - 4 = 3
Repeat Step 2:
Now you are left with the number 3. As 2 is lower than or equal to 3, a 1 is placed underneath the number 2 column.
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 1 | 0 | 1 | 0 | 1 | 1 |
128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
0 |
1 |
0 |
1 |
0 |
1 |
1 |
Repeat Step 3:
3 - 2 = 1
Repeat Step 2:
Finally, you are left with 1 and can place this value under the number 1 column.
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 1 | 0 | 1 | 0 | 1 | 1 | 1 |
128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
0 |
1 |
0 |
1 |
0 |
1 |
1 |
1 |
Converting the denary number 87 into binary should give you 01010111.