From bf8e099b9c8b3c60d60b3712b4fc97b052c39887 Mon Sep 17 00:00:00 2001 From: julieng Date: Tue, 3 Aug 2021 08:03:23 +0200 Subject: convert content to md --- .../reference/global_objects/math/log2/index.md | 94 +++++++++------------- 1 file changed, 38 insertions(+), 56 deletions(-) (limited to 'files/fr/web/javascript/reference/global_objects/math/log2') diff --git a/files/fr/web/javascript/reference/global_objects/math/log2/index.md b/files/fr/web/javascript/reference/global_objects/math/log2/index.md index c1700ae5c1..8d9d91c64b 100644 --- a/files/fr/web/javascript/reference/global_objects/math/log2/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/log2/index.md @@ -11,79 +11,61 @@ tags: translation_of: Web/JavaScript/Reference/Global_Objects/Math/log2 original_slug: Web/JavaScript/Reference/Objets_globaux/Math/log2 --- -
{{JSRef}}
+{{JSRef}} -

La fonction Math.log2() renvoie le logarithme en base 2 d'un nombre :

+La fonction **`Math.log2()`** renvoie le logarithme en base 2 d'un nombre : -

x>0,Math.log2(x)=log2(x)=l'unique ytel que2y=x\forall x > 0, \mathtt{\operatorname{Math.log2}(x)} = \log_2(x) = \text{the unique} \; y \; \text{such that} \; 2^y = x

+x>0,Math.log2(x)=log2(x)=l'unique ytel que2y=x\forall x > 0, \mathtt{\operatorname{Math.log2}(x)} = \log_2(x) = \text{the unique} \; y \; \text{such that} \; 2^y = x -
{{EmbedInteractiveExample("pages/js/math-log2.html")}}
+{{EmbedInteractiveExample("pages/js/math-log2.html")}} -

Syntaxe

+## Syntaxe -
Math.log2(x)
+ Math.log2(x) -

Paramètres

+### Paramètres -
-
x
-
Un nombre.
-
+- `x` + - : Un nombre. -

Valeur de retour

+### Valeur de retour -

Le logarithme en base 2 du nombre passé en argument. Si ce nombre est négatif, c'est {{jsxref("NaN")}} qui sera renvoyé.

+Le logarithme en base 2 du nombre passé en argument. Si ce nombre est négatif, c'est {{jsxref("NaN")}} qui sera renvoyé. -

Description

+## Description -

Si x est strictement inférieur à 0, la valeur renvoyée sera {{jsxref("NaN")}}.

+Si `x` est strictement inférieur à 0, la valeur renvoyée sera {{jsxref("NaN")}}. -

log2() étant une méthode statique de Math, il faut utiliser Math.log2() et non pas la méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur). Si on souhaite utiliser des constantes, on pourra employer {{jsxref("Math.LOG2E")}} ou {{jsxref("Math.LN2")}}.

+`log2()` étant une méthode statique de `Math`, il faut utiliser `Math.log2()` et non pas la méthode d'un autre objet qui aurait été créé (`Math `n'est pas un constructeur). Si on souhaite utiliser des constantes, on pourra employer {{jsxref("Math.LOG2E")}} ou {{jsxref("Math.LN2")}}. -

Exemples

+## Exemples -

Utiliser Math.log2()

+### Utiliser `Math.log2()` -
Math.log2(3);    // 1.584962500721156
+```js
+Math.log2(3);    // 1.584962500721156
 Math.log2(2);    // 1
 Math.log2(1);    // 0
 Math.log2(0);    // -Infinity
 Math.log2(-2);   // NaN
 Math.log2(1024); // 10
-
- -

Spécifications

- - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES2015', '#sec-math.log2', 'Math.log2')}}{{Spec2('ES2015')}}Définition initiale.
{{SpecName('ESDraft', '#sec-math.log2', 'Math.log2')}}{{Spec2('ESDraft')}}
- -

Compatibilité des navigateurs

- -

{{Compat("javascript.builtins.Math.log2")}}

- -

Voir aussi

- - +``` + +## Spécifications + +| Spécification | État | Commentaires | +| ------------------------------------------------------------------------ | ---------------------------- | -------------------- | +| {{SpecName('ES2015', '#sec-math.log2', 'Math.log2')}} | {{Spec2('ES2015')}} | Définition initiale. | +| {{SpecName('ESDraft', '#sec-math.log2', 'Math.log2')}} | {{Spec2('ESDraft')}} | | + +## Compatibilité des navigateurs + +{{Compat("javascript.builtins.Math.log2")}} + +## Voir aussi + +- {{jsxref("Math.exp()")}} +- {{jsxref("Math.log()")}} +- {{jsxref("Math.log10()")}} +- {{jsxref("Math.log1p()")}} +- {{jsxref("Math.pow()")}} -- cgit v1.2.3-54-g00ecf