don't NaN & infinities hide FP errors
Tim Peters
tim.peters at gmail.com
Wed Nov 17 08:49:13 EST 2004
[Peter Maas]
> Just try it. 1./0. raises a ZeroDivisionError,
That much is true -- Python forces this.
> math.log(0) raises a math range error, and math.log(-1) yields nan.
The rest varies across platforms, as explained in this note at the end
of Python's math module docs:
"""
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.
"""
More information about the Python-list
mailing list