This set of instructions is intended for any individual interested in learning to convert binary code to decimal and vice versa. Most of the time, this will be beginning engineering or computer science students.
It is expected that the reader understands basic math, including division and exponentials.
After following through with the steps of this task, the reader shall be able to understand binary code.
Binary Number |
A number written in “base two.” This means all numbers are expressed using only two digits: 0’s and 1’s. Typically used by computers. |
Decimal Number |
A number written in “base ten.” All numbers are expressed with the numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. The number system common to most people. |
Our working example: Convert the decimal number 376 into binary.
1. Take the decimal number and divide it by two. Remember the remainder.
F
376 ¸ 2 =
188, remainder 0
2. Take the quotient, and divide that by two. Again, keep the remainder.
F
188 ¸ 2 =
94, remainder 0
3. Continue to take the quotient and divide by two until the quotient is 0, always noting the remainder.
F
376 ¸ 2 = 188,
R 0
188 ¸ 2 = 94, R 0
94 ¸ 2 = 47, R 0
47 ¸ 2 = 23, R 1
23 ¸ 2 = 11, R 1
11 ¸ 2 = 5, R 1
5 ¸ 2 = 2, R 1
2 ¸ 2 = 1, R 0
1 ¸ 2 = 0, R 1
4. Now, the reason we saved the remainders is because this is our binary number. To read the number, you read from the last division up (backwards). So, for this example 376 in decimal is 101111000 in binary.
Converting From Binary
Our working example: Convert the binary number 01001011 into decimal.
1. Assign a “place value” to each column in the binary number. If N is the number of places you have moved from right to left, each place value is 2N.
F
Place Value |
27 or 128 |
26 or 64 |
25 or 32 |
24 or 16 |
23 or 8 |
22 or 4 |
21 or 2 |
20 or 1 |
Binary Number |
0 |
1 |
0 |
0 |
1 |
0 |
1 |
1 |
2. For every column that contains a one, write the place number down:
F
64, 8, 2, 1
3. Add all of these numbers together and that is your decimal value.
F
01001011 = 64 + 8 + 2 + 1 = 75
The conversion of binary to decimal will get easier with practice. Also, once the reader is comfortable with this conversion, it will be easy to convert hexadecimal (numbers of base 16) to decimal, or even octal (numbers of base 8) to decimal.