所以我有一个脚本,它使用Javascript的Math.log2()函数。今天在IE9中进行了测试,发现IE不支持log2。它只支持日志。
有谁知道我能得到和日志库2相同的结果吗?下面是我的代码的一个示例:
var number = 16,
exponent = Math.log2(number);
//Will return 4
return exponent;发布于 2015-01-09 03:41:19
表达式Math.log(number) / Math.log(2)等价于Math.log2(number)
formula.htm
发布于 2015-04-08 04:45:02
如果Math.log2函数不存在,可以创建它:
Math.log2 = Math.log2 || function(x){return Math.log(x)*Math.LOG2E;};https://stackoverflow.com/questions/27853445
复制相似问题