on floating-point numbers
Peter Pearson
pkpearson at nowhere.invalid
Thu Sep 2 10:41:17 EDT 2021
On Thu, 02 Sep 2021 10:51:03 -0300, Hope Rouselle wrote:
>
>>>> import sys
>>>> sys.version
> '3.8.10 (tags/...
>
>>>> ls = [7.23, 8.41, 6.15, 2.31, 7.73, 7.77]
>>>> sum(ls)
> 39.599999999999994
>
>>>> ls = [8.41, 6.15, 2.31, 7.73, 7.77, 7.23]
>>>> sum(ls)
> 39.60000000000001
Welcome to the exciting world of roundoff error:
Python 3.5.3 (default, Jul 9 2020, 13:00:10)
[GCC 6.3.0 20170516] on linux
>>> 0.1 + 0.2 + 9.3 == 0.1 + 9.3 + 0.2
False
>>>
--
To email me, substitute nowhere->runbox, invalid->com.
More information about the Python-list
mailing list