Inverse confusion about floating point precision

Tim Peters tim.peters at gmail.com
Mon May 9 14:50:45 EDT 2005


[Dan] 
>    Dan> The floating-point representation of 95.895 is exactly
>    Dan> 6748010722917089 * 2**-46.

[Skip Montanaro]
> I seem to recall seeing some way to extract/calculate fp representation from
> Python but can't find it now.  I didn't see anything obvious in the
> distribution.

For Dan's example,

>>> import math
>>> math.frexp(95.895)
(0.74917968749999997, 7)
>>> int(math.ldexp(_[0], 53))
6748010722917089L



More information about the Python-list mailing list