JavaScript log2() method
- Föregående sida log1p()
- Nästa sida LOG2E
- Åter till föregående nivå JavaScript Math Referens Handbok
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: |
Number, representing the logarithm of the number with base 2.
|
---|---|
JavaScript version: | ECMAScript 2015 |
Webbläsarstöd
Metoder | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
log2() | 38.0 | 12.0 | 25.0 | 8.0 | 25.0 |
Relaterade sidor
Tutorial:JavaScript matematik
- Föregående sida log1p()
- Nästa sida LOG2E
- Åter till föregående nivå JavaScript Math Referens Handbok