This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients David Hwang, steven.daprano, tim.peters
Date 2020-02-02.05:54:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1580622852.64.0.660150619429.issue39525@roundup.psfhosted.org>
In-reply-to
Content
Arguments to `remainder()` are converted to floats, and the returned value is also a float.  These specific arguments convert to the same float:

>>> a = 12345678901234567890
>>> b = 12345678901234567891
>>> float(a) == float(b)
True

And the float they convert _to_ retains only the 53 most-significant bits of the inputs:

>>> int(float(b))
12345678901234567168
>>> c = _
>>> c.bit_length()
64
>>> bin(c)
'0b1010101101010100101010011000110011101011000111110000100000000000'

Note that the last 11 bits are zeroes, and 64 - 11 = 53.

So this is all doing what it's intended to do, and won't be changed.

I'm leaving this open, though, in case someone thinks the docs should be clarified.  But the same things apply to _many_ functions in the `math` module:  unless the docs specifically say they work with integer arguments, integer arguments are converted to float.

Oops!  Someone else already closed this while I was typing.  That's fine by me too ;-)
History
Date User Action Args
2020-02-02 05:54:12tim.peterssetrecipients: + tim.peters, steven.daprano, David Hwang
2020-02-02 05:54:12tim.peterssetmessageid: <1580622852.64.0.660150619429.issue39525@roundup.psfhosted.org>
2020-02-02 05:54:12tim.peterslinkissue39525 messages
2020-02-02 05:54:12tim.peterscreate