Message 335898 - Python tracker

Message335898

Author mark.dickinson
Recipients Au Vo, mark.dickinson, remi.lapeyre, rhettinger, skrah, steven.daprano, tim.peters
Date 2019-02-19.08:16:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1550564161.94.0.657358496305.issue36028@roundup.psfhosted.org>
In-reply-to
Content
[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.
History
Date User Action Args
2019-02-19 08:16:01mark.dickinsonsetrecipients: + mark.dickinson, tim.peters, rhettinger, steven.daprano, skrah, remi.lapeyre, Au Vo
2019-02-19 08:16:01mark.dickinsonsetmessageid: <1550564161.94.0.657358496305.issue36028@roundup.psfhosted.org>
2019-02-19 08:16:01mark.dickinsonlinkissue36028 messages
2019-02-19 08:16:01mark.dickinsoncreate