How to Convert Decimal to Binary

Author: John Stephens
Date Of Creation: 1 January 2021
Update Date: 29 June 2024
Anonim
How To Convert Decimal to Binary
Video: How To Convert Decimal to Binary

Content

The decimal factor (base-ten) has ten values ​​(0,1,2,3,4,5,6,7,8, or 9) for each value. In contrast, the binary system (hexadecimal system) has two representations of 0 and 1 for each. Since binary is the intrinsic language used in electronic computers, computer programmers should understand how to convert from decimal to binary. Follow these simple steps to see how to convert.

Steps

Method 1 of 2: Short Division by Two with Balances

  1. Problem solving. For this example we will convert decimal 15610 to binary. Write the decimal number as the divisor within the long division symbol. Record the coefficient of the target system (in our case, write the number "2" for the binary system) as the divisor outside the curve of the long division symbol.
    • This method is easier to understand when describing on paper, and a lot easier for the beginners, because it only relies on division by two.
    • To avoid confusion before and after the conversion, write the base system number you are working on under each number. In this case, the decimal will have an subscript of 10, and the equivalent binary number will have an subscript of 2.

  2. Division. Write the quotient below the long division symbol, and write the remainder (0 or 1) to the right of the divisor.
    • Since we divide by 2, when the divided number is an even number, the binary remainder becomes 0, and when the divisor is an odd number the binary remainder becomes 1.

  3. Continue division until the result of division by 2 is zero. Continuing the division down, divide the new quotient by two, and write the remainder to the right of the division. Stop when the quotient is 0.
  4. Write a new binary number. Starting with the balance at the bottom, sequence the balance from bottom to top. As in this example, you will get the result 10011100. This is the binary equivalent of the decimal number 156. Or it can be written as subscript each: 15610 = 100111002
    • This method can be adjusted to convert from decimal to 'any' system. Divisor is 2 because the system you want to convert is system 2 (binary). If the conversion system is another system, replace the divisor 2 in the calculation with the system you want to convert. For example, if the system you want to convert is 9, replace the divisor 2 with 9. The final result will be the system you want to convert.
    advertisement

Method 2 of 2: Descending Power and Subtraction


  1. Start by making a table. List the powers of two in a "factor table of 2" from right to left. Starting at 2, has the value "1". Increase exponent by one for each power. Create a sequence of powers until you get to the number that is close to the decimal you are starting with. In this example, we will convert the decimal number 15610 to binary.
  2. Find the largest power of 2. Choose the largest number that matches the number you are converting. 128 is the largest power of 2 that matches 156, write the number 1 below this cell in your spreadsheet as the binary in the bottom left. Subtract 128 from the original number. You will get 28.
  3. Switch to the powers of the next two smaller. Using the new number (28), move down to the spreadsheet to mark the power 2 that can match the number to be divided. 64 is greater than 28, write a 0 below that cell as the next binary on the right. Continue until you find the number that "might" cover the number 28.
  4. Subtract the next number that might match, and mark it with 1. 16 could match 28, so you would write 1 below that box and subtract 28 from 16. You will get 12. 8 matches 12, so write 1 below box 8 and subtract 12 from 8. You will get 4.
  5. Continue until you finish your spreadsheet. Check 1 below the number included in the new number, and write 0 under the cells that are larger than the new number.
  6. Write the result in binary number. The binary numbers are 1 and 0 below the spreadsheet from left to right. You will have the binary number 10011100. This is the binary number that corresponds to the decimal number 156. Or it can be written as subscript each: 15610 = 100111002.
    • Repeating this method will help memorize the powers of 2, allowing you to skip step 1.
    advertisement

Advice

  • The computer installed in your operating system can do this for you, but as a programmer, you should have a clear understanding of how to convert.You can view your computer's conversion options by opening the "View" menu item on the toolbar and selecting "Programmer".
  • Converting backwards, from binary to decimal, is often easier to learn first.
  • Practice. Try converting to decimal 17810, 6310, and 810. The corresponding binary number is 101100102, 1111112, and 10002. Try converting 20910, 2510, and 24110 to the corresponding binary number 110100012, 110012, and 111100012.