Math.log2()
Math.log2() 静态方法返回数字的以 2 为底的对数。那是
¥The Math.log2() static method returns the base 2 logarithm of a number. That is
Try it
语法
参数
返回值
描述
¥Description
因为 log2() 是 Math 的静态方法,所以你始终将其用作 Math.log2(),而不是用作你创建的 Math 对象的方法(Math 不是构造函数)。
¥Because log2() is a static method of Math, you always use it as Math.log2(), rather than as a method of a Math object you created (Math is not a constructor).
该功能相当于 Math.log(x) / Math.log(2)。对于 log2(e),使用常量 Math.LOG2E,即 1 / Math.LN2。
¥This function is the equivalent of Math.log(x) / Math.log(2). For log2(e), use the constant Math.LOG2E, which is 1 / Math.LN2.
示例
使用 Math.log2()
规范
| Specification |
|---|
| ECMAScript Language Specification # sec-math.log2 |
浏览器兼容性
BCD tables only load in the browser