> [Mark Dickinson <dicki...@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.is_integer() True >>>> math.sqrt(x**2).is_integer() 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 _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com