Mark Dickinson <[EMAIL PROTECTED]> wrote:

>On Sep 25, 8:55 am, Tim Roberts <[EMAIL PROTECTED]> wrote:
>> Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> >0.1 actually is
>>
>> >In [98]: '%.50f' % 0.1
>> >Out[98]: '0.10000000000000000555111512312578270211815834045410'
>> >?
>>
>> Actually, it's not.  Your C run-time library is generating random digits
>> after it runs out of useful information (which is the first 16 or 17
>> digits).  0.1 in an IEEE 784 double is this:
>>
>>      0.100000000000000088817841970012523233890533447265625
>
>I get (using Python 2.6):
>
>>>> n, d = 0.1.as_integer_ratio()
>>>> from decimal import Decimal, getcontext
>>>> getcontext().prec = 100
>>>> Decimal(n)/Decimal(d)
>Decimal('0.1000000000000000055511151231257827021181583404541015625')
>
>which is a lot closer to Marc's answer.  Looks like your float
>approximation to 0.1 is 6 ulps out.  :-)

Hmmph, that makes the vote 3 to 1 against me.  I need to go re-examine my
"extreme float converter".
-- 
Tim Roberts, [EMAIL PROTECTED]
Providenza & Boekelheide, Inc.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to