A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Math/LN2 below:

Math.LN2 - JavaScript | MDN

Math.LN2

Baseline Widely available

La propriété Math.LN2 représente le logarithme naturel de 2, environ 0.693:

Math.LN2 = ln ( 2 ) ≈ 0.693 \mathtt{\mi{Math.LN2}} = \ln(2) \approx 0.693 Exemple interactif
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).

Exemples Utiliser 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