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