Issue 3222: inf*inf gives inf, but inf**2 gives overflow error (original) (raw)

This is a known problem, that's unlikely to change unless there's a serious overhaul of Python's floating point.

The warning at the end of the math module documentation should probably be taken to apply equally to all the built-in floating-point operations:

"""The math module consists mostly of thin wrappers around the platform C math library functions. Behavior in exceptional cases is loosely specified by the C standards, and Python inherits much of its math- function error-reporting behavior from the platform C implementation. As a result, the specific exceptions raised in error cases (and even whether some arguments are considered to be exceptional at all) are not defined in any useful cross-platform or cross-release way. For example, whether math.log(0) returns -Inf or raises ValueError or OverflowError isn't defined, and in cases where math.log(0) raises OverflowError, math.log(0L) may raise ValueError instead."""

Or, as Tim Peters is fond of saying:

"""All Python behavior in the presence of infinities, NaNs, and signed zeroes is a platform-dependent accident, mostly inherited from that all C89 behavior in the presence of infinities, NaNs, and signed zeroes is a platform-dependent crapshoot."""