Bug in floating point multiplication
Laurent Pointal
laurent.pointal at free.fr
Thu Jul 2 17:12:32 EDT 2015
Steven D'Aprano wrote:
> Despite the title, this is not one of the usual "Why can't Python do
> maths?" "bug" reports.
>
> Can anyone reproduce this behaviour? If so, please reply with the version
> of Python and your operating system. Printing sys.version will probably
> do.
<zip>
On Kubuntu 15.04, it works.
Python 3.4.3 (default, Mar 26 2015, 22:03:40)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> x = 1 - 1/2**53
>>> assert x == 0.9999999999999999
>>> for i in range(1, 1000000):
... if int(i*x) == i:
... print(i); break
...
>>>
A+
Laurent.
More information about the Python-list
mailing list