Surprise with special floating point values

prouleau001 at gmail.com prouleau001 at gmail.com
Wed Nov 29 20:26:40 CET 2006



On Nov 29, 1:11 pm, Fredrik Lundh <fred... at pythonware.com> wrote:
> prouleau... at gmail.com wrote:
> > While trying to use simplejson under Python 2.4.3 I have been
> > investigating the handling of special floating point valuesnote that JSON doesn't support non-numeric floating point values, as can
> be seen by the "number" syntax description on this page:
>
>      http://www.json.org/
>
> (and as I pointed out in another thread on this topic, Python relies on
> the C library for serialization of floats, so non-numeric floating point
> values aren't portable between Python versions either).
>
> </F>

That's true, but I ran into a problem with simplejson under Python
2.4.3 on Win32, where it fails to serialize 1.0 properly (and  I
reported the problem to its author, and the fact that it works fine
under Python 2.5).  There is another thread (Inconsistency producing
constant for float "infinity") that talks about differences between
Python 2.5 and earlier versions regarding treatment of non-numeric
floating point values.  So, while investigating the simplejson problem,
I though I had found a problem with the handling of NaN (which
obviously is not the case).

- Pierre R.




More information about the Python-list mailing list