[Bug 28679] math:log contradiction about result when argument is zero

https://www.w3.org/Bugs/Public/show_bug.cgi?id=28679

--- Comment #2 from Michael Kay <mike@saxonica.com> ---
Thanks for raising this.

IEEE 754-2008 says (section 9.2.1) that log(0) and log10(0) return -INF and
signal the divideByZero exception.

We say in section 4.2:

The [IEEE 754-2008] specification also describes handling of two exception
conditions called divideByZero and invalidOperation. The IEEE divideByZero
exception is raised not only by a direct attempt to divide by zero, but also by
operations such as log(0). The IEEE invalidOperation exception is raised by
attempts to call a function with an argument that is outside the function's
domain (for example, sqrt(-1) or log(-1). These IEEE exceptions do not cause a
dynamic error at the application level; rather they result in the relevant
function or operator returning NaN. The underlying IEEE exception may be
notified to the application or to the user by some ·implementation-defined·
warning condition, but the observable effect on an application using the
functions and operators defined in this specification is simply to return NaN
with no error.

Both Java and .NET follow our examples: log(0) returns -INF, while log(-1)
returns NaN.

The text in 4.2 also appears to be incorrect as regards simple division by
zero. Like log(0), division by zero returns ±INF, and signals the divideByZero
exception.

I suggest revising the relevant paragraph in 4.2 to read:

The [IEEE 754-2008] specification also describes handling of two exception
conditions called divideByZero and invalidOperation. The IEEE divideByZero
exception is raised not only by a direct attempt to divide by zero, but also by
operations such as log(0). The IEEE invalidOperation exception is raised by
attempts to call a function with an argument that is outside the function's
domain (for example, sqrt(-1) or log(-1)<add>)</add>. <add>Although IEEE
defines these as exceptions, it also defines "default non-stop exception
handling" in which the operation returns a defined result, typically positive
or negative infinity, or NaN. With this function library,</add> these IEEE
exceptions do not cause a dynamic error at the application level; rather they
result in the relevant function or operator returning <mod>the defined
non-error result</mod>. The underlying IEEE exception may be notified to the
application or to the user by some ·implementation-defined· warning condition,
but the observable effect on an application using the functions and operators
defined in this specification is simply to return <mod>the defined result
(typically -INF, +INF, or NaN)</mod> with no error.

Then in math:log and math:log10 we should say "The effect is that if the
argument is zero, the result is -INF, and if the argument is less than zero,
the result is NaN."

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Friday, 29 May 2015 08:58:17 UTC