[issue6387] floor division gives different result for int versus float.
Tim Peters
report at bugs.python.org
Tue Jun 30 13:08:17 CEST 2009
Tim Peters <tim.peters at gmail.com> added the comment:
Do you realize that 2**54-1 isn't exactly representable as a float? It
requires 54 bits of precision, but the Python float format only has 53
bits available (on all popular boxes).
>>> 2**54-1
18014398509481983L
>>> float(_) # rounds to closest representable float
18014398509481984.0
In fact, x//y == x//float(y) for only a small subset of integer x and y
values, mostly because only a small subset of integer x and y values are
exactly representable as floats (given that Python integers enjoy
unbounded precision, but floats only retain 53 bits).
----------
nosy: +tim_one
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6387>
_______________________________________
More information about the Python-bugs-list
mailing list