all Python 3Exceptionsexception
FloatingPointError
built-in exceptions
A floating-point operation failed; not raised by default in CPython but part of the hierarchy.
Syntax
raise FloatingPointError
In modern CPython this exception is essentially dead: the fpectl module that enabled it was removed in 3.7, and ordinary arithmetic never raises it. Real floating-point trouble arrives under other names — ZeroDivisionError for division by zero, OverflowError for a result too large, ValueError from math.sqrt(-1), while a NaN simply propagates silently. An except FloatingPointError branch in student code will never fire; test results with math.isnan() and math.isinf() instead.
Examples
try:
raise FloatingPointError
except FloatingPointError as e:
print(type(e).__name__) # → FloatingPointError
See also
Open in the full glossarydocs.python.orgReport an inaccuracy