curious problem with large numbers

Scott David Daniels Scott.Daniels at Acm.Org
Fri Apr 8 13:18:05 EDT 2005


Bengt Richter wrote:
>>Aha! Same version (2.3.4):
>>
>>Idle:
>>    >>> 1e10000
>>    1.0
>>    >>> import struct; struct.pack('d', 1e10000)
>>    '\x00\x00\x00\x00\x00\x00\xf0?'
>>(which is actually 1.0)
>>
>>python via command line (readline support):
>>    >>> 1e10000
>>    1.#INF
>>    >>> import struct; struct.pack('d', 1e10000)
>>    '\x00\x00\x00\x00\x00\x00\xf0\x7f'
>>
>>Note the difference in the final byte.  Same results (command
>>line vs. Idle) for 2.4.1.
>>

> Good aha, but ISTM one of them is more missing than different ;-)
> (I.e., returned packed string is length 7 vs 8)
In the first one, the final byte is '?' (I made the same mistake
myself when I first read it).

Also note:

     float('1e10000') is 1.#INF both in Idle and from the command line.

I suspect an Idle bug.


--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list