JavaScript log2() method
- Forrige side log1p()
- Næste side LOG2E
- Gå tilbage til forrige niveau JavaScript Math Reference Håndbog
Definition and usage
log2()
The method returns the logarithm of the number with base 2.
Example
Return the logarithm of different numbers with base 2:
var a = Math.log2(2.7183); var b = Math.log2(2); var c = Math.log2(1); var d = Math.log2(0); var e = Math.log2(-1);
Syntax
Math.log2(x)
Parameter value
Parameter | Description |
---|---|
x | Required. Number. |
Technical details
Return value: |
A number representing the logarithm of the number with base 2.
|
---|---|
JavaScript version: | ECMAScript 2015 |
Browserstøtte
Metoder | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
log2() | 38.0 | 12.0 | 25.0 | 8.0 | 25.0 |
Relaterede sider
Tilførsel:JavaScript matematik
- Forrige side log1p()
- Næste side LOG2E
- Gå tilbage til forrige niveau JavaScript Math Reference Håndbog