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 steven.daprano
Recipients mark.dickinson, skrah, steven.daprano, tim.peters
Date 2014-08-14.19:19:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <20140814191858.GW4525@ando>
In-reply-to <1408034861.79.0.503776123394.issue22198@psf.upfronthosting.co.za>
Content
On Thu, Aug 14, 2014 at 04:47:41PM +0000, Mark Dickinson wrote:

> I'm not sure it's worth fixing this, but it seems worth recording:
> 
> >>> -0.5 // float('inf')
> -1.0
> 
> I was expecting a value of `-0.0`, and while IEEE 754 doesn't cover 
> the floor division operation, I'm reasonably confident that that's the 
> value it would have recommended if it had. :-)

Hmmm. I'm not so sure. -0.5 // something_really_big gives -1:

py> -0.5//1e200
-1.0

Consider something_really_big as it gets bigger and bigger and 
approaches infinity, if we *informally* take the limit -> inf I think it 
makes sense for it to return -1. Another way of looking at it is that 
-0.5/inf returns a negative infinitesimal quantity, and then taking the 
floor returns -1. So I think the current behaviour is "correct", for 
some definition of correct.

The alternative is a discontinuity, where -0.5//x = -1 for all finite 
but huge x and then suddenly 0 when x overflows to infinity. That's 
probably a bad idea.
History
Date User Action Args
2014-08-14 19:19:14steven.dapranosetrecipients: + steven.daprano, tim.peters, mark.dickinson, skrah
2014-08-14 19:19:14steven.dapranolinkissue22198 messages
2014-08-14 19:19:14steven.dapranocreate