[Python-checkins] r69760 - python/branches/release30-maint/Doc/library/math.rst

raymond.hettinger python-checkins at python.org
Thu Feb 19 06:49:53 CET 2009


Author: raymond.hettinger
Date: Thu Feb 19 06:49:53 2009
New Revision: 69760

Log:
Add an example for math.fsum() and elaborate on the accurary note.

Modified:
   python/branches/release30-maint/Doc/library/math.rst

Modified: python/branches/release30-maint/Doc/library/math.rst
==============================================================================
--- python/branches/release30-maint/Doc/library/math.rst	(original)
+++ python/branches/release30-maint/Doc/library/math.rst	Thu Feb 19 06:49:53 2009
@@ -80,14 +80,18 @@
 .. function:: fsum(iterable)
 
    Return an accurate floating point sum of values in the iterable.  Avoids
-   loss of precision by tracking multiple intermediate partial sums.  The
-   algorithm's accuracy depends on IEEE-754 arithmetic guarantees and the
-   typical case where the rounding mode is half-even.
+   loss of precision by tracking multiple intermediate partial sums::
 
-   .. note::
-
-      The accuracy of fsum() may be impaired on builds that use
-      extended precision addition and then double-round the results.
+        >>> sum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1])
+        0.99999999999999989
+        >>> fsum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1])
+        1.0
+
+   The algorithm's accuracy depends on IEEE-754 arithmetic guarantees and the
+   typical case where the rounding mode is half-even.  On some non-Windows
+   builds, the underlying C library uses extended precision addition and may
+   occasionally double-round an intermediate sum causing it to be off in its
+   least significant bit.
 
 
 .. function:: isinf(x)


More information about the Python-checkins mailing list