How to Convert a Number from Binary to Decimal System

Table of contents:

How to Convert a Number from Binary to Decimal System
How to Convert a Number from Binary to Decimal System
Anonim

The binary (or base two) number system has two possible values (0 and 1) for each position in the system. By contrast, the decimal (or base ten) number system has ten possible values (0, 1, 2, 3, 4, 5, 6, 7, 8, or 9) for each position in the system.

To avoid confusion when using different number systems, it is possible to make the base of each number explicit by writing it as a subscript of the number itself. For example, you can specify that the binary number 10011100 is in "base two" by writing it as 100111002. the decimal number 156 can be written as 15610 and read as "one hundred and fifty six, base ten".

Since the binary system is the internal language used by electronic computers, all serious programmers should know how to convert from binary to decimal system. The reverse process - converting from decimal to binary - is often more difficult to learn first.

Steps

Method 1 of 2: Positional Notation Method

Convert from Binary to Decimal Step 1
Convert from Binary to Decimal Step 1

Step 1. For this example, we will convert the binary number 100110112 in decimal.

Write the powers of two, going from right to left. Start from 20, which is 1. Increase the exponent by one for each subsequent power. Stop when the number of items in the list equals the number of digits of the binary number. The number of the example, 10011011, has eight digits, so the list of powers, of eight elements, would be this: 128, 64, 32, 16, 8, 4, 2, 1

Convert from Binary to Decimal Step 2
Convert from Binary to Decimal Step 2

Step 2. Write down the digits of the binary number under their corresponding powers of two

Now write 10011011 under the numbers 128, 64, 32, 16, 8, 4, 2 and 1 so that each binary digit corresponds to its power of two. The one to the right of the binary number should correspond to the one on the right of the listed powers of two and so on. You can also write the binary digits above the powers of two if you prefer. The important thing is that they match.

Convert from Binary to Decimal Step 3
Convert from Binary to Decimal Step 3

Step 3. Connect the digits of the binary number with their corresponding powers of two

Draw lines, starting from the right, so that they connect each consecutive digit of the binary number to the power of two in the list above. Start by drawing a line from the first digit of the binary number to the first power of two on the previous line. Then draw a line from the second digit of the binary number to the second power of two on the list. Continue to connect each digit with the corresponding power of two. This will help you visualize the relationship between the two sets of numbers.

Convert from Binary to Decimal Step 4
Convert from Binary to Decimal Step 4

Step 4. If the digit is a 1, then write the corresponding power of two below a line drawn under the binary number

If the digit is a 0, write a 0 below the line and digit.

Since "1" matches "1", it becomes a "1". Since "2" matches "1", it becomes a "2". Since "4" corresponds to "0", it becomes "0". Since "8" corresponds to "1", it becomes "8" and, since "16" corresponds to "1", it becomes "16". "32" corresponds to "0" and is "0" and "64", since it corresponds to "0", becomes "0", while "128", corresponding to "1", becomes "128"

Convert from Binary to Decimal Step 5
Convert from Binary to Decimal Step 5

Step 5. Add the final values

At this point, add the numbers written below the line. Do this: 128 + 0 + 0 + 16 + 8 + 0 + 2 + 1 = 155. This is the decimal number equivalent to the binary number 10011011.

Convert from Binary to Decimal Step 6
Convert from Binary to Decimal Step 6

Step 6. Write the answer by adding its base in subscript

At this point all you have to do is write 15510 to specify that you are working with a decimal number in the form of powers of 10. The more you get used to converting a number from binary to decimal, the easier it will be to memorize the powers of two, thus being able to reach the goal faster.

Convert from Binary to Decimal Step 7
Convert from Binary to Decimal Step 7

Step 7. Use this method to convert a binary number to a decimal point as a decimal

You can also use this method when you want to convert a binary number like 1, 12 in decimal. All you have to do is know that the number on the left of the comma is in the position of the units, as is normal, while the number on the right of the comma is in the position of the "halves" or 1 x (1/2).

The "1" to the left of the comma is equal to 20, that is 1. The "1" on the right corresponds to 2-1, that is 0, 5. Add 1 with 0, 5, obtaining 1, 5, which, in decimal notation, corresponds to 1, 12.

Method 2 of 2: Doubling Method

Convert from Binary to Decimal Step 8
Convert from Binary to Decimal Step 8

Step 1. Write down the binary number

This method does not use powers. For this reason, it is a more convenient method to use for converting large numbers by mind, as you only need to remember one partial result at a time. The first thing you need to do is write down the number you want to convert using the doubling method. Let's say you want to work with 10110012. Write it down.

Convert from Binary to Decimal Step 9
Convert from Binary to Decimal Step 9

Step 2. Starting from the left, double the previous total and add the current figure

As you are working with the number 10110012, your first digit on the left is 1. The previous total is 0 as you haven't started yet. You need to double this total, 0, then add 1, the current figure. 0 x 2 + 1 = 1, so your new running total becomes 1.

Convert from Binary to Decimal Step 10
Convert from Binary to Decimal Step 10

Step 3. Double this partial and add the following figure to the left

Your total is now 1 and the new figure to consider is 0. At this point, double 1 and add 0. 1 x 2 + 0 = 2. Your new total becomes 2.

Convert from Binary to Decimal Step 11
Convert from Binary to Decimal Step 11

Step 4. Repeat the previous step

Continues. Double the running total and add 1, the next digit. 2 x 2 + 1 = 5. Your new total is now 5.

Convert from Binary to Decimal Step 12
Convert from Binary to Decimal Step 12

Step 5. Continue doubling the running total, 5, and add the following digit, 1

5 x 2 + 1 = 11. Your new total is 11.

Convert from Binary to Decimal Step 13
Convert from Binary to Decimal Step 13

Step 6. Repeat the process again

Double your current total, 11, and add the following figure, 0. 2 x 11 + 0 = 22.

Convert from Binary to Decimal Step 14
Convert from Binary to Decimal Step 14

Step 7. Repeat everything again

Now double the running total, 22, and add 0, the next digit. 22 × 2 + 0 = 44.

Convert from Binary to Decimal Step 15
Convert from Binary to Decimal Step 15

Step 8. Continue doubling the subtotal and adding the following figure until you have taken all figures into account

With the last issue you are almost done! All you have to do is take the total, 44, double it and add 1, the last digit. 2 × 44 + 1 = 89. You are done! Were you able to convert 100110112 in the form of decimal notation, 89.

Convert from Binary to Decimal Step 16
Convert from Binary to Decimal Step 16

Step 9. Write down the answer specifying the base subscript

The result is 8910 to highlight that you are working with a decimal number, which is base 10.

Convert from Binary to Decimal Step 17
Convert from Binary to Decimal Step 17

Step 10. Use this method to convert any base to decimal

Doubling is used because the given number is in base 2. If the given number were expressed with a different base, then 2 would have to be replaced with the base of the given number. For example, if the number to be converted were base 37, it would be enough to swap * 2 with a * 37. The final result will always be a decimal number (base 10)

Advice

  • Practice. Try converting the binary numbers 110100012, 110012 and 111100012. The equivalents in decimal base are, respectively, 20910, 2510 and 24110.
  • The calculator provided by your operating system is able to do this conversion for you, but if you are a programmer it is better that you have a good understanding of the conversion process. You can access the calculator's conversion options by clicking on the button View and selecting Programmer or Scientific. On Linux, you can use galculator.
  • Note: This article only explains how to switch between number systems and does not cover translation into ASCII code.

Recommended: