Baseline Widely available
La propriété Math.LN2
représente le logarithme naturel de 2, environ 0.693:
function getNatLog2() {
return Math.LN2;
}
console.log(getNatLog2());
// Expected output: 0.6931471805599453
Ãcrivable Non Ãnumérable Non Configurable Non Description
LN2
est une propriété statique de l'objet Math
, il doit toujours être utilisé avec la syntaxe Math.LN2
, et non pas être utilisé comme la propriété d'un objet qui aurait été créé (Math
n'est pas un constructeur).
Math.LN2
La fonction suivante renvoie le logarithme en base 2 d'un nombre en utilisant la valeur de Math.LN2
:
function getLog2(x) {
return Math.log(x) / Math.LN2;
}
getLog2(256); // 8
Spécifications Compatibilité des navigateurs Voir aussi
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4