Steven D'Aprano added the comment: 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. ---------- nosy: +steven.daprano _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22198> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com