The binary (base two) numeric system has two possible values, either 0 or 1, for each place value. In contrast, the decimal (base ten) numeric system has ten possible values (0, 1, 2, 3, 4, 5, 6, 7, 8, or 9) for each place value. To avoid confusion when using different numeric systems, the base of each number can be subscripted. For example the binary number 10011100 can be written in base two by writing 100111002. The decimal number 156 can be written as 15610 and read one hundred and fifty six, base ten. Since the binary system is the internal language of electronic computers, serious computer programmers will understand how to convert binary to decimal. Converting vice versa, from decimal to binary, is often more difficult to learn the first time.
Step
Method 1 of 2: Using Position Notation
Step 1. Write down the binary numbers and list the squares of 2 from right to left
For example we want to convert the binary number 100110112 be decimal. First, write it down. Then, write down the square of 2 from right to left. Start at 20, which is 1. Increment the square one by one. Stop if the number of digits in the list is equal to the number of binary digits. The example number, 10011011, has eight digits, so the list has 8 numbers, like this: 128, 64, 32, 16, 8, 4, 2, 1
Step 2. Write down the digits of the binary number below the square of two list
Write the number 10011011 under the numbers 128, 64, 32, 16, 8, 4, 2, and 1 so that each binary digit has its own square of twos. The 1 to the right of the binary number aligns with the 1 in the list of squares 2 and so on. You can also write binary digits above the square of two, if you prefer. The important thing is that you can pair it.
Step 3. Connect the digits of the binary number with the list of squares of two
Draw a line, starting from the right, connecting each digit of the binary number by the square of two. Start by lining the first digit of the binary number with the square of the first two in the list above it. Then, draw a line from the second digit of the binary number to the square of the second two in the list. Continue connecting each digit by the square of two. This will help you visualize the relationship between the two sets of numbers.
Step 4. Write down the final value of each square of two
Comb through each digit of the binary number. If the digit is 1, write the square of the two pairs below the 1. If the digit is 0, write 0 under the number 0.
Since 1 pairs with 1, the result is 1. Since 2 pairs with 1, the result is 2. Since 4 pairs with 0, the result is 0. Since 8 pairs with 1, the result is 8, and since 16 pairs with 1, the result is 16. 32 pairs with 0 so the result is 0 and 64 pairs with 0 so the result is 0, while 128 pairs with 1 so the result is 128
Step 5. Add the final value
Now, add up all the numbers written below the binary digits. Here's what you do: 128 + 0 + 0 + 16 + 8 + 0 + 2 + 1 = 155. This is the decimal equivalent of the binary number 10011011.
Step 6. Write your answer with the base subscript
Now, you have to write 15510, to show that the number is a decimal, which is a multiple of 10. The more you get used to converting binary to decimal, the easier it will be for you to remember the square of two, and you'll be able to convert it more quickly.
Step 7. Use this method to convert a binary number with a decimal point into decimal form
You can use this method when you want to convert binary numbers like 1, 12 be decimal. All you have to do is know that the number to the left of the decimal is the ones position, while the number to the right is the half position, or 1 x (1/2).
The 1 to the left of the decimal point equals 20, or 1. The 1 to the right of the decimal equals 2-1, or 0, 5. Add 1 and 0, 5 so that the result is 1,5 which can be written 1, 12 in decimal notation.
Method 2 of 2: Using Multiplying Two
Step 1. Write down the binary number
This method does not use squares. So, it's easier to turn big numbers in your head because you only need to remember the numbers. The first thing you will need is to write down the binary number that you are going to convert by multiplying by two. Suppose you want to convert the binary number 10110012. Write it down.
Step 2. Starting from the left, multiply the previous total by two and add the digits
Because you are using the binary number 10110012, your first digit from the left is 1. Your previous total is 0 because you haven't started yet. You must multiply the previous two totals, 0, and add 1, the digits. 0 x 2 + 1 = 1, so your new total is 1.
Step 3. Multiply your current total by two and add the next digit
Your current total is 1 and the new digit is 0. So multiply by 1 and add 0.1 x 2 + 0 = 2. Your new total is 2.
Step 4. Repeat the previous step
Continue. Next, double your total and add 1, your next digit. 2 x 2 + 1 = 5. Your total now is 5.
Step 5. Repeat the previous step again
Next, double your current total, 5, and add the next digit, 1.5 x 2 + 1 = 11. Your new total is 11.
Step 6. Repeat the previous step again
Multiply your current total, 11, and add the next digit, 0.2 x 11 + 0 = 22.
Step 7. Repeat the previous step again
Now, double your current total, 22 and add 0, the next digit. 22 x 2 + 0 = 44.
Step 8. Continue to multiply your current total by two and add the next digits until you run out
Now, is your final number and it's almost done! All you have to do is multiply your current total, 44 and multiply by two and then add 1, the last digit. 2 x 44 + 1 = 89. It's done! You have changed 100110112 to the decimal form 89.
Step 9. Write down the answer with the base subscript
Write your final answer 8910 to denote a decimal number that has a base of 10.
Step 10. Use this method to convert any base to decimal form
Multiplying two is used because the given number is based on 2. If the given number has a different base, replace the 2 in this method with that number's base. For example, if the number given is based on 37, replace x 2 with x 37. The end result is always in decimal (base 10).
Tips
- Practice. Try converting the binary number 110100012, 110012, and 111100012. Each binary number is equivalent to a decimal 20910, 2510, and 24110.
- The calculator built into Microsoft Windows can help you convert numbers, but as a programmer, you better understand how to change them. The conversion calculator can be brought up by opening the View menu and selecting Scientific (or Programmer). In Linux, you can use galculator.
- Note: this is ONLY for calculating and not talking about ACSII.