函数 log #
计算一个值的对数。
为避免与矩阵对数混淆,此函数不适用于矩阵。
Syntax #
math.log(x)
math.log(x, base)
Parameters #
| Parameter | Type | Description |
|---|---|---|
x |
number | BigNumber | Fraction | Complex | 要计算对数的值。 |
base |
number | BigNumber | Fraction | Complex | 对数的可选底数。如果未提供,则计算 x 的自然对数。默认值:e。 |
Returns #
| Type | Description |
|---|---|
| number | BigNumber | Fraction | Complex | 返回 x 的对数 |
Throws #
Type | Description —- | ———–
Examples #
math.log(3.5) // returns 1.252762968495368
math.exp(math.log(2.4)) // returns 2.4
math.pow(10, 4) // returns 10000
math.log(10000, 10) // returns 4
math.log(10000) / math.log(10) // returns 4
math.log(1024, 2) // returns 10
math.pow(2, 10) // returns 1024