UNPKG

944 BMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function log2
4
5Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.
6
7For matrices, the function is evaluated element wise.
8
9
10## Syntax
11
12```js
13math.log2(x)
14```
15
16### Parameters
17
18Parameter | Type | Description
19--------- | ---- | -----------
20`x` | number &#124; BigNumber &#124; Complex &#124; Array &#124; Matrix | Value for which to calculate the logarithm.
21
22### Returns
23
24Type | Description
25---- | -----------
26number &#124; BigNumber &#124; Complex &#124; Array &#124; Matrix | Returns the 2-base logarithm of `x`
27
28
29## Examples
30
31```js
32math.log2(0.03125) // returns -5
33math.log2(16) // returns 4
34math.log2(16) / math.log2(2) // returns 4
35math.pow(2, 4) // returns 16
36```
37
38
39## See also
40
41[exp](exp.md),
42[log](log.md),
43[log1p](log1p.md),
44[log10](log10.md)