[Python-Dev] Deprecating float.is_integer() (original) (raw)

Devin Jeanpierre jeanpierreda at gmail.com
Wed Mar 21 21:17:58 EDT 2018


[Mark Dickinson <dickinsm at gmail.com> ]

If you have a moment to share it, I'd be interested to know what value of x you used to achieve this, and what system you were on. This can't happen under IEEE 754 arithmetic. I expect it might happen under one of the directed rounding modes (like "to +infinity").

PyPy (5.8):

x = 1e300 x.isinteger() True math.sqrt(x**2).isinteger() False x**2 inf

(It gives an OverflowError on my CPython installs.)

I believe this is allowed, and Python is not required to raise OverflowError here: https://docs.python.org/3.6/library/exceptions.html#OverflowError says:

for historical reasons, OverflowError is sometimes raised for integers that are outside a required range. Because of the lack of standardization of floating point exception handling in C, most floating point operations are not checked

-- Devin



More information about the Python-Dev mailing list