Mark Dickinson <dicki...@gmail.com> added the comment:
[Au Vo] > Python2 produces 10.0 as the answers for all of the above calculation. Can you double check this, and confirm which Python version and operating system you're using? Like others, I'm not seeing any difference between Python 2 and Python 3, and as far as I'm aware the implementation of `//` for floats hasn't changed between Python 2 and Python 3. There's no behavioural bug here: all operations are producing perfectly correctly rounded results, which is about as good as one could possibly hope for. And as Tim says: > In any case, none of this is going to change after 30 years ;-) It's surprising, sure, but it's correct, and I can't imagine any fudge that would make the two results match without introducing a horde of other weird corner cases. [Tim] > For Python 3 I had thought Guido agreed to change a % b for floats to > return an exact result (exactly equal to the mathematical a - q*b for > some mathematical integer q) such that abs(a % b) <= abs(b)/2, which > is most useful most often for floats. But that didn't happen. If it's any consolation, we do at least have `math.remainder` in Python 3.7, which does exactly this. Closing this issue. ---------- resolution: -> not a bug stage: -> resolved status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36028> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com