How to Convert from Decimal to Binary

As Piseth my friends just walk in to IT Subject, He ask me how to convert from Decimal to Binary or Binary to Decimal. I’ve left it for long time ago, So I might be forget how to do it. Hope this article will help you or me to do it again.

The decimal (base ten) numeral system has ten possible values (0,1,2,3,4,5,6,7,8, or 9) for each place-value. In contrast, the binary (base two) numeral system has two possible values, often represented as 0 or 1, for each place-value.

To avoid confusion while using different numeral systems, the base of each individual number may be specified by writing it as a subscript of the number. For example, the decimal number 156 may be written as 15610 and read as “one hundred fifty-six, base ten”. The binary number 10011100 may be specified as “base two” by writing it as 100111002.

Since the binary system is the internal language of electronic computers, serious computer programmers should understand how to convert from decimal to binary. Although, converting in the opposite direction, from binary to decimal, is often easier to learn first.

Choose a method of conversion

  • Comparison with descending powers of two and subtraction
  • Short division by two with remainder

Comparison with descending powers of two and subtraction

  1. List the powers of two in a “base 2 table” from right to left. Start at 20, evaluating it as “1”. Increment the exponent by one for each power. The list, to ten elements, would look like this: 512, 256, 128, 64, 32, 16, 8, 4, 2, 1
  2. For this example, let’s convert the decimal number 15610 to binary. What is the greatest power of two that will fit into 156? Since 128 fits, write a 1 for the leftmost binary digit, and subtract 128 from your decimal number, 156. You now have 28.
  3. Move to the next lower power of two. Can 64 fit into 28? No, so write a 0 for the next binary digit to the right.
  4. Can 32 fit into 28? No, so write a 0.
  5. Can 16 fit into 28? Yes, so write a 1, and subtract 16 from 28. You now have 12.
  6. Can 8 fit into 12? Yes, so write a 1, and subtract 8 from 12. You now have 4.
  7. Can 4 (power of two) fit into 4 (working decimal)? Yes, so write a 1, and subtract 4 from 4. You have 0.
  8. Can 2 fit into 0? No, so write a 0.
  9. Can 1 fit into 0? No, so write a 0.
  10. Since there are no more powers of two in the list, you are done. You should have 10011100. This is the binary equivalent of the decimal number 156. Or, written with base subscripts: 15610 = 100111002
Here is the example of this method written on a piece of paper.  The steps are labeled "A" through "L".

Here is the example of this method written on a piece of paper. The steps are labeled “A” through “L”.

Repetition of this method will result in memorization of the powers of two, which will allow you to skip step 1.

Short division by two with remainder

This method is much easier to understand when visualized on paper. It relies only on division by two.

  1. For this example, let’s convert the decimal number 15610 to binary. Write the decimal number as the dividend inside an upside-down “long division” symbol. Write the base of the destination system (in our case, “2” for binary) as the divisor outside the curve of the division symbol.2)156
  2. Write the integer answer (quotient) under the long division symbol, and write the reminader (0 or 1) to the right of the dividend.2)156 0
    78
  3. Continue downwards, dividing each new quotient by two and writing the remainders to the right of each dividend. Stop when the quotient is 1.2)156 0
    2)78 0
    2)39 1
    2)19 1
    2)9 1
    2)4 0
    2)2 0
    1
  4. Starting with the bottom 1, read the sequence of 1’s and 0’s upwards to the top. You should have 10011100. This is the binary equivalent of the decimal number 156. Or, written with base subscripts: 15610 = 100111002

2 thoughts on “How to Convert from Decimal to Binary

ឆ្លើយ​តប

Fill in your details below or click an icon to log in:

ឡូហ្កូ WordPress.com

អ្នក​កំពុង​បញ្ចេញ​មតិ​ដោយ​ប្រើ​គណនី WordPress.com របស់​អ្នក​។ Log Out / ផ្លាស់ប្តូរ )

រូប Twitter

អ្នក​កំពុង​បញ្ចេញ​មតិ​ដោយ​ប្រើ​គណនី Twitter របស់​អ្នក​។ Log Out / ផ្លាស់ប្តូរ )

រូបថត Facebook

អ្នក​កំពុង​បញ្ចេញ​មតិ​ដោយ​ប្រើ​គណនី Facebook របស់​អ្នក​។ Log Out / ផ្លាស់ប្តូរ )

Google+ photo

អ្នក​កំពុង​បញ្ចេញ​មតិ​ដោយ​ប្រើ​គណនី Google+ របស់​អ្នក​។ Log Out / ផ្លាស់ប្តូរ )

កំពុង​ភ្ជាប់​ទៅ​កាន់ %s