[Python-Dev] FP vs. tutorial

Guido van Rossum guido@digicool.com
Mon, 21 May 2001 18:33:17 -0400


> + Yes, I'm serious about not including tutorial examples with
>   platform-dependent output, unless they're explicitly meant to
>   illustrate non-portable code.

Sure.  Most examples can be rewritten to avoid platform-dependent
output.  But there should be one section on floating-point
inaccuracies that shows a few of the kind of things you can expect on
a typical platform, and 1.1 -> 1.1000000000000001 is pretty common.

> + Specific small examples notwithstanding, there is no uniformity
>   across platforms in the last digit or so, because not even the IEEE-
>   754 standard requires that (while C is much sloppier than 754), and
>   vendors generally don't implement anything better than the minimum
>   necessary when it comes to f.p. (Sun is a notable exception).

So we'll have to add something like "the actual inexact output you see
may differ from the inexact output in this example".

> + Happy to add text explaining the existence of surprises, and
>   providing a URL.  Do the floating-point morons <wink> on Python-Dev
>   find this one comprehensible?:
> 
>     http://www.lahey.com/float.htm

I was thinking more of immortalizing this one:

http://www.python.org/cgi-bin/moinmoin/RepresentationError

This can serve as a nice self-contained section on f.p. surprises.

--Guido van Rossum (home page: http://www.python.org/~guido/)