Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Converting Decimal to Binary

  1. Sep 9, 2008 #1
    I'm trying to figure out how to convert from decimal to binary. I've read a few explanations but I still don't understand. Could someone please help?

    The method I've read about invloved dividing the number you want to convert, by 2 each time, and looking at the remainder.
  2. jcsd
  3. Sep 9, 2008 #2
    Go back to papers and find out how decimal and binary are related.
    you will find the answer for question yourself.
  4. Sep 9, 2008 #3


    User Avatar
    Science Advisor

  5. Sep 10, 2008 #4


    User Avatar

    an alternative method, if you have the means to do unsigned multiply of binary numbers, is to:

    1. start with the Most Significant Digit of the decimal input.
    2. initialize your binary accumulator to zero (then you may skip to step 4. if you like).
    3. multiply the binary accumulator by 10 (00001010 in base 2).
    4. add that digit, 0 to 9, to the binary accumulator.
    5. move to one less significant digit (right by one place in the decimal input number).
    6. if there are any remaining digits, loop back to step 3.
    7. if no remaining digits, you're done; converted number in binary accumulator.

    it's pretty easy to code that in C or assembly language.

    now, how 'bout a nice and clean way to convert binary to decimal? know how to do that?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook