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/log1p below:

Math.log1p() - JavaScript | MDN

Math.log1p()

Baseline Widely available

La fonction Math.log1p() renvoie le logarithme népérien (en base e) d'un nombre +1, donné par la formule :

∀ x > - 1 , Math.log1p ( x ) = ln ( 1 + x ) \forall x > -1, \mathtt{\operatorname{Math.log1p}(x)} = \ln(1 + x)

Exemple interactif
console.log(Math.log1p(1));
// Expected output: 0.6931471805599453

console.log(Math.log1p(0));
// Expected output: 0

console.log(Math.log1p(-1));
// Expected output: -Infinity

console.log(Math.log1p(-2));
// Expected output: NaN
Syntaxe Paramètres Valeur de retour

La valeur du logarithme naturel de 1 plus l'argument (log(1 + x)). Si l'argument est inférieur à -1, NaN est renvoyée.

Description

Si x est strictement inférieur à -1, la valeur renvoyée est NaN.

log1p étant une méthode statique de Math, il faut utiliser Math.log1p() et non pas la méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

Exemple Utiliser Math.log1p()
Math.log1p(1); // 0.6931471805599453
Math.log1p(0); // 0
Math.log1p(-1); // -Infinity
Math.log1p(-2); // NaN
Prothèse d'émulation (polyfill)

Si cette fonction n'est pas disponible, elle peut être définie grâce au code suivant :

Math.log1p =
  Math.log1p ||
  function (x) {
    return Math.log(1 + x);
  };
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