Rename Number.prototype.clz to Math.clz

Nick Krempel ndkrempel at google.com
Fri Jan 17 17:59:11 PST 2014


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?

Nick



On 17 January 2014 20:16, Adam Ahmed <aahmed at atlassian.com> wrote:

>
>
> On 18 January 2014 06:25, Jason Orendorff <jason.orendorff at gmail.com>wrote:
>
>>
>> Except I think we want bitlen(0) === 0 for consistency with clz.
>>
>>
> Just noting that this actually works:
>  Math.ceil(Math.log(0 + 1) / Math.LN2) === 0
>
> However:
>  Math.ceil(Math.log(-1 + 1) / Math.LN2) === -Infinity
>
> Not sure how that affects a Negative NaN-cy option :)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140118/17f2fea1/attachment.html>


More information about the es-discuss mailing list