Frank Heckenbach wrote:
ISO Pascal wants an error (though, in principle, I think we could use NaN and document the error as "not detected" -- we might do this sometime, perhaps optionally). For now, I'm making it runtime errors. (emil27*.pas)
Special cases for the pow function in IEEE 754 (see e.g. Apple Numerics Manual, second edition, page 64, or the PowerPC Numerics manual available from <http://developer.apple.com/documentation/mac/PPCNumerics/PPCNumerics- 2.html>).
Operation Result Exceptions raised
pow( x, y) for x < 0 NaN if y is not integer Invalid x^y if y is integer None
pow( +0, y) +/-0 if y is odd integer > 0 None +0 if y > 0 but not odd integer None +/- INF if y is odd integer < 0 Divide-by-zero +INF if y < 0 but not odd integer Divide-by-zero
pow( x, +0) +1 None
pow( -0, y) +/-0 if y is odd integer > 0 None +0 if y > 0 but not odd integer None +/-INF if y is odd integer < 0 Divide-by-zero +INF if y < 0 but not odd integer Divide-by-zero
pow( x, -0) +1 None
pow( NaN, y) NaN if y <> 0 None* +1 if y = 0 None*
pow( x, NaN) NaN None*
pow( +INF, y) +INF if y > 0 None +0 if y < 0 None +1 if y = 0 None
pow( x, +INF) +INF if |x| > 1 None +0 if |x| < 1 None NaN if |x| = 1 Invalid
pow( -INF, y) -INF if y is odd integer > 0 None +INF if y > 0 but not odd integer None -0 if y is odd integer < 0 None +0 if y < 0 but not odd integer None +1 if y = 0 None pow( x, -INF) +0 if |x| > 1 None +INF if |x| < 1 None NaN if |x| = 1 Invalid
* If the NaN is a signaling NaN, the invalid exception is raised.
In an IEEE environment, you have routines that give you precise control over what happens if exceptions are signaled (halt vectors and exception flags).
Regards,
Adriaan van Os