Variables different between .py and .pyc

Joshua Marshall jmarshal at mathworks.com
Mon May 7 22:30:27 EDT 2001


Tim Peters <tim.one at home.com> wrote:
>> My variables are truncated at ~12 decimal points of precision.

> Yup, and that's disgusting.  This is apparently the cause:

>>>> eval(str(3.1415926535897931))
> 3.1415926535900001
>>>>

> That is, marshal stores floats as strings after %.12g conversion (which is
> what str() uses).  If Guido doesn't object, I'm going to change marshal to
> use repr() conversion instead (which uses %.17g conversion, which is enough
> digits to reproduce finite IEEE-754 doubles exactly, assuming high-quality
> platform C string<->double I/O).

Why was the decision made to store floats with %g instead of storing
the raw bits directly?



More information about the Python-list mailing list