[Python-Dev] Python 2.6/3.0, IEEE 754 floating point semantics and S60

Mark Dickinson dickinsm at gmail.com
Thu Nov 27 20:27:03 CET 2008


Torne,

Many thanks for your input!

> IEEE 754 doesn't include string formatting or parsing as far as I know,
> so I think this is irrelevant to whether we are compliant :)

I think IEEE 754 is relevant. :-)

There's a section 5.6 in the original 1985 standard that's called
something like:  "Binary <-> Decimal conversion" that covers
this.  If I'm reading it right (and I'm far from sure that I am), it
seems to say that for doubles one has to provide decimal
output up to 17 significant digits, but that digits beyond the
17th don't have to be accurate.  It also requires that the output is
correctly rounded for some subrange of the range of all doubles,
and there are weaker accuracy requirements for doubles outside
this subrange.

I think the updated 2008 version of the standard is somewhat
stricter, requiring correct rounding for conversions to and from
decimal in all cases.

> Does *any* standard actually promise that roundtripping will work, or is
> it just assumed?

I believe that roundtripping is a consequence of the 'correct
rounding' requirements in IEEE 754-2008, rather than a
direct requirement.  It might also be a consequence of the
weaker IEEE 754-1985 requirements, but I'm not sure.

Mark


More information about the Python-Dev mailing list