On Tue, 10 Mar 2020 at 13:41, Chris Angelico <ros...@gmail.com> wrote: > It makes good sense for > division by 0 and division by 0.0 to both result in the same > exception.
But Python 3 returns a float, for example, in division between integers. 4 / 2 == 2.0. So some_integer / +0 should return +Infinity. This is what IEEE 754 says. Luckily Python does not adhere completely to IEEE 754. Furthermore, there's a precedence in Python: decimal. decimal.Decimal does not returns NaN in any of the operations that should return it: https://en.wikipedia.org/wiki/NaN#Operations_generating_NaN On the contrary, it returns decimal.InvalidOperation. @Alan Bawden: thank you for letting me know about William Kahan. I think it's analysis of IEEE 754 is very detailed, and I didn't know that traps exist. And yes, I agree that traps and exceptions slows down the computation. But in a language like Python, when simplicity and usability is a priority, and when "no exception should pass silently", IMHO operations that returns NaN are only an heritage from C, since Python is written in C. PS: I'm quoting import this with Tim Peters in the discussion, to Alan Bawden... It's like teaching physics to Fermi. -- https://mail.python.org/mailman/listinfo/python-list