converting decimal fraction to binary

Discussion in 'Math' started by PG1995, Oct 9, 2011.

  1. PG1995

    Thread Starter Active Member

    Apr 15, 2011
    753
    5
    Hi

    I'm learning to convert decimal fractions into their binary equivalent.

    1: After the decimal point 2's powers are in negative: 2^-1, 2^-2, 2^-3, ...; and this is equivalent to: 0.5, 0.25, 0.125, ....

    Let's say we want to convert 0.625 into its a binary fraction.

    If we subtract "0.5" or "2^-1" from 0.625 we are left with 0.125 and "0.125" can be represented by 2^-3.

    Therefore,
    0.625 = 0.5 + 0 + 0.125 = 0.101

    The above example was found in a book. Suppose, we have 0.620 instead. How would we convert it into a binary fraction using the method we used above? How do I use this method so that I can deal with any given decimal number?

    2: I know there is another method of repeated multiplication by 2. Though this method seems simple but it's not that much natural. Please have a look on the linked scan (or, you can check the attachment):
    http://img809.imageshack.us/img809/4655/imgus.jpg

    I have tried to apply repeated multiplication method to convert a decimal fraction to a binary one. In case of 0.3125 I was successful but then I tried to apply it on 0.620 without any success. It seems the method would never end.

    Please help me.

    Regards
    PG
     
    • IMG.jpg
      IMG.jpg
      File size:
      216.3 KB
      Views:
      85
  2. Papabravo

    Expert

    Feb 24, 2006
    10,142
    1,790
    0.620 may not have an exact binary representation. You can however get arbitrarily close to 0.620 it is just a question of how many places you want to work with and weather you choose to be above 0.620 or below 0.620

    My conjecture is that if you take any decimal number and write it as a fraction, then factor the numerator and denominator into prime factors, then cancel the common factors. You must end up with only twos in the denominator to have an exact representation.
    Code ( (Unknown Language)):
    1.  
    2. 0.620 = 620 / 1000 = (2*2*5*31) / (2*2*2*5*5*5) = 31 / (2*5*5) = 31 / 50
    3.  
    since there is a pair of 5's left in the denominator 0.620 does not have an exact representation and any algorithm you employ witll fail to terminate as you have already observed.
     
    Last edited: Oct 9, 2011
    PG1995 likes this.
  3. PG1995

    Thread Starter Active Member

    Apr 15, 2011
    753
    5
    It seems now I understand how the method of repeated multiplication by 2 really works. Please check the attachment.

    To someone like me who stumbles onto this thread:
    The bases which have direct relationship with 2 such as 8, 16, 32, etc. can easily be converted between each other. For example, an octal number such as (562) can easily be converted into a binary one.

    562 = 5 6 2 = (101) (110) (010) = 101110010

    To see how this works please check the attachment.
     
    Last edited: Oct 9, 2011
  4. Papabravo

    Expert

    Feb 24, 2006
    10,142
    1,790
    Yup. Nothing has changed much since the introduction of "The New Math" more than 50 years ago.
     
Loading...