On Saturday, February 19, 2022, Stefan Pochmann <smpochmann@gmail.com> wrote:
1e200.is_integer() True
So that could losslessly be converted to int, and then the division would succeed
If the float argument isn't an integer, you can multiply both sides by a power of 2 that makes it one (if it's finite, obviously), so this would still work. Currently, int/int and float/float are always properly rounded. It would be nice if you could just say that a/b is properly rounded whenever a and b are int or float, and forget about conversion issues. So I'm +1 on this. It would make certain divisions more expensive than they currently are, but only those where one argument is float and the other is an int that isn't exactly representable as a float (meaning, in particular, its absolute value is greater than 2**53). It seems unlikely to me that anyone is doing a lot of divisions of that kind and needs the speed, but if they are and do, casting to float beforehand is an easy workaround. Also, 10**400/float('inf') should return +0.0 instead of raising OverflowError, and 10**400/float('nan') should be NaN. The division should behave as though both arguments are promoted to arbitrary-precision floating point (but the result is rounded to 64-bit float). I wouldn't suggest that if it was hard to implement, but I think it's pretty easy when long_true_divide already exists.