mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
55 lines
1.4 KiB
Markdown
55 lines
1.4 KiB
Markdown
---
|
|
layout: default
|
|
---
|
|
|
|
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|
|
|
|
<h1 id="function-log2">Function log2 <a href="#function-log2" title="Permalink">#</a></h1>
|
|
|
|
Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.
|
|
|
|
For matrices, the function is evaluated element wise.
|
|
|
|
|
|
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
|
|
|
|
```js
|
|
math.log2(x)
|
|
```
|
|
|
|
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
|
|
|
|
Parameter | Type | Description
|
|
--------- | ---- | -----------
|
|
`x` | number | BigNumber | Complex | Array | Matrix | Value for which to calculate the logarithm.
|
|
|
|
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
number | BigNumber | Complex | Array | Matrix | Returns the 2-base logarithm of `x`
|
|
|
|
|
|
<h3 id="throws">Throws <a href="#throws" title="Permalink">#</a></h3>
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
|
|
|
|
<h2 id="examples">Examples <a href="#examples" title="Permalink">#</a></h2>
|
|
|
|
```js
|
|
math.log2(0.03125) // returns -5
|
|
math.log2(16) // returns 4
|
|
math.log2(16) / math.log2(2) // returns 4
|
|
math.pow(2, 4) // returns 16
|
|
```
|
|
|
|
|
|
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
|
|
|
|
[exp](exp.html),
|
|
[log](log.html),
|
|
[log1p](log1p.html),
|
|
[log10](log10.html)
|