Rename Number.prototype.clz to Math.clz
ndkrempel at google.com
Sat Jan 18 16:27:20 PST 2014
On 18 January 2014 18:16, Brendan Eich <brendan at mozilla.com> wrote:
> Nick Krempel wrote:
>> Whether log(0) is -Infinity or NaN should depend in some sense on what
>> side you approach 0 from (I arbitrarily claim to be approaching it from the
>> left in my formula, to give a NaN result there too).
>> I feel Math.log(-0) should be NaN in js for that reason, but it is
>> defined to be -Infinity in the standard. Maybe there are industry standards
>> pertaining to floating point transcendental functions that mandate this?
>> Similarly, Math.sqrt(-0) is -0 rather than NaN. Perhaps using the more
>> correct NaN values in these cases have caused more problems than they have
>> solved in practice?
> These cases (log(-0), sqrt(-0)) conform to IEEE 754. See
Thanks. Didn't know it covered log.
> The "Signed Zero" section of
> is worth reading.
Yes, and it supports my case:
"Another example of the use of signed zero concerns underflow and functions
that have a discontinuity at 0, such as log. In IEEE arithmetic, it is
natural to define log 0 = -∞and log x to be a NaN when x < 0. Suppose that
x represents a small negative number that has underflowed to zero. Thanks
to signed zero, x will be negative, so log can return a NaN. However, if
there were no signed zero, the log function could not distinguish an
underflowed negative number from 0, and would therefore have to return -∞."
Further reading from Prof. Wm. Kahan:
> Also good links. Think I've read most of it already. Kahan's paper on the
correct definitions of transcendental functions along branch cuts mostly
relates to the complex-valued versions, but IIRC has sqrt(-0+0i) = +0, not
-0 in any case.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss