8000 GH-100425: Improve accuracy of builtin sum() for float inputs by rhettinger · Pull Request #100426 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-100425: Improve accuracy of builtin sum() for float inputs #100426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Dec 23, 2022
Merged
Prev Previous commit
Next Next commit
Remove out of date example for fsum()
  • Loading branch information
rhettinger committed Dec 22, 2022
commit 66db9377f5c0317149b9c3c1bd31b68d449a92ae
7 changes: 1 addition & 6 deletions Doc/library/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,7 @@ Number-theoretic and representation functions
.. function:: fsum(iterable)

Return an accurate floating point sum of values in the iterable. Avoids
loss of precision by tracking multiple intermediate partial sums:

>>> sum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1])
0.9999999999999999
>>> fsum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1])
1.0
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. On some non-Windows
Expand Down
0