Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f3936f87
Commit
f3936f87
authored
Feb 19, 2009
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an example for math.fsum() and elaborate on the accurary note.
parent
cdf8ba36
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
+12
-8
Doc/library/math.rst
Doc/library/math.rst
+12
-8
No files found.
Doc/library/math.rst
View file @
f3936f87
...
@@ -80,14 +80,18 @@ Number-theoretic and representation functions
...
@@ -80,14 +80,18 @@ Number-theoretic and representation functions
.. function:: fsum(iterable)
.. function:: fsum(iterable)
Return an accurate floating point sum of values in the iterable. Avoids
Return an accurate floating point sum of values in the iterable. Avoids
loss of precision by tracking multiple intermediate partial sums. The
loss of precision by tracking multiple intermediate partial sums::
algorithm's accuracy depends on IEEE-754 arithmetic guarantees and the
typical case where the rounding mode is half-even.
>>> sum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1])
0.99999999999999989
.. note::
>>> fsum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1])
1.0
The accuracy of fsum() may be impaired on builds that use
extended precision addition and then double-round the results.
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)
.. function:: isinf(x)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment