How to Convert Binary to Decimal

Author: Monica Porter
Date Of Creation: 19 March 2021
Update Date: 27 June 2024
Anonim
How To Convert Binary To Decimal
Video: How To Convert Binary To Decimal

Content

Binary is the internal language of an electronic computer. As a programmer, you need to know how to switch words binary to decimal. In this article, wikiHow will guide that.

Steps

Method 1 of 2: Use location notation

  1. Write binary numbers and a list of powers of two words right to left. Assume the same as with the binary number 100110112. First, write this number. Next, write down the powers of two from right to left. Starting at 2, gives the value "1". Increase exponential through each power value. Stop when the number of elements in the list is equal to the number of digits contained in the binary number. 10011011 has eight digits so our list has eight elements, namely: 128, 64, 32, 16, 8, 4, 2, 1.

  2. Write the digits in the binary number below its corresponding element in the power list of 2. In the example problem, we simply write 10011011 under the numbers 128, 64, 32, 16, 8, 4, 2, and 1. The digit "1" is at the end of the binary number corresponding to "1". rightmost of the powers of two. You can also write the digits in the binary number on top if you prefer. It is important that they correspond to having elements in the powers of 2.

  3. Matches the digit in the binary number to the power of 2 corresponding to it. From the right, draw the line connecting each digit of the binary number to the power of 2 directly above it. The first is the first digit of the binary number with 2 exponent 1. Next, the second digit with 2 exponent 2. Continue until the end. Thus, you can see the relationship between the two sets of numbers.

  4. Write down the final value. For the number 1, write the power of 2 that corresponds to it directly below the dash below. If it is a 0, write 0 directly below the horizontal line.
    • Since "1" corresponds to "1", our final value will be "1". "2" corresponds to "1" so the final value will be "2". "4" corresponds to "0" so the final value will be "0". "8" corresponds to "1" so the final value is "8" and "16" corresponds to "1" so we have "16". "32" corresponds to "0" and returns "0". "64" corresponds to "0" so the final value is "0" while "128" corresponds to "1" so we have 128.
  5. Add the final values. Now add up the numbers written under the dash. We have: 128 + 0 + 0 + 16 + 8 + 0 + 2 + 1 = 155. This is the decimal corresponding to the binary number 10011011.
  6. Write the sum you find with its base. In the example problem, that would be 15510, indicates that this is the answer in decimal. The more you get used to converting from binary to decimal, the easier it will be for you to remember the powers of 2, and the faster the conversion becomes.
  7. Use this method to convert a binary number with commas to decimal. You can use this method even for binary numbers like 1,12. Just remember that numbers to the left of the comma are in units, as usual, numbers to the right of the comma are "half", or 1 x (1/2).
    • "1" to the left of the comma equates to 2, or 1. 1 to the right of the comma equates to 2, or, 5. Adding 1 plus, 5 gives 1.5, which is 1.12 when represented in decimal notation.
    advertisement

Method 2 of 2: Use the double method

  1. Write binary numbers. With this method, we do not use power. It makes it easier to do mental arithmetic on large numbers: for now, you just need to pay attention to the subtotal. First, write down the binary number you plan to convert using this duplication method. Take the example number 10110012. I will write this number down on paper.
  2. Starting from the left, duplicate the previous total and add the current digit. With 10110012, the leftmost digit is 1. The previous sum is 0 because we haven't started anything yet. You will have to double the previous total, 0, and add 1, the number you are considering. 0 x 2 + 1 = 1, so our new sum is 1.
  3. Duplicate the current total and add the next digit. Current sum is 1 and the current digit is 0. So, double 1 and add 0, we get: 1 x 2 + 0 = 2. The new sum is 2.
  4. Repeat the above step. Just continue like that. Duplicate your current total and add 1, the next digit. 2 x 2 + 1 = 5. The new sum is 5.
  5. Repeat the above step. Duplicate your current total, 5 and add 1, the next digit. 5 x 2 + 1 = 11. Your new total is 11.
  6. Repeat the above step. Duplicate your current total, 11, and add 0, the next digit. 2 x 11 + 0 = 22.
  7. Repeat next step. Duplicate your current total, 22 and add 0, the next digit. 22 x 2 + 0 = 44.
  8. Continue to double your current total and add the next digit until the end. Now we only have the last number left and we are almost done! All we have to do is take the current sum, 44, duplicate it and add 1, the last digit. 2 x 44 + 1 = 89. Done! We transferred 100110112 to 89, its decimal form.
  9. Write your answer with the base. Write your answer in the form 8910 To show that here, we are working with a base 10 decimal number.
  10. Use this method to convert words every base to decimal. Here, we double it because the given number has base 2. For another base, we simply replace 2 with that base. For example, for a number with base 37, you would replace "x 2" with "x 37". The result is always a decimal (base 10). advertisement

Advice

  • Practice. Try converting the binary numbers 110100012, 110012, and 111100012. They correspond to 209, respectively10, 2510, and 24110.
  • A personal computer pre-installed on Microsoft Windows can make the switch for you, but as a programmer you should have a good understanding of how. You can display the conversion options on your computer by opening the "View" menu and choosing "Scientific" or "Programmer". On Linux, you can use a personal computer.
  • Note: this article covers the calculation ONLY and does not talk about ASCII encoding.

Warning

  • This article uses unsigned binary numbers instead of signed numbers, static comma real numbers or floating point real numbers.