Skip to content
Prev Previous commit
Next Next commit
Compare sum() and fsum() with straight addition
  • Loading branch information
rhettinger committed Feb 19, 2023
commit cd8abc516370508654387097cafeb1032e3eed38
6 changes: 6 additions & 0 deletions Doc/tutorial/floatingpoint.rst
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ each other out leaving a final sum near zero:
8.042173697819788e-13
>>> sum(arr) # Multiple roundings in extended precision
8.042178034628478e-13
>>> total = 0.0
>>> for x in arr:
... total += x # Multiple roundings in standard precision
...
>>> total # Straight addition has no correct digits!
-0.0051575902860057365


.. _tut-fp-error:
Expand Down