summaryrefslogtreecommitdiffstats
path: root/Doc/library/math.rst
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2008-07-30 20:23:15 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2008-07-30 20:23:15 (GMT)
commit23957cb8fb4289a11f55d46c3fa01938ff01dbea (patch)
tree37a2dc413085963981ff3890cfb044018e8d48c3 /Doc/library/math.rst
parent67ebfefef550a28af98f022b35af912ecc3e6e4a (diff)
downloadcpython-23957cb8fb4289a11f55d46c3fa01938ff01dbea.zip
cpython-23957cb8fb4289a11f55d46c3fa01938ff01dbea.tar.gz
cpython-23957cb8fb4289a11f55d46c3fa01938ff01dbea.tar.bz2
Add note about problems with math.fsum on x86 hardware.
Diffstat (limited to 'Doc/library/math.rst')
-rw-r--r--Doc/library/math.rst26
1 files changed, 26 insertions, 0 deletions
diff --git a/Doc/library/math.rst b/Doc/library/math.rst
index 5740759..6f8d3c8 100644
--- a/Doc/library/math.rst
+++ b/Doc/library/math.rst
@@ -90,6 +90,32 @@ Number-theoretic and representation functions:
algorithm's accuracy depends on IEEE-754 arithmetic guarantees and the
typical case where the rounding mode is half-even.
+ .. note::
+
+ On platforms where arithmetic results are not correctly rounded,
+ :func:`fsum` may occasionally produce incorrect results; these
+ results should be no less accurate than those from the builtin
+ :func:`sum` function, but nevertheless may have arbitrarily
+ large relative error.
+
+ In particular, this affects some older Intel hardware (for
+ example Pentium and earlier x86 processors) that makes use of
+ 'extended precision' floating-point registers with 64 bits of
+ precision instead of the 53 bits of precision provided by a C
+ double. Arithmetic operations using these registers may be
+ doubly rounded (rounded first to 64 bits, and then rerounded to
+ 53 bits), leading to incorrectly rounded results. To test
+ whether your machine is one of those affected, try the following
+ at a Python prompt::
+
+ >>> 1e16 + 2.9999
+ 10000000000000002.0
+
+ Machines subject to the double-rounding problem described above
+ are likely to print ``10000000000000004.0`` instead of
+ ``10000000000000002.0``.
+
+
.. versionadded:: 2.6