mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
GH-100425: Improve accuracy of builtin sum() for float inputs (GH-100426)
This commit is contained in:
parent
1ecfd1ebf1
commit
5d84966cce
6 changed files with 45 additions and 8 deletions
|
|
@ -192,7 +192,7 @@ added onto a running total. That can make a difference in overall accuracy
|
|||
so that the errors do not accumulate to the point where they affect the
|
||||
final total:
|
||||
|
||||
>>> sum([0.1] * 10) == 1.0
|
||||
>>> 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 == 1.0
|
||||
False
|
||||
>>> math.fsum([0.1] * 10) == 1.0
|
||||
True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue