Rename Number.prototype.clz to Math.clz

Brendan Eich brendan at
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

and many others.

The "Signed Zero" section of

is worth reading.

Further reading from Prof. Wm. Kahan:


More information about the es-discuss mailing list