Elias Zamaria <mikez...@gmail.com> added the comment:

Mark, I tried `Fraction(10**23) // 1e22`, and I got 10.

Your `10**23 // 1e22` example was strange, but then `int(1e23)` and got 
99999999999999991611392. That is kind of unexpected but I think it is rare for 
anyone to do something like that with numbers that big.

I think the fact that floating-point rounding error sometimes causes strange 
results is not a reason to do really unexpected things like making 1.0 // 1/10 
equal 9.0, if that can be reasonably avoided.

I updated my pull request with my change, which you suggested, to make 
__rfloordiv__ and __rmod__ return a float, but with a small change to 
_operator_fallbacks to avoid the rounding error, so 1.0 // 1/10 is 10.0. You 
can see it at 
https://github.com/python/cpython/pull/5956/commits/1020bb219c1a4fad575ee2309c930ce82a4777fb#diff-14d03bfb59581367725b00781e6f802fL391.
 What do you think?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32968>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to