How to Convert from Decimal to Binary: 10 Steps

Table of contents:

How to Convert from Decimal to Binary: 10 Steps
How to Convert from Decimal to Binary: 10 Steps
Anonim

The decimal number system (based on ten) has ten possible values (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) for each place value. In contrast, the binary number system (based on two) has two possible values represented by 0 or 1 for each place value. Since the binary system is the internal language of computers, programmers must know how to convert from decimal to binary. Read on to learn how to master converting decimal to binary numbers.

Steps

Method 1 of 2: Division by two using the remainder

Convert_from_Decimal_to_Binary_Step_1
Convert_from_Decimal_to_Binary_Step_1

Step 1. Write the problem

For this example, we are going to convert the decimal number 15610 a binary number. Write the decimal number as the dividend inside a "long" division sign. Write the base of the system you want to convert to (in our case, "2" for binary number) as the divisor outside the division sign.

  • This method is much easier to understand when viewed on paper, and it is also much easier for beginners to do, since all you have to do is divide by two.
  • To avoid confusion before and after conversion, write the number of the base system you are going to work with as a subscript for each number. In this case, the decimal number will have a subscript of 10 and the binary equivalent will have a subscript of 2.
Convert_from_Decimal_to_Binary_Step_2
Convert_from_Decimal_to_Binary_Step_2

Step 2. Do the division

Write the answer (quotient) under the division sign, and write the remainder (0 or 1) to the right of the dividend.

Since we are dividing by 2, when the dividend is an even number, the remainder will be 0, and when the dividend is an odd number the binary remainder will be 1

Convert_from_Decimal_to_Binary_Step_3
Convert_from_Decimal_to_Binary_Step_3

Step 3. Continue dividing until the result is 0

Continue down the page, dividing each new quotient by two and writing the remainder to the right of each dividend. Stop when the quotient is 0.

Convert_from_Decimal_to_Binary_Step_4
Convert_from_Decimal_to_Binary_Step_4

Step 4. Write the binary number you got

Starting from the last residue, read the sequence of residues up to the first. In our example, you should have 10011100. That is the binary equivalent of the decimal number 156. Or, written with the subscripts of the bases: 15610 = 100111002.

This method can be modified to convert from decimal number to number in any base type. The divisor is 2 because we wanted to convert to base 2 (binary) system. If you want to work with a different base system, replace the 2 in the above method with the number of the base system you want to convert to. For example, if you want to convert to base 9 system, replace 2 with 9. The final result will be expressed in the base you want

Method 2 of 2: Subtraction and Descending Powers of Two

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

Step 1. Make a table

Write the powers of two in a "base of 2 table" from right to left. Starts with 20, assigning it a value of "1". Increase the exponent by one for each power. Continue through the table until you reach the number closest to the decimal number you want to convert. For this example, we are going to convert the decimal number 15610 a binary number.

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

Step 2. Find the greatest power of 2

Choose the largest number that will fit in the number you are converting. 128 is the greatest power of two that goes into 156, so write a 1 under the 156 box on your table. Then subtract 128 from your starting number. You are now 28.

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

Step 3. Move to the nearest power of two

Using the new number (28), move across the table marking how many times each power of two fits in your dividend. 64 doesn't go into 28, so write a 0 under the 64 box. Keep going until you get to a number that Yes fit in 28.

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

Step 4. Subtract each successive number that will fit into the dividend, and mark it with a 1

16 goes into 28, so write 1 under the 16 box and subtract it from 28. Now you have 12. 8 goes into 12, so write 1 under the 8 box and subtract it from 12. You now have 4.

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

Step 5. Continue until you reach the end of the table

Remember to mark with a 1 each number that fits in the dividend you obtain, and mark with a 0 those numbers that do not meet this condition.

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

Step 6. Write the binary answer

The number in binary is the row that is formed by the cells of 1 and 0 under the powers of two. You should have the result 10011100. That's the binary equivalent of the decimal number 156. Or, written with the base subscripts: 15610 = 100111002.

Repeating this method will help you memorize the powers of two, allowing you to skip the first step

Advice

  • It is generally easier to learn to convert in the opposite way, from binary to decimal.
  • The calculator that comes installed with your computer's operating system can perform the conversion, but as a programmer, you'd better have a good understanding of how the conversion works. You can open the calculator's conversion options by opening the "View" menu and selecting "Developer."
  • Practice. Try to convert the decimal numbers 17810, 6310, and 810. Their decimal equivalents are 101100102, 1111112, and 10002. Try to convert 20910, 2510, and 24110 to their respective binaries, 110100012, 110012, and 111100012.

Popular by topic