How to convert from binary to decimal

Author: Joan Hall
Date Of Creation: 28 July 2021
Update Date: 1 July 2024
Anonim
How To Convert Binary To Decimal
Video: How To Convert Binary To Decimal

Content

Binary number system ("base two") is a number system that has two possible meanings for each digit; often these values ​​are represented as 0 or 1. Conversely, decimal (base ten) the number system has ten possible values ​​(0,1,2,3,4,5,6,7,8 or 9) for each digit. To avoid confusion when using different number systems, the base of each individual number can be written after the number with a subscript. For example, the binary number 10011100 can be written base two like 100111002... Decimal number 156 can be written as 15610, it will be read like this: "one hundred fifty six, base ten." Since the binary system is the internal language of computers, serious programmers need to understand how to translate from binary to decimal.Converting back from decimal to binary is often more difficult to master first.

Steps

Method 1 of 2: Using positional notation

  1. 1 Write the number in binary, and the powers of two from right to left. For example, we want to convert the binary number 100110112 to decimal. Let's write it down first. Then we write the powers of two from right to left. Let's start with 2, which equals "1". We increase the degree by one for each next number. We stop when the number of elements in the list is equal to the number of digits in a binary number. Our example number, 10011011, includes eight digits, so a list of eight elements would look like this: 128, 64, 32, 16, 8, 4, 2, 1
  2. 2 Write the digits of the binary number under the appropriate powers of two. Now just 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 rightmost "1" of a binary number must match the rightmost "1" of the powers of two, and so on. If you prefer, you can write a binary number over powers of two. The most important thing is that they match each other.
  3. 3 Concatenate binary digits with the corresponding powers of two. Draw lines (from right to left) that connect each subsequent digit in the binary number to the power of two above it. Start drawing lines by connecting the first digit of a binary number with the first power of two above it. Then, draw a line from the second digit of the binary number to the second power of two. Continue connecting each digit with the corresponding power of two. This will help you visually see the relationship between two different sets of numbers.
  4. 4 Write down the final value of each power of two. Go through each digit of the binary number. If the number is 1, write down the corresponding power of two below the number. If this number is 0, write it under the number 0.
    • Since "1" corresponds to "1", it remains "1". Since "2" matches "1", it remains "2". Since "4" is "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 becomes "0", "64" corresponds to "0" and therefore becomes "0", while "128" corresponds to "1" and becomes 128.
  5. 5 Add up the resulting values. Now add the numbers under the line. Here's what you should do: 128 + 0 + 0 + 16 + 8 + 0 + 2 + 1 = 155. This is the decimal equivalent of the binary number 10011011.
  6. 6 Write your answer together with a subscript equal to the number system. Now all you have to do is write 15510to indicate that you are working with a decimal answer that operates in powers of ten. The more you convert binary numbers to decimal numbers, the easier it will be for you to remember the powers of two, and the faster you can complete the task.
  7. 7 Use this method to convert a binary number with a decimal point to decimal. You can use this method even if you want to convert a binary number such as 1.12 to decimal. All you need to know is that the number on the left side of the decimal number is an ordinary number, and the number on the right side of the decimal number is the number of "halves", or 1 x (1/2).
    • "1" to the left of the decimal is 2, or 1. 1 to the right of the decimal is 2, or .5. Add 1 and .5 and you get 1.5, which is the equivalent of 1.1.2 in decimal form.

Method 2 of 2: Using Doubling

  1. 1 Write down the binary number. This method does not use degrees. Therefore, it is easier to convert large numbers in your head - you only need to remember the total all the time. The first thing you need to do is write down the binary number that you will convert using the doubling method. Let's say you are working with the number 10110012... Write it down.
  2. 2 Starting from the left, double your previous total and add the current figure. Since you are working with binary number 10110012, your first digit on the left is 1. Your previous total is 0 since you haven't started yet. You need to double the previous total, 0, and add 1, the current digit. 0 x 2 + 1 = 1, so your new total is 1.
  3. 3 Double your current total and add the next digit to the left. Your current total is 1 and your new digit is 0. So double 1 and add 0. 1 x 2 + 0 = 2. Your new total is 2.
  4. 4 Repeat the previous step. Just keep going. Next, double your current total and add 1, your next digit. 2 x 2 + 1 = 5. Your current total is 5.
  5. 5 Repeat the previous step again. Now double your current total, 5, and add the next digit, 1.5 x 2 + 1 = 11. Your new total is 11.
  6. 6 Repeat the previous step again. Double your current total, 11, and add the next digit, 0.2 x 11 + 0 = 22.
  7. 7 Repeat your previous step again. Now double your current total, 22, and add 0, the next digit. 22 x 2 + 0 = 44.
  8. 8 Keep doubling your current total and adding the next digit until the numbers run out. Now you just have to take the last step. We're almost done! All you have to do is take your current total, 44, double it, and add 1, the last digit. 2 x 44 + 1 = 89. You are done. You have converted 100110112 in decimal notation, in decimal form, 89.
  9. 9 Write your answer together with the radix (subscript). Write your final answer as 8910to indicate that you are using a base 10 decimal system.
  10. 10 Use this method to convert from any bases to decimal. We used doubling because the base of our number system is 2. If the number given to you has a different base, replace 2 with the base of the number system in which the given number is written. For example, if you were given a base 37 number, you would need to replace "x 2" with "x 37". The result will always be in decimal (base 10).

Tips

  • Practice. Try to convert binary numbers 110100012, 110012 and 111100012... Their decimal equivalents are, respectively, 20910, 2510 and 24110.
  • The calculator that comes with Microsoft Windows can do the conversion for you, but as a programmer you have a better understanding of how the conversion works. Conversion is available when you open the View menu and select Engineering (or Programmer). On Linux, you can use a calculator.
  • Note: This method is for counting ONLY, it is not applicable for ASCII conversions.

Warnings

  • This method assumes that the binary number has no sign... It is not a signed number, nor is it a fixed or floating point number.

Similar articles

  • How to convert binary numbers to octal
  • How to Convert Temperature Units
  • How to read time using a binary clock
  • How to convert from decimal to binary