Math.log2 applied to powers of 2

Claude Pache claude.pache at gmail.com
Thu Sep 18 03:17:29 PDT 2014


Just tried in the console of Chrome (with "Experimental JavaScript features" flag enabled).

    > Math.log2(8) 
    < 2.9999999999999996

Firefox gives me the correct answer (3).

Question: Should Math.log2 give exact results for powers of 2?

The same issue holds for Math.log10 (might be applicable for nonnegative powers only): Math.log10(1e15) != 15 in Chrome.

—Claude
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140918/0387e738/attachment.html>


More information about the es-discuss mailing list