On Thu, Sep 18, 2014 at 05:59:02PM +0200, Petr Viktorin wrote: [...]
Sorry? If you've studied mathematics you'd know there's no discrete value that is the same as infinity. I'm not even sure how anyone could begin define floor(infinity). Infinity is not present in any discrete set. Yes float('inf') / 1 should be float('inf'), no one is arguing that. That's easily shown through limits. floor(float('inf') / 1) has no intrinsic meaning. Discrete sets such as the naturals, integers, and rationals are all "countably infinite" but there's no bijective mapping between them and the real numbers (and therefore, no such mapping to the complex numbers) because the are uncountably infinite real numbers.
There is even no *real* number that is the same as infinity.
Correct. Once we start talking about a value representing infinity, we're being impure and mathematically dubious, regardless of whether we have ints or floats.
But more than that, an IEEE-754 infinity doesn't just represent mathematical infinity, but also finite numbers which overflowed. Hence:
py> 1.7976931348623157e+308 * 1.1 inf
I don't think it is clear what inf//1 should return, which suggests to me that returning a NAN is perhaps less wrong than returning inf. (If we really don't know how to interpret inf//1, then a NAN, or an exception, is the right answer.)
What I do care about is that Python and Numpy should give the same result. It would be nice to see this changed in either Python or Numpy, whatever the "correct" result is.
That is reasonable.