Converting between number bases using binary
Binary to decimal
The binaryA number system that contains two symbols, 0 and 1. Also known as base 2. system is base 2A number system that contains two digits, 0 and 1. Also known as binary. and has just two symbols, 0 and 1. The first eight binary place values are:
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| 128 |
| 64 |
| 32 |
| 16 |
| 8 |
| 4 |
| 2 |
| 1 |
To convert binary to decimalAnother name for the number system that contains the digits 0 to 9. Also known as denary or base 10. Decimal fractions are numbers where the fraction is indicated by the use of a full stop, eg 4.1 or 6.3., simply take each place value that has a 1, and add them together.
Example - binary number 1111100
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| 0 | 1 | 1 | 1 | 1 | 1 | 0 | 0 |
| 128 | 0 |
|---|---|
| 64 | 1 |
| 32 | 1 |
| 16 | 1 |
| 8 | 1 |
| 4 | 1 |
| 2 | 0 |
| 1 | 0 |
Result - (0 × 128) + (1 × 64) + (1 × 32) + (1 × 16) + (1 × 8) +
(1 × 4) + (0 × 2) + (0 × 1) = 124
A method of converting a denary number to binary
Question
What would these binary numbers be in decimal?
- 1001
- 10101
- 11001100
- 9
- 21
- 204
Decimal to binary
To convert from decimal to binary, start by subtracting the biggest place value possible from the decimal number, then place a 1 in that place value column. Next, subtract the second biggest place value possible, and place a 1 in the column. Repeat this process until zero is reached. Finally, place a 0 in any empty place value columns.
Example - decimal number 84
- First set up the columns of binary place values.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| 128 | |
|---|---|
| 64 | |
| 32 | |
| 16 | |
| 8 | |
| 4 | |
| 2 | |
| 1 |
- 64 is the biggest place value that can be subtracted from 84. Place a 1 in the 64 place value column and subtract 64 from 84, which gives 20.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| 1 |
| 128 | |
|---|---|
| 64 | 1 |
| 32 | |
| 16 | |
| 8 | |
| 4 | |
| 2 | |
| 1 |
- 16 is the biggest place value that can be subtracted from 20. Place a 1 in the 16 place value column and subtract 16 from 20, which gives 4.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| 1 | 1 |
| 128 | |
|---|---|
| 64 | 1 |
| 32 | |
| 16 | 1 |
| 8 | |
| 4 | |
| 2 | |
| 1 |
- 4 is the biggest place value that can be subtracted from 4. Place a 1 in the 4 place value column and subtract 4 from 4, which gives 0.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| 1 | 1 | 1 |
| 128 | |
|---|---|
| 64 | 1 |
| 32 | |
| 16 | 1 |
| 8 | |
| 4 | 1 |
| 2 | |
| 1 |
- Place a 0 in each remaining empty place value column.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 |
| 128 | 0 |
|---|---|
| 64 | 1 |
| 32 | 0 |
| 16 | 1 |
| 8 | 0 |
| 4 | 1 |
| 2 | 0 |
| 1 | 0 |
Result - 84 in decimal is 01010100 in binary.
To check that this is right, convert the binary back to decimal:
(0 × 128) + (1 × 64) + (0 × 32) + (1 × 16) + (0 × 8) + (1 × 4) +
(0 × 2) + (0 × 1) = 84
Another way to convert a decimal number to binary is to divide the starting number by two. If it divides evenly, the binary digitA single whole number value from 0 to 9, especially when used in a larger number. For example, the number 752 has 3 digits. is 0. If it does not and there is a remainder, the binary digit is 1. Finally, reverse the digits and you have the correct number.
A method of converting a denary number to binary
Question
What would these decimal numbers be in binary?
- 12
- 42
- 188
- 1100
- 101010
- 10111100
This table illustrates the relationship between decimal and binary numbers, from 0 up to 255.
Binary is also used within truth tableA table to list the output for all possible input combinations into a logic gate.. To find out more, see the computer systems study guide.