Rename Number.prototype.clz to Math.clz
Brendan Eich
brendan at mozilla.com
Sat Jan 18 10:16:55 PST 2014
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
http://grouper.ieee.org/groups/754/
http://stackoverflow.com/questions/19232157/square-root-of-negative-zero
http://msdn.microsoft.com/en-us/library/windows/desktop/cc308050%28v=vs.85%29.aspx
and many others.
The "Signed Zero" section of
http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
is worth reading.
Further reading from Prof. Wm. Kahan:
http://www.cs.berkeley.edu/~wkahan/
http://www.cs.berkeley.edu/~wkahan/ieee754status/
/be
More information about the es-discuss
mailing list