Message225309
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. |
|
Date |
User |
Action |
Args |
2014-08-14 19:19:14 | steven.daprano | set | recipients:
+ steven.daprano, tim.peters, mark.dickinson, skrah |
2014-08-14 19:19:14 | steven.daprano | link | issue22198 messages |
2014-08-14 19:19:14 | steven.daprano | create | |
|