correct me if I am wrong.

String convertFloatToBinary(float num) {
       String str = "";
       int numBeforeDecimal = (int)num;
       float decimalPart = num - (float)numBeforeDecimal;
       int sign=1;
       if (numBeforeDecimal < 0 ) sign = -1;
       if (sign < 0) str[str.length] = '-';
       while(numBeforeDecimal > 0) {
             str[str.length] = numBeforeDecimal % 2 + '0';
             numBeforeDecimal /= 2;
       }
       str[str.length] = '.';
       while (decimalPart > 0 && decimalPart < 1 && str.length < 64) {
            decimalPart *= 2;
            str[str.length] = (decimalPart - 0) + '0';
       }
       return str;
}

Thanks,
Immanuel

On Tue, May 24, 2011 at 12:15 PM, Naveen Kumar
<naveenkumarve...@gmail.com>wrote:

> http://kipirvine.com/asm/workbook/floating_tut.htm
>
>
>
> On Tue, May 24, 2011 at 12:09 PM, saurabh agrawal <saurabh...@gmail.com>wrote:
>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Cheers
> Naveen Kumar
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to