From 844f5103992238c0c23203286dad16a466e89c97 Mon Sep 17 00:00:00 2001 From: julieng Date: Tue, 3 Aug 2021 08:03:09 +0200 Subject: move *.html to *.md --- .../reference/global_objects/math/abs/index.html | 100 ------------ .../reference/global_objects/math/abs/index.md | 100 ++++++++++++ .../reference/global_objects/math/acos/index.html | 100 ------------ .../reference/global_objects/math/acos/index.md | 100 ++++++++++++ .../reference/global_objects/math/acosh/index.html | 97 ------------ .../reference/global_objects/math/acosh/index.md | 97 ++++++++++++ .../reference/global_objects/math/asin/index.html | 99 ------------ .../reference/global_objects/math/asin/index.md | 99 ++++++++++++ .../reference/global_objects/math/asinh/index.html | 88 ----------- .../reference/global_objects/math/asinh/index.md | 88 +++++++++++ .../reference/global_objects/math/atan/index.html | 102 ------------ .../reference/global_objects/math/atan/index.md | 102 ++++++++++++ .../reference/global_objects/math/atan2/index.html | 110 ------------- .../reference/global_objects/math/atan2/index.md | 110 +++++++++++++ .../reference/global_objects/math/atanh/index.html | 99 ------------ .../reference/global_objects/math/atanh/index.md | 99 ++++++++++++ .../reference/global_objects/math/cbrt/index.html | 88 ----------- .../reference/global_objects/math/cbrt/index.md | 88 +++++++++++ .../reference/global_objects/math/ceil/index.html | 174 --------------------- .../reference/global_objects/math/ceil/index.md | 174 +++++++++++++++++++++ .../reference/global_objects/math/clz32/index.html | 92 ----------- .../reference/global_objects/math/clz32/index.md | 92 +++++++++++ .../reference/global_objects/math/cos/index.html | 95 ----------- .../reference/global_objects/math/cos/index.md | 95 +++++++++++ .../reference/global_objects/math/cosh/index.html | 103 ------------ .../reference/global_objects/math/cosh/index.md | 103 ++++++++++++ .../reference/global_objects/math/e/index.html | 82 ---------- .../reference/global_objects/math/e/index.md | 82 ++++++++++ .../reference/global_objects/math/exp/index.html | 93 ----------- .../reference/global_objects/math/exp/index.md | 93 +++++++++++ .../reference/global_objects/math/expm1/index.html | 91 ----------- .../reference/global_objects/math/expm1/index.md | 91 +++++++++++ .../reference/global_objects/math/floor/index.html | 97 ------------ .../reference/global_objects/math/floor/index.md | 97 ++++++++++++ .../global_objects/math/fround/index.html | 86 ---------- .../reference/global_objects/math/fround/index.md | 86 ++++++++++ .../reference/global_objects/math/hypot/index.html | 126 --------------- .../reference/global_objects/math/hypot/index.md | 126 +++++++++++++++ .../reference/global_objects/math/imul/index.html | 90 ----------- .../reference/global_objects/math/imul/index.md | 90 +++++++++++ .../reference/global_objects/math/index.html | 170 -------------------- .../reference/global_objects/math/index.md | 170 ++++++++++++++++++++ .../reference/global_objects/math/ln10/index.html | 82 ---------- .../reference/global_objects/math/ln10/index.md | 82 ++++++++++ .../reference/global_objects/math/ln2/index.html | 82 ---------- .../reference/global_objects/math/ln2/index.md | 82 ++++++++++ .../reference/global_objects/math/log/index.html | 104 ------------ .../reference/global_objects/math/log/index.md | 104 ++++++++++++ .../reference/global_objects/math/log10/index.html | 97 ------------ .../reference/global_objects/math/log10/index.md | 97 ++++++++++++ .../global_objects/math/log10e/index.html | 82 ---------- .../reference/global_objects/math/log10e/index.md | 82 ++++++++++ .../reference/global_objects/math/log1p/index.html | 96 ------------ .../reference/global_objects/math/log1p/index.md | 96 ++++++++++++ .../reference/global_objects/math/log2/index.html | 89 ----------- .../reference/global_objects/math/log2/index.md | 89 +++++++++++ .../reference/global_objects/math/log2e/index.html | 82 ---------- .../reference/global_objects/math/log2e/index.md | 82 ++++++++++ .../reference/global_objects/math/max/index.html | 112 ------------- .../reference/global_objects/math/max/index.md | 112 +++++++++++++ .../reference/global_objects/math/min/index.html | 108 ------------- .../reference/global_objects/math/min/index.md | 108 +++++++++++++ .../reference/global_objects/math/pi/index.html | 80 ---------- .../reference/global_objects/math/pi/index.md | 80 ++++++++++ .../reference/global_objects/math/pow/index.html | 103 ------------ .../reference/global_objects/math/pow/index.md | 103 ++++++++++++ .../global_objects/math/random/index.html | 113 ------------- .../reference/global_objects/math/random/index.md | 113 +++++++++++++ .../reference/global_objects/math/round/index.html | 94 ----------- .../reference/global_objects/math/round/index.md | 94 +++++++++++ .../reference/global_objects/math/sign/index.html | 89 ----------- .../reference/global_objects/math/sign/index.md | 89 +++++++++++ .../reference/global_objects/math/sin/index.html | 91 ----------- .../reference/global_objects/math/sin/index.md | 91 +++++++++++ .../reference/global_objects/math/sinh/index.html | 95 ----------- .../reference/global_objects/math/sinh/index.md | 95 +++++++++++ .../reference/global_objects/math/sqrt/index.html | 94 ----------- .../reference/global_objects/math/sqrt/index.md | 94 +++++++++++ .../global_objects/math/sqrt1_2/index.html | 79 ---------- .../reference/global_objects/math/sqrt1_2/index.md | 79 ++++++++++ .../reference/global_objects/math/sqrt2/index.html | 79 ---------- .../reference/global_objects/math/sqrt2/index.md | 79 ++++++++++ .../reference/global_objects/math/tan/index.html | 98 ------------ .../reference/global_objects/math/tan/index.md | 98 ++++++++++++ .../reference/global_objects/math/tanh/index.html | 105 ------------- .../reference/global_objects/math/tanh/index.md | 105 +++++++++++++ .../reference/global_objects/math/trunc/index.html | 94 ----------- .../reference/global_objects/math/trunc/index.md | 94 +++++++++++ 88 files changed, 4330 insertions(+), 4330 deletions(-) delete mode 100644 files/fr/web/javascript/reference/global_objects/math/abs/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/abs/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/acos/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/acos/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/acosh/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/acosh/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/asin/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/asin/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/asinh/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/asinh/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/atan/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/atan/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/atan2/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/atan2/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/atanh/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/atanh/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/cbrt/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/cbrt/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/ceil/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/ceil/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/clz32/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/clz32/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/cos/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/cos/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/cosh/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/cosh/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/e/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/e/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/exp/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/exp/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/expm1/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/expm1/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/floor/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/floor/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/fround/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/fround/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/hypot/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/hypot/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/imul/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/imul/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/ln10/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/ln10/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/ln2/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/ln2/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/log/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/log/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/log10/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/log10/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/log10e/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/log10e/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/log1p/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/log1p/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/log2/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/log2/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/log2e/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/log2e/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/max/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/max/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/min/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/min/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/pi/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/pi/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/pow/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/pow/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/random/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/random/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/round/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/round/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/sign/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/sign/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/sin/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/sin/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/sinh/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/sinh/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/sqrt/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/sqrt/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/sqrt1_2/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/sqrt1_2/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/sqrt2/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/sqrt2/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/tan/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/tan/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/tanh/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/tanh/index.md delete mode 100644 files/fr/web/javascript/reference/global_objects/math/trunc/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/math/trunc/index.md (limited to 'files/fr/web/javascript/reference/global_objects/math') diff --git a/files/fr/web/javascript/reference/global_objects/math/abs/index.html b/files/fr/web/javascript/reference/global_objects/math/abs/index.html deleted file mode 100644 index c632d426db..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/abs/index.html +++ /dev/null @@ -1,100 +0,0 @@ ---- -title: Math.abs() -slug: Web/JavaScript/Reference/Global_Objects/Math/abs -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/abs -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/abs ---- -
{{JSRef}}
- -

La fonction Math.abs() retourne la valeur absolue d'un nombre, c'est-à-dire

- -

Math.abs(x)=|x|={xsix0-xsix<0{\mathtt{\operatorname{Math.abs}(x)}} = {|x|} = \begin{cases} x & \text{si} \quad x \geq 0 \\ -x & \text{si} \quad x < 0 \end{cases}

- -
{{EmbedInteractiveExample("pages/js/math-abs.html")}}
- -

Syntaxe

- -
Math.abs(x);
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur absolue

- -

La valeur absolue du nombre passé en argument.

- -

Description

- -

abs est une méthode statique de l'objet Math et doit toujours être utilisée avec la syntaxe Math.abs().

- -

Exemples

- -

Utiliser Math.abs()

- -

Si la méthode est utilisée avec une chaîne de caractères non numérique, avec un tableau à plus d'un élément, sans paramètre ou avec {{jsxref("undefined")}}, la valeur retournée sera {{jsxref("NaN")}}. Si elle est utilisée avec {{jsxref("null")}}, la fonction renverra 0.

- -
Math.abs('-1');     // 1
-Math.abs(-2);       // 2
-Math.abs(null);     // 0
-Math.abs('');       // 0
-Math.abs([]);       // 0
-Math.abs([2]);      // 2
-Math.abs([1,2]);    // NaN
-Math.abs({});       // NaN
-Math.abs("string"); // NaN
-Math.abs();         // NaN
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.1', 'Math.abs')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.abs', 'Math.abs')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.abs', 'Math.abs')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/abs/index.md b/files/fr/web/javascript/reference/global_objects/math/abs/index.md new file mode 100644 index 0000000000..c632d426db --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/abs/index.md @@ -0,0 +1,100 @@ +--- +title: Math.abs() +slug: Web/JavaScript/Reference/Global_Objects/Math/abs +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/abs +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/abs +--- +
{{JSRef}}
+ +

La fonction Math.abs() retourne la valeur absolue d'un nombre, c'est-à-dire

+ +

Math.abs(x)=|x|={xsix0-xsix<0{\mathtt{\operatorname{Math.abs}(x)}} = {|x|} = \begin{cases} x & \text{si} \quad x \geq 0 \\ -x & \text{si} \quad x < 0 \end{cases}

+ +
{{EmbedInteractiveExample("pages/js/math-abs.html")}}
+ +

Syntaxe

+ +
Math.abs(x);
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur absolue

+ +

La valeur absolue du nombre passé en argument.

+ +

Description

+ +

abs est une méthode statique de l'objet Math et doit toujours être utilisée avec la syntaxe Math.abs().

+ +

Exemples

+ +

Utiliser Math.abs()

+ +

Si la méthode est utilisée avec une chaîne de caractères non numérique, avec un tableau à plus d'un élément, sans paramètre ou avec {{jsxref("undefined")}}, la valeur retournée sera {{jsxref("NaN")}}. Si elle est utilisée avec {{jsxref("null")}}, la fonction renverra 0.

+ +
Math.abs('-1');     // 1
+Math.abs(-2);       // 2
+Math.abs(null);     // 0
+Math.abs('');       // 0
+Math.abs([]);       // 0
+Math.abs([2]);      // 2
+Math.abs([1,2]);    // NaN
+Math.abs({});       // NaN
+Math.abs("string"); // NaN
+Math.abs();         // NaN
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.1', 'Math.abs')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.abs', 'Math.abs')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.abs', 'Math.abs')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/acos/index.html b/files/fr/web/javascript/reference/global_objects/math/acos/index.html deleted file mode 100644 index 3a2f6fa132..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/acos/index.html +++ /dev/null @@ -1,100 +0,0 @@ ---- -title: Math.acos() -slug: Web/JavaScript/Reference/Global_Objects/Math/acos -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/acos -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/acos ---- -
{{JSRef}}
- -

La fonction Math.acos() renvoie l'arc cosinus d'une valeur exprimée en radians. Cela est défini par :

- -

x[-1;1],Math.acos(x)=arccos(x)= le seul  y[0;π]tel quecos(y)=x\forall x \in [{-1};1],\;\mathtt{\operatorname{Math.acos}(x)} = \arccos(x) = \text{ the unique } \; y \in [0; \pi] \, \text{such that} \; \cos(y) = x

- -
{{EmbedInteractiveExample("pages/js/math-acos.html")}}
- -

Syntaxe

- -
Math.acos(x) 
- -

Paramètres

- -
-
x
-
Un nombre (représentant un angle exprimé en radians).
-
- -

Valeur de retour

- -

L'arc cosinus du nombre passé en argument si celui est compris entre -1 et 1. La méthode renvoie {{jsxref("NaN")}} sinon.

- -

Description

- -

La méthode acos renvoie une valeur numérique comprise entre 0 et Pi pour x compris entre -1 et 1. Si la valeur de x est hors de cet intervalle, la méthode renverra {{jsxref("NaN")}}.

- -

acos est une méhode statique de Math et doit toujours être utilisée avec la syntaxe Math.acos(), elle ne doit pas être appelée depuis un autre objet qui aurait été créé (Math n'est pas un constructeur).

- -

Exemples

- -

Utiliser Math.acos()

- -
Math.acos(-2);  // NaN
-Math.acos(-1);  // 3.141592653589793
-Math.acos(0);   // 1.5707963267948966
-Math.acos(0.5); // 1.0471975511965979
-Math.acos(1);   // 0
-Math.acos(2);   // NaN
-
- -

Pour les valeurs (strictement) inférieures à -1 ou supérieures à 1, Math.acos renvoie NaN.

- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.2', 'Math.acos')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.acos', 'Math.acos')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.acos', 'Math.acos')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/acos/index.md b/files/fr/web/javascript/reference/global_objects/math/acos/index.md new file mode 100644 index 0000000000..3a2f6fa132 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/acos/index.md @@ -0,0 +1,100 @@ +--- +title: Math.acos() +slug: Web/JavaScript/Reference/Global_Objects/Math/acos +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/acos +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/acos +--- +
{{JSRef}}
+ +

La fonction Math.acos() renvoie l'arc cosinus d'une valeur exprimée en radians. Cela est défini par :

+ +

x[-1;1],Math.acos(x)=arccos(x)= le seul  y[0;π]tel quecos(y)=x\forall x \in [{-1};1],\;\mathtt{\operatorname{Math.acos}(x)} = \arccos(x) = \text{ the unique } \; y \in [0; \pi] \, \text{such that} \; \cos(y) = x

+ +
{{EmbedInteractiveExample("pages/js/math-acos.html")}}
+ +

Syntaxe

+ +
Math.acos(x) 
+ +

Paramètres

+ +
+
x
+
Un nombre (représentant un angle exprimé en radians).
+
+ +

Valeur de retour

+ +

L'arc cosinus du nombre passé en argument si celui est compris entre -1 et 1. La méthode renvoie {{jsxref("NaN")}} sinon.

+ +

Description

+ +

La méthode acos renvoie une valeur numérique comprise entre 0 et Pi pour x compris entre -1 et 1. Si la valeur de x est hors de cet intervalle, la méthode renverra {{jsxref("NaN")}}.

+ +

acos est une méhode statique de Math et doit toujours être utilisée avec la syntaxe Math.acos(), elle ne doit pas être appelée depuis un autre objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Exemples

+ +

Utiliser Math.acos()

+ +
Math.acos(-2);  // NaN
+Math.acos(-1);  // 3.141592653589793
+Math.acos(0);   // 1.5707963267948966
+Math.acos(0.5); // 1.0471975511965979
+Math.acos(1);   // 0
+Math.acos(2);   // NaN
+
+ +

Pour les valeurs (strictement) inférieures à -1 ou supérieures à 1, Math.acos renvoie NaN.

+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.2', 'Math.acos')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.acos', 'Math.acos')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.acos', 'Math.acos')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/acosh/index.html b/files/fr/web/javascript/reference/global_objects/math/acosh/index.html deleted file mode 100644 index 26a4b11b80..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/acosh/index.html +++ /dev/null @@ -1,97 +0,0 @@ ---- -title: Math.acosh() -slug: Web/JavaScript/Reference/Global_Objects/Math/acosh -tags: - - JavaScript - - Math - - Méthode - - Reference - - polyfill -translation_of: Web/JavaScript/Reference/Global_Objects/Math/acosh -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/acosh ---- -
{{JSRef}}
- -

La fonction Math.acosh() renvoie l'arc cosinus hyperbolique d'un nombre.Elle est définie par :

- -

x1,Math.acosh(x)=arcosh(x)= l'unique y0tel quecosh(y)=x\forall x \geq 1, \mathtt{\operatorname{Math.acosh}(x)} = \operatorname{arcosh}(x) = \text{ the unique } \; y \geq 0 \; \text{such that} \; \cosh(y) = x

- -
{{EmbedInteractiveExample("pages/js/math-acosh.html")}}
- -

Syntaxe

- -
Math.acosh(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

L'arc cosinus hyperbolique du nombre en argument. Si le nombre est inférieur à 1, la valeur renvoyée sera {{jsxref("NaN")}}.

- -

Description

- -

acosh étant une méthode statique de Math, il faut l'utiliser avec Math.acosh(), plutôt qu'en faisant appel à une méthode d'un autre objet créé (Math n'est pas un constructeur).

- -

Exemple

- -

Utiliser Math.acosh()

- -
Math.acosh(-1);  // NaN
-Math.acosh(0);   // NaN
-Math.acosh(0.5); // NaN
-Math.acosh(1);   // 0
-Math.acosh(2);   // 1.3169578969248166
- -

Pour les valeurs strictement inférieures à 1 Math.acosh renvoie {{jsxref("NaN")}}.

- -

Prothèse d'émulation (polyfill)

- -

Pour tout x1x \geq 1, arcosh(x)=ln(x+x2-1)\operatorname {arcosh} (x) = \ln \left(x + \sqrt{x^{2} - 1} \right), on peut donc émuler cette fonction avec le code suivant :

- -
function acosh(x) {
-  return Math.log(x + Math.sqrt(x * x - 1));
-}
-
- -

Spécifications

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

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/acosh/index.md b/files/fr/web/javascript/reference/global_objects/math/acosh/index.md new file mode 100644 index 0000000000..26a4b11b80 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/acosh/index.md @@ -0,0 +1,97 @@ +--- +title: Math.acosh() +slug: Web/JavaScript/Reference/Global_Objects/Math/acosh +tags: + - JavaScript + - Math + - Méthode + - Reference + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Math/acosh +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/acosh +--- +
{{JSRef}}
+ +

La fonction Math.acosh() renvoie l'arc cosinus hyperbolique d'un nombre.Elle est définie par :

+ +

x1,Math.acosh(x)=arcosh(x)= l'unique y0tel quecosh(y)=x\forall x \geq 1, \mathtt{\operatorname{Math.acosh}(x)} = \operatorname{arcosh}(x) = \text{ the unique } \; y \geq 0 \; \text{such that} \; \cosh(y) = x

+ +
{{EmbedInteractiveExample("pages/js/math-acosh.html")}}
+ +

Syntaxe

+ +
Math.acosh(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

L'arc cosinus hyperbolique du nombre en argument. Si le nombre est inférieur à 1, la valeur renvoyée sera {{jsxref("NaN")}}.

+ +

Description

+ +

acosh étant une méthode statique de Math, il faut l'utiliser avec Math.acosh(), plutôt qu'en faisant appel à une méthode d'un autre objet créé (Math n'est pas un constructeur).

+ +

Exemple

+ +

Utiliser Math.acosh()

+ +
Math.acosh(-1);  // NaN
+Math.acosh(0);   // NaN
+Math.acosh(0.5); // NaN
+Math.acosh(1);   // 0
+Math.acosh(2);   // 1.3169578969248166
+ +

Pour les valeurs strictement inférieures à 1 Math.acosh renvoie {{jsxref("NaN")}}.

+ +

Prothèse d'émulation (polyfill)

+ +

Pour tout x1x \geq 1, arcosh(x)=ln(x+x2-1)\operatorname {arcosh} (x) = \ln \left(x + \sqrt{x^{2} - 1} \right), on peut donc émuler cette fonction avec le code suivant :

+ +
function acosh(x) {
+  return Math.log(x + Math.sqrt(x * x - 1));
+}
+
+ +

Spécifications

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

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/asin/index.html b/files/fr/web/javascript/reference/global_objects/math/asin/index.html deleted file mode 100644 index b094e1bdce..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/asin/index.html +++ /dev/null @@ -1,99 +0,0 @@ ---- -title: Math.asin() -slug: Web/JavaScript/Reference/Global_Objects/Math/asin -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/asin -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/asin ---- -
{{JSRef}}
- -

La fonction Math.asin() renvoie l'arc sinus d'un nombre (en radians). Elle est définie par :

- -

x[-1;1],Math.asin(x)=arcsin(x)= le seul y[-π2;π2]tel quesin(y)=x\forall x \in [{-1};1],\;\mathtt{\operatorname{Math.asin}(x)} = \arcsin(x) = \text{ the unique } \; y \in \left[-\frac{\pi}{2}; \frac{\pi}{2}\right] \, \text{such that} \; \sin(y) = x

- -
{{EmbedInteractiveExample("pages/js/math-asin.html")}}
- -

Syntaxe

- -
Math.asin(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

L'arc sinus du nombre passé en argument (exprimé en radians). Si ce nombre n'est pas compris entre -1 et 1, la valeur renvoyée sera {{jsxref("NaN")}}.

- -

Description

- -

La méthode Math.asin() renvoie une valeur numérique comprise entre -π2-\frac{\pi}{2} et π2\frac{\pi}{2} pour x compris entre -1 et 1. Si x est hors de cet intervalle, la méthode renverra {{jsxref("NaN")}}.

- -

Math.asin() est une méthode statique de Math et doit toujours être utilisée avec la syntaxe Math.asin(), elle ne doit pas être appelée à partir d'un autre objet créé (Math n'est pas un constructeur).

- -

Exemples

- -

Utiliser Math.asin()

- -
Math.asin(-2);  // NaN
-Math.asin(-1);  // -1.570796326794897 (-pi/2)
-Math.asin(0);   // 0
-Math.asin(0.5); // 0.5235987755982989
-Math.asin(1);   // 1.570796326794897 (pi/2)
-Math.asin(2);   // NaN
- -

Pour les valeurs (strictement) inférieures à -1 ou supérieures à 1, Math.asin() renvoie {{jsxref("NaN")}}.

- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.3', 'Math.asin')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.asin', 'Math.asin')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.asin', 'Math.asin')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -
{{Compat("javascript.builtins.Math.asin")}}
- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/asin/index.md b/files/fr/web/javascript/reference/global_objects/math/asin/index.md new file mode 100644 index 0000000000..b094e1bdce --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/asin/index.md @@ -0,0 +1,99 @@ +--- +title: Math.asin() +slug: Web/JavaScript/Reference/Global_Objects/Math/asin +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/asin +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/asin +--- +
{{JSRef}}
+ +

La fonction Math.asin() renvoie l'arc sinus d'un nombre (en radians). Elle est définie par :

+ +

x[-1;1],Math.asin(x)=arcsin(x)= le seul y[-π2;π2]tel quesin(y)=x\forall x \in [{-1};1],\;\mathtt{\operatorname{Math.asin}(x)} = \arcsin(x) = \text{ the unique } \; y \in \left[-\frac{\pi}{2}; \frac{\pi}{2}\right] \, \text{such that} \; \sin(y) = x

+ +
{{EmbedInteractiveExample("pages/js/math-asin.html")}}
+ +

Syntaxe

+ +
Math.asin(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

L'arc sinus du nombre passé en argument (exprimé en radians). Si ce nombre n'est pas compris entre -1 et 1, la valeur renvoyée sera {{jsxref("NaN")}}.

+ +

Description

+ +

La méthode Math.asin() renvoie une valeur numérique comprise entre -π2-\frac{\pi}{2} et π2\frac{\pi}{2} pour x compris entre -1 et 1. Si x est hors de cet intervalle, la méthode renverra {{jsxref("NaN")}}.

+ +

Math.asin() est une méthode statique de Math et doit toujours être utilisée avec la syntaxe Math.asin(), elle ne doit pas être appelée à partir d'un autre objet créé (Math n'est pas un constructeur).

+ +

Exemples

+ +

Utiliser Math.asin()

+ +
Math.asin(-2);  // NaN
+Math.asin(-1);  // -1.570796326794897 (-pi/2)
+Math.asin(0);   // 0
+Math.asin(0.5); // 0.5235987755982989
+Math.asin(1);   // 1.570796326794897 (pi/2)
+Math.asin(2);   // NaN
+ +

Pour les valeurs (strictement) inférieures à -1 ou supérieures à 1, Math.asin() renvoie {{jsxref("NaN")}}.

+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.3', 'Math.asin')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.asin', 'Math.asin')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.asin', 'Math.asin')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +
{{Compat("javascript.builtins.Math.asin")}}
+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/asinh/index.html b/files/fr/web/javascript/reference/global_objects/math/asinh/index.html deleted file mode 100644 index e831b9abcb..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/asinh/index.html +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: Math.asinh() -slug: Web/JavaScript/Reference/Global_Objects/Math/asinh -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/asinh -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/asinh ---- -
{{JSRef}}
- -

La fonction Math.asinh() renvoie l'arc sinus hyperbolique d'un nombre :

- -

Math.asinh(x)=arsinh(x)= le seul ytel quesinh(y)=x\mathtt{\operatorname{Math.asinh}(x)} = \operatorname{arsinh}(x) = \text{ the unique } \; y \; \text{such that} \; \sinh(y) = x

- -
{{EmbedInteractiveExample("pages/js/math-asinh.html")}}
- -

Syntaxe

- -
Math.asinh(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

L'arc sinus hyperbolique du nombre passé en argument.

- -

Description

- -

asinh() étant une méthode statique de Math, elle doit toujours être utilisée avec la syntaxe Math.asinh() et ne doit pas être appelée depuis un autre objet qui aurait été créé (Math n'est pas un constructeur).

- -

Exemple

- -

Utiliser Math.asinh()

- -
Math.asinh = Math.asinh || function(x) {
-  if (x === -Infinity) {
-    return x;
-  } else {
-    return Math.log(x + Math.sqrt(x * x + 1));
-  }
-};
-
- -

Spécifications

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

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/asinh/index.md b/files/fr/web/javascript/reference/global_objects/math/asinh/index.md new file mode 100644 index 0000000000..e831b9abcb --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/asinh/index.md @@ -0,0 +1,88 @@ +--- +title: Math.asinh() +slug: Web/JavaScript/Reference/Global_Objects/Math/asinh +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/asinh +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/asinh +--- +
{{JSRef}}
+ +

La fonction Math.asinh() renvoie l'arc sinus hyperbolique d'un nombre :

+ +

Math.asinh(x)=arsinh(x)= le seul ytel quesinh(y)=x\mathtt{\operatorname{Math.asinh}(x)} = \operatorname{arsinh}(x) = \text{ the unique } \; y \; \text{such that} \; \sinh(y) = x

+ +
{{EmbedInteractiveExample("pages/js/math-asinh.html")}}
+ +

Syntaxe

+ +
Math.asinh(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

L'arc sinus hyperbolique du nombre passé en argument.

+ +

Description

+ +

asinh() étant une méthode statique de Math, elle doit toujours être utilisée avec la syntaxe Math.asinh() et ne doit pas être appelée depuis un autre objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Exemple

+ +

Utiliser Math.asinh()

+ +
Math.asinh = Math.asinh || function(x) {
+  if (x === -Infinity) {
+    return x;
+  } else {
+    return Math.log(x + Math.sqrt(x * x + 1));
+  }
+};
+
+ +

Spécifications

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

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/atan/index.html b/files/fr/web/javascript/reference/global_objects/math/atan/index.html deleted file mode 100644 index 3c6754866d..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/atan/index.html +++ /dev/null @@ -1,102 +0,0 @@ ---- -title: Math.atan() -slug: Web/JavaScript/Reference/Global_Objects/Math/atan -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/atan -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/atan ---- -
{{JSRef}}
- -

La fonction Math.atan() renvoie l'arc tangente d'un nombre exprimée en radians. Elle est définie par :

- -

Math.atan(x)=arctan(x)=le seuly[-π2;π2]tel quetan(y)=x\mathtt{\operatorname{Math.atan}(x)} = \arctan(x) = \text{ the unique } \; y \in \left[-\frac{\pi}{2}; \frac{\pi}{2}\right] \, \text{such that} \; \tan(y) = x

- -
{{EmbedInteractiveExample("pages/js/math-atan.html")}}
- -

Syntaxe

- -
Math.atan(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

L'arc tangente du nombre passé en argument (exprimé en radians).

- -

Description

- -

La méthode Math.atan() renvoie une valeur numérique comprise entre -π2-\frac{\pi}{2} et π2\frac{\pi}{2}.

- -

atan() est une méthode statique de Math et doit toujours être utilisée avec la syntaxe Math.atan(), elle ne doit pas être utilisée comme une méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

- -

Exemples

- -

Utiliser Math.atan()

- -
Math.atan(1);  // 0.7853981633974483
-Math.atan(0);  // 0
-Math.atan(-0); // -0
-
-Math.atan(Infinity); // 1.5707963267948966
-Math.atan(-Infinity); // -1.5707963267948966
-
-// L'angle formé entre la droite [(0,0);(x,y)] et l'axe des abscisses
-// dans un système de coordonnées cartésienne
-Math.atan(y / x);
-
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.4', 'Math.atan')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.atan', 'Math.atan')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.atan', 'Math.atan')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -
{{Compat("javascript.builtins.Math.atan")}}
- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/atan/index.md b/files/fr/web/javascript/reference/global_objects/math/atan/index.md new file mode 100644 index 0000000000..3c6754866d --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/atan/index.md @@ -0,0 +1,102 @@ +--- +title: Math.atan() +slug: Web/JavaScript/Reference/Global_Objects/Math/atan +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/atan +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/atan +--- +
{{JSRef}}
+ +

La fonction Math.atan() renvoie l'arc tangente d'un nombre exprimée en radians. Elle est définie par :

+ +

Math.atan(x)=arctan(x)=le seuly[-π2;π2]tel quetan(y)=x\mathtt{\operatorname{Math.atan}(x)} = \arctan(x) = \text{ the unique } \; y \in \left[-\frac{\pi}{2}; \frac{\pi}{2}\right] \, \text{such that} \; \tan(y) = x

+ +
{{EmbedInteractiveExample("pages/js/math-atan.html")}}
+ +

Syntaxe

+ +
Math.atan(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

L'arc tangente du nombre passé en argument (exprimé en radians).

+ +

Description

+ +

La méthode Math.atan() renvoie une valeur numérique comprise entre -π2-\frac{\pi}{2} et π2\frac{\pi}{2}.

+ +

atan() est une méthode statique de Math et doit toujours être utilisée avec la syntaxe Math.atan(), elle ne doit pas être utilisée comme une méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Exemples

+ +

Utiliser Math.atan()

+ +
Math.atan(1);  // 0.7853981633974483
+Math.atan(0);  // 0
+Math.atan(-0); // -0
+
+Math.atan(Infinity); // 1.5707963267948966
+Math.atan(-Infinity); // -1.5707963267948966
+
+// L'angle formé entre la droite [(0,0);(x,y)] et l'axe des abscisses
+// dans un système de coordonnées cartésienne
+Math.atan(y / x);
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.4', 'Math.atan')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.atan', 'Math.atan')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.atan', 'Math.atan')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +
{{Compat("javascript.builtins.Math.atan")}}
+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/atan2/index.html b/files/fr/web/javascript/reference/global_objects/math/atan2/index.html deleted file mode 100644 index 24923087e3..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/atan2/index.html +++ /dev/null @@ -1,110 +0,0 @@ ---- -title: Math.atan2() -slug: Web/JavaScript/Reference/Global_Objects/Math/atan2 -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/atan2 -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/atan2 ---- -
{{JSRef}}
- -

La fonction Math.atan2() renvoie l'arc tangente du quotient de ses arguments.

- -
{{EmbedInteractiveExample("pages/js/math-atan2.html")}}
- -

Syntaxe

- -
Math.atan2(y, x) 
- -

Paramètres

- -
-
x
-
La coordonnée en abscisse du point.
-
y
-
La coordonnée en ordonnée du point.
-
- -

Valeur de retour

- -

L'arc tangente du quotient formé par les deux arguments, c'est-à-dire l'angle, exprimé en radians entre l'axe des abscisses et la droite passant par l'origin (0,0) et le point de coordonnées (x,y).

- -

Description

- -

La méthode Math.atan2() renvoie une valeur numérique comprise entre -Pi et Pi qui représente l'angle theta d'un point de coordonnées (x,y). Cela correspond à l'angle (dans le sens trigonométrique) entre l'axe des abscisses et le point de coordonnées (x,y). Attention, le premier argument de la fonction est l'ordonnée (y) et le second est l'abscisse (x).

- -

Graphique explicitant l'angle donné par un point de coordonnées X/Y

- -

Math.atan2() utilise deux arguments x et y, alors que la méthode Math.atan() utilise le ratio de deux nombres comme un seul argument.

- -

atan2() est une méthode statique de l'objet Math, elle doit toujours être utilisée avec la syntaxe Math.atan2(), elle ne doit pas être utilisée comme la méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

- -

Exemples

- -

Utiliser Math.atan2()

- -
Math.atan2(90, 15); // 1.4056476493802699
-Math.atan2(15, 90); // 0.16514867741462683
-
-Math.atan2( ±0, -0 );               // ±PI.
-Math.atan2( ±0, +0 );               // ±0.
-Math.atan2( ±0, -x );               // ±PI pour x > 0.
-Math.atan2( ±0, x );                // ±0 pour x > 0.
-Math.atan2( -y, ±0 );               // -PI/2 pour y > 0.
-Math.atan2( y, ±0 );                // PI/2 pour y > 0.
-Math.atan2( ±y, -Infinity );        // ±PI pour y qui est un nombre fini > 0.
-Math.atan2( ±y, +Infinity );        // ±0 pour y qui est un nombre fini > 0.
-Math.atan2( ±Infinity, x );         // ±PI/2 pour x qui est un nombre fini.
-Math.atan2( ±Infinity, -Infinity ); // ±3*PI/4.
-Math.atan2( ±Infinity, +Infinity ); // ±PI/4.
-
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.5', 'Math.atan2')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.atan2', 'Math.atan2')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.atan2', 'Math.atan2')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/atan2/index.md b/files/fr/web/javascript/reference/global_objects/math/atan2/index.md new file mode 100644 index 0000000000..24923087e3 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/atan2/index.md @@ -0,0 +1,110 @@ +--- +title: Math.atan2() +slug: Web/JavaScript/Reference/Global_Objects/Math/atan2 +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/atan2 +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/atan2 +--- +
{{JSRef}}
+ +

La fonction Math.atan2() renvoie l'arc tangente du quotient de ses arguments.

+ +
{{EmbedInteractiveExample("pages/js/math-atan2.html")}}
+ +

Syntaxe

+ +
Math.atan2(y, x) 
+ +

Paramètres

+ +
+
x
+
La coordonnée en abscisse du point.
+
y
+
La coordonnée en ordonnée du point.
+
+ +

Valeur de retour

+ +

L'arc tangente du quotient formé par les deux arguments, c'est-à-dire l'angle, exprimé en radians entre l'axe des abscisses et la droite passant par l'origin (0,0) et le point de coordonnées (x,y).

+ +

Description

+ +

La méthode Math.atan2() renvoie une valeur numérique comprise entre -Pi et Pi qui représente l'angle theta d'un point de coordonnées (x,y). Cela correspond à l'angle (dans le sens trigonométrique) entre l'axe des abscisses et le point de coordonnées (x,y). Attention, le premier argument de la fonction est l'ordonnée (y) et le second est l'abscisse (x).

+ +

Graphique explicitant l'angle donné par un point de coordonnées X/Y

+ +

Math.atan2() utilise deux arguments x et y, alors que la méthode Math.atan() utilise le ratio de deux nombres comme un seul argument.

+ +

atan2() est une méthode statique de l'objet Math, elle doit toujours être utilisée avec la syntaxe Math.atan2(), elle ne doit pas être utilisée comme la méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Exemples

+ +

Utiliser Math.atan2()

+ +
Math.atan2(90, 15); // 1.4056476493802699
+Math.atan2(15, 90); // 0.16514867741462683
+
+Math.atan2( ±0, -0 );               // ±PI.
+Math.atan2( ±0, +0 );               // ±0.
+Math.atan2( ±0, -x );               // ±PI pour x > 0.
+Math.atan2( ±0, x );                // ±0 pour x > 0.
+Math.atan2( -y, ±0 );               // -PI/2 pour y > 0.
+Math.atan2( y, ±0 );                // PI/2 pour y > 0.
+Math.atan2( ±y, -Infinity );        // ±PI pour y qui est un nombre fini > 0.
+Math.atan2( ±y, +Infinity );        // ±0 pour y qui est un nombre fini > 0.
+Math.atan2( ±Infinity, x );         // ±PI/2 pour x qui est un nombre fini.
+Math.atan2( ±Infinity, -Infinity ); // ±3*PI/4.
+Math.atan2( ±Infinity, +Infinity ); // ±PI/4.
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.5', 'Math.atan2')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.atan2', 'Math.atan2')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.atan2', 'Math.atan2')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/atanh/index.html b/files/fr/web/javascript/reference/global_objects/math/atanh/index.html deleted file mode 100644 index f159f35630..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/atanh/index.html +++ /dev/null @@ -1,99 +0,0 @@ ---- -title: Math.atanh() -slug: Web/JavaScript/Reference/Global_Objects/Math/atanh -tags: - - JavaScript - - Math - - Méthode - - Reference - - polyfill -translation_of: Web/JavaScript/Reference/Global_Objects/Math/atanh -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/atanh ---- -
{{JSRef}}
- -

La fonction Math.atanh() renvoie l'arc tangente hyperbolique d'un nombre :

- -

x(-1,1),Math.atanh(x)=arctanh(x)= le seul y  tel quetanh(y)=x\forall x \in \left( -1, 1 \right), \mathtt{\operatorname{Math.atanh}(x)} = \operatorname{arctanh}(x) = \text{ the unique } \; y \; \text{such that} \; \tanh(y) = x

- -
{{EmbedInteractiveExample("pages/js/math-atanh.html")}}
- -

Syntaxe

- -
Math.atanh(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

L'arc tangente hyperbolique du nombre passé en argument.

- -

Description

- -

atanh() est une méthode statique de Math, il faut utiliser la syntaxe Math.atanh(), et non pas une méthode d'un objet Math créé sur mesure (Math n'est pas un constructeur).

- -

Exemple

- -

Utiliser Math.atanh()

- -
Math.atanh(-2);  // NaN
-Math.atanh(-1);  // -Infinity
-Math.atanh(0);   // 0
-Math.atanh(0.5); // 0.5493061443340548
-Math.atanh(1);   // Infinity
-Math.atanh(2);   // NaN
-
- -

Pour les valeurs strictement inférieures à -1 ou strictement supérieures à 1, {{jsxref("NaN")}} sera renvoyé.

- -

Prothèse d'émulation (polyfill)

- -

Pour |x|<1\left|x\right| < 1, on a la formule suivante : artanh(x)=12ln(1+x1-x)\operatorname {artanh} (x) = \frac{1}{2}\ln \left( \frac{1 + x}{1 - x} \right)et on peut donc émuler la fonction avec :

- -
Math.atanh = Math.atanh || function(x) {
-  return Math.log((1+x)/(1-x)) / 2;
-};
-
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - -
SpécificationStatutCommentaires
{{SpecName('ES6', '#sec-math.atanh', 'Math.atanh')}}{{Spec2('ES6')}}Définition initiale.
{{SpecName('ESDraft', '#sec-math.atanh', 'Math.atanh')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/atanh/index.md b/files/fr/web/javascript/reference/global_objects/math/atanh/index.md new file mode 100644 index 0000000000..f159f35630 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/atanh/index.md @@ -0,0 +1,99 @@ +--- +title: Math.atanh() +slug: Web/JavaScript/Reference/Global_Objects/Math/atanh +tags: + - JavaScript + - Math + - Méthode + - Reference + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Math/atanh +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/atanh +--- +
{{JSRef}}
+ +

La fonction Math.atanh() renvoie l'arc tangente hyperbolique d'un nombre :

+ +

x(-1,1),Math.atanh(x)=arctanh(x)= le seul y  tel quetanh(y)=x\forall x \in \left( -1, 1 \right), \mathtt{\operatorname{Math.atanh}(x)} = \operatorname{arctanh}(x) = \text{ the unique } \; y \; \text{such that} \; \tanh(y) = x

+ +
{{EmbedInteractiveExample("pages/js/math-atanh.html")}}
+ +

Syntaxe

+ +
Math.atanh(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

L'arc tangente hyperbolique du nombre passé en argument.

+ +

Description

+ +

atanh() est une méthode statique de Math, il faut utiliser la syntaxe Math.atanh(), et non pas une méthode d'un objet Math créé sur mesure (Math n'est pas un constructeur).

+ +

Exemple

+ +

Utiliser Math.atanh()

+ +
Math.atanh(-2);  // NaN
+Math.atanh(-1);  // -Infinity
+Math.atanh(0);   // 0
+Math.atanh(0.5); // 0.5493061443340548
+Math.atanh(1);   // Infinity
+Math.atanh(2);   // NaN
+
+ +

Pour les valeurs strictement inférieures à -1 ou strictement supérieures à 1, {{jsxref("NaN")}} sera renvoyé.

+ +

Prothèse d'émulation (polyfill)

+ +

Pour |x|<1\left|x\right| < 1, on a la formule suivante : artanh(x)=12ln(1+x1-x)\operatorname {artanh} (x) = \frac{1}{2}\ln \left( \frac{1 + x}{1 - x} \right)et on peut donc émuler la fonction avec :

+ +
Math.atanh = Math.atanh || function(x) {
+  return Math.log((1+x)/(1-x)) / 2;
+};
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaires
{{SpecName('ES6', '#sec-math.atanh', 'Math.atanh')}}{{Spec2('ES6')}}Définition initiale.
{{SpecName('ESDraft', '#sec-math.atanh', 'Math.atanh')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/cbrt/index.html b/files/fr/web/javascript/reference/global_objects/math/cbrt/index.html deleted file mode 100644 index fb9daa3cc0..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/cbrt/index.html +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: Math.cbrt() -slug: Web/JavaScript/Reference/Global_Objects/Math/cbrt -tags: - - ECMAScript 2015 - - JavaScript - - Math - - Méthode - - Reference - - polyfill -translation_of: Web/JavaScript/Reference/Global_Objects/Math/cbrt -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/cbrt ---- -
{{JSRef}}
- -

La fonction Math.cbrt() renvoie la racine cubique (le nom anglais étant cubic root) d'un nombre :

- -

Math.cbrt(x)=x3=le seulytel quey3=x\mathtt{Math.cbrt(x)} = \sqrt[3]{x} = \text{the unique} \; y \; \text{such that} \; y^3 = x

- -
{{EmbedInteractiveExample("pages/js/math-cbrt.html")}}
- -

Syntaxe

- -
Math.cbrt(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

La racine cubique du nombre passé en argument.

- -

Description

- -

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

- -

Exemple

- -

Utiliser Math.cbrt()

- -
Math.cbrt(NaN); // NaN
-Math.cbrt(-1); // -1
-Math.cbrt(-0); // -0
-Math.cbrt(-Infinity); // -Infinity
-Math.cbrt(0); // 0
-Math.cbrt(1); // 1
-Math.cbrt(Infinity); // Infinity
-Math.cbrt(null); // 0
-Math.cbrt(2);  // 1.2599210498948732
- -

Spécifications

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

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/cbrt/index.md b/files/fr/web/javascript/reference/global_objects/math/cbrt/index.md new file mode 100644 index 0000000000..fb9daa3cc0 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/cbrt/index.md @@ -0,0 +1,88 @@ +--- +title: Math.cbrt() +slug: Web/JavaScript/Reference/Global_Objects/Math/cbrt +tags: + - ECMAScript 2015 + - JavaScript + - Math + - Méthode + - Reference + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Math/cbrt +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/cbrt +--- +
{{JSRef}}
+ +

La fonction Math.cbrt() renvoie la racine cubique (le nom anglais étant cubic root) d'un nombre :

+ +

Math.cbrt(x)=x3=le seulytel quey3=x\mathtt{Math.cbrt(x)} = \sqrt[3]{x} = \text{the unique} \; y \; \text{such that} \; y^3 = x

+ +
{{EmbedInteractiveExample("pages/js/math-cbrt.html")}}
+ +

Syntaxe

+ +
Math.cbrt(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

La racine cubique du nombre passé en argument.

+ +

Description

+ +

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

+ +

Exemple

+ +

Utiliser Math.cbrt()

+ +
Math.cbrt(NaN); // NaN
+Math.cbrt(-1); // -1
+Math.cbrt(-0); // -0
+Math.cbrt(-Infinity); // -Infinity
+Math.cbrt(0); // 0
+Math.cbrt(1); // 1
+Math.cbrt(Infinity); // Infinity
+Math.cbrt(null); // 0
+Math.cbrt(2);  // 1.2599210498948732
+ +

Spécifications

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

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/ceil/index.html b/files/fr/web/javascript/reference/global_objects/math/ceil/index.html deleted file mode 100644 index 93e8919368..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/ceil/index.html +++ /dev/null @@ -1,174 +0,0 @@ ---- -title: Math.ceil() -slug: Web/JavaScript/Reference/Global_Objects/Math/ceil -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/ceil -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/ceil ---- -
{{JSRef}}
- -

La fonction Math.ceil() retourne le plus petit entier supérieur ou égal au nombre donné.

- -
{{EmbedInteractiveExample("pages/js/math-ceil.html")}}
- -

Syntaxe

- -
Math.ceil(x) 
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

Le plus petit entier qui est supérieur ou égal au nombre donné.

- -

Description

- -

ceil() est une méthode statique de Math. Elle doit être utilisée avec la syntaxe Math.ceil(), plutôt que comme une méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

- -
-

Note : Math.ceil(null) renverra 0 et pas {{jsxref("NaN")}}.

-
- -

Exemples

- -

Utiliser Math.ceil()

- -

Voici un exemple d'utilisation de Math.ceil().

- -
Math.ceil(.95);    // 1
-Math.ceil(4);      // 4
-Math.ceil(7.004);  // 8
-Math.ceil(-0.95);  // -0
-Math.ceil(-4);     // -4
-Math.ceil(-7.004); // -7
-Math.ceil(null);   // 0
- -

Arrondi décimal

- -
// Fermeture
-(function(){
-
-	/**
-	 * Fonction pour arrondir un nombre.
-	 *
-	 * @param	{String}	type	Le type d'arrondi.
-	 * @param	{Number}	value	Le nombre à arrondir.
-	 * @param	{Integer}	exp		L'exposant (le logarithme en base 10 de la base pour l'arrondi).
-	 * @returns	{Number}			La valeur arrondie.
-	 */
-	function decimalAdjust(type, value, exp) {
-		// Si l'exposant vaut undefined ou zero...
-		if (typeof exp === 'undefined' || +exp === 0) {
-			return Math[type](value);
-		}
-		value = +value;
-		exp = +exp;
-		// Si value n'est pas un nombre
-        // ou si l'exposant n'est pas entier
-		if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) {
-			return NaN;
-		}
-		// Décalage
-		value = value.toString().split('e');
-		value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp)));
-		// Re "calage"
-		value = value.toString().split('e');
-		return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp));
-	}
-
-	// Arrondi décimal
-	if (!Math.round10) {
-		Math.round10 = function(value, exp) {
-			return decimalAdjust('round', value, exp);
-		};
-	}
-	// Arrondi décimal inférieur
-	if (!Math.floor10) {
-		Math.floor10 = function(value, exp) {
-			return decimalAdjust('floor', value, exp);
-		};
-	}
-	// Arrondi décimal supérieur
-	if (!Math.ceil10) {
-		Math.ceil10 = function(value, exp) {
-			return decimalAdjust('ceil', value, exp);
-		};
-	}
-
-})();
-
-// Arrondi décimal
-Math.round10(55.55, -1); // 55.6
-Math.round10(55.549, -1); // 55.5
-Math.round10(55, 1); // 60
-Math.round10(54.9, 1); // 50
-Math.round10(-55.55, -1); // -55.5
-Math.round10(-55.551, -1); // -55.6
-Math.round10(-55, 1); // -50
-Math.round10(-55.1, 1); // -60
-// Arrondi décimal inférieur
-Math.floor10(55.59, -1); // 55.5
-Math.floor10(59, 1); // 50
-Math.floor10(-55.51, -1); // -55.6
-Math.floor10(-51, 1); // -60
-// Arrondi décimal supérieur
-Math.ceil10(55.51, -1); // 55.6
-Math.ceil10(51, 1); // 60
-Math.ceil10(-55.59, -1); // -55.5
-Math.ceil10(-59, 1); // -50
-
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.6', 'Math.ceil')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-math.ceil', 'Math.ceil')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-math.ceil', 'Math.ceil')}}{{Spec2('ESDraft')}}
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/ceil/index.md b/files/fr/web/javascript/reference/global_objects/math/ceil/index.md new file mode 100644 index 0000000000..93e8919368 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/ceil/index.md @@ -0,0 +1,174 @@ +--- +title: Math.ceil() +slug: Web/JavaScript/Reference/Global_Objects/Math/ceil +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/ceil +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/ceil +--- +
{{JSRef}}
+ +

La fonction Math.ceil() retourne le plus petit entier supérieur ou égal au nombre donné.

+ +
{{EmbedInteractiveExample("pages/js/math-ceil.html")}}
+ +

Syntaxe

+ +
Math.ceil(x) 
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

Le plus petit entier qui est supérieur ou égal au nombre donné.

+ +

Description

+ +

ceil() est une méthode statique de Math. Elle doit être utilisée avec la syntaxe Math.ceil(), plutôt que comme une méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

+ +
+

Note : Math.ceil(null) renverra 0 et pas {{jsxref("NaN")}}.

+
+ +

Exemples

+ +

Utiliser Math.ceil()

+ +

Voici un exemple d'utilisation de Math.ceil().

+ +
Math.ceil(.95);    // 1
+Math.ceil(4);      // 4
+Math.ceil(7.004);  // 8
+Math.ceil(-0.95);  // -0
+Math.ceil(-4);     // -4
+Math.ceil(-7.004); // -7
+Math.ceil(null);   // 0
+ +

Arrondi décimal

+ +
// Fermeture
+(function(){
+
+	/**
+	 * Fonction pour arrondir un nombre.
+	 *
+	 * @param	{String}	type	Le type d'arrondi.
+	 * @param	{Number}	value	Le nombre à arrondir.
+	 * @param	{Integer}	exp		L'exposant (le logarithme en base 10 de la base pour l'arrondi).
+	 * @returns	{Number}			La valeur arrondie.
+	 */
+	function decimalAdjust(type, value, exp) {
+		// Si l'exposant vaut undefined ou zero...
+		if (typeof exp === 'undefined' || +exp === 0) {
+			return Math[type](value);
+		}
+		value = +value;
+		exp = +exp;
+		// Si value n'est pas un nombre
+        // ou si l'exposant n'est pas entier
+		if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) {
+			return NaN;
+		}
+		// Décalage
+		value = value.toString().split('e');
+		value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp)));
+		// Re "calage"
+		value = value.toString().split('e');
+		return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp));
+	}
+
+	// Arrondi décimal
+	if (!Math.round10) {
+		Math.round10 = function(value, exp) {
+			return decimalAdjust('round', value, exp);
+		};
+	}
+	// Arrondi décimal inférieur
+	if (!Math.floor10) {
+		Math.floor10 = function(value, exp) {
+			return decimalAdjust('floor', value, exp);
+		};
+	}
+	// Arrondi décimal supérieur
+	if (!Math.ceil10) {
+		Math.ceil10 = function(value, exp) {
+			return decimalAdjust('ceil', value, exp);
+		};
+	}
+
+})();
+
+// Arrondi décimal
+Math.round10(55.55, -1); // 55.6
+Math.round10(55.549, -1); // 55.5
+Math.round10(55, 1); // 60
+Math.round10(54.9, 1); // 50
+Math.round10(-55.55, -1); // -55.5
+Math.round10(-55.551, -1); // -55.6
+Math.round10(-55, 1); // -50
+Math.round10(-55.1, 1); // -60
+// Arrondi décimal inférieur
+Math.floor10(55.59, -1); // 55.5
+Math.floor10(59, 1); // 50
+Math.floor10(-55.51, -1); // -55.6
+Math.floor10(-51, 1); // -60
+// Arrondi décimal supérieur
+Math.ceil10(55.51, -1); // 55.6
+Math.ceil10(51, 1); // 60
+Math.ceil10(-55.59, -1); // -55.5
+Math.ceil10(-59, 1); // -50
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.6', 'Math.ceil')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-math.ceil', 'Math.ceil')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-math.ceil', 'Math.ceil')}}{{Spec2('ESDraft')}}
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/clz32/index.html b/files/fr/web/javascript/reference/global_objects/math/clz32/index.html deleted file mode 100644 index c3298823a6..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/clz32/index.html +++ /dev/null @@ -1,92 +0,0 @@ ---- -title: Math.clz32() -slug: Web/JavaScript/Reference/Global_Objects/Math/clz32 -tags: - - ECMAScript 2015 - - JavaScript - - Math - - Méthode - - Reference - - polyfill -translation_of: Web/JavaScript/Reference/Global_Objects/Math/clz32 -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/clz32 ---- -
{{JSRef}}
- -

La fonction Math.clz32() renvoie le nombre de zéros de tête dans la représentation binaire sur 32 bits d'un nombre.

- -
{{EmbedInteractiveExample("pages/js/math-clz32.html")}}
- -

Syntaxe

- -
Math.clz32(x)
-
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur retournée

- -

Le nombre de bits à zéro en tête de la représentation binaire sur 32 bits du nombre donné.

- -

Description

- -

"clz32" est un raccourci pour CountLeadingZeroes32 (en français, « compter les zéros de tête »).

- -

Si x n'est pas un nombre, il sera d'abord converti en nombre puis converti en un entier non signé sur 32 bits.

- -

Si l'entier non signé sur 32 bits résultant vaut 0, la fonction renverra 32, car tous les bits valent 0.

- -

Cette fonction est particulièrement utile aux systèmes qui compilent du code JavaScript, comme Emscripten.

- -

Exemples

- -
Math.clz32(1)                // 31
-Math.clz32(1000)             // 22
-Math.clz32()                 // 32
-
-var liste = [NaN, Infinity, -Infinity, 0, -0, null, undefined, 'machin', {}, []];
-liste.every(n => Math.clz32(n) == 32); // true
-
-Math.clz32(true)             // 31
-Math.clz32(3.5)              // 30
-
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - -
SpécificationStatutCommentaire
{{SpecName('ES2015', '#sec-math.clz32', 'Math.clz32')}}{{Spec2('ES2015')}}Définition initiale.
{{SpecName('ESDraft', '#sec-math.clz32', 'Math.clz32')}}{{Spec2('ESDraft')}}
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/clz32/index.md b/files/fr/web/javascript/reference/global_objects/math/clz32/index.md new file mode 100644 index 0000000000..c3298823a6 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/clz32/index.md @@ -0,0 +1,92 @@ +--- +title: Math.clz32() +slug: Web/JavaScript/Reference/Global_Objects/Math/clz32 +tags: + - ECMAScript 2015 + - JavaScript + - Math + - Méthode + - Reference + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Math/clz32 +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/clz32 +--- +
{{JSRef}}
+ +

La fonction Math.clz32() renvoie le nombre de zéros de tête dans la représentation binaire sur 32 bits d'un nombre.

+ +
{{EmbedInteractiveExample("pages/js/math-clz32.html")}}
+ +

Syntaxe

+ +
Math.clz32(x)
+
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur retournée

+ +

Le nombre de bits à zéro en tête de la représentation binaire sur 32 bits du nombre donné.

+ +

Description

+ +

"clz32" est un raccourci pour CountLeadingZeroes32 (en français, « compter les zéros de tête »).

+ +

Si x n'est pas un nombre, il sera d'abord converti en nombre puis converti en un entier non signé sur 32 bits.

+ +

Si l'entier non signé sur 32 bits résultant vaut 0, la fonction renverra 32, car tous les bits valent 0.

+ +

Cette fonction est particulièrement utile aux systèmes qui compilent du code JavaScript, comme Emscripten.

+ +

Exemples

+ +
Math.clz32(1)                // 31
+Math.clz32(1000)             // 22
+Math.clz32()                 // 32
+
+var liste = [NaN, Infinity, -Infinity, 0, -0, null, undefined, 'machin', {}, []];
+liste.every(n => Math.clz32(n) == 32); // true
+
+Math.clz32(true)             // 31
+Math.clz32(3.5)              // 30
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaire
{{SpecName('ES2015', '#sec-math.clz32', 'Math.clz32')}}{{Spec2('ES2015')}}Définition initiale.
{{SpecName('ESDraft', '#sec-math.clz32', 'Math.clz32')}}{{Spec2('ESDraft')}}
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/cos/index.html b/files/fr/web/javascript/reference/global_objects/math/cos/index.html deleted file mode 100644 index 2015708e27..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/cos/index.html +++ /dev/null @@ -1,95 +0,0 @@ ---- -title: Math.cos() -slug: Web/JavaScript/Reference/Global_Objects/Math/cos -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/cos -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/cos ---- -
{{JSRef}}
- -

La fonction Math.cos() retourne le cosinus d'un angle dont la valeur est exprimée en radians.

- -
{{EmbedInteractiveExample("pages/js/math-cos.html")}}
- -

Syntaxe

- -
Math.cos(x)
- -

Paramètres

- -
-
x
-
Une valeur numérique (exprimée en radians).
-
- -

Valeur de retour

- -

Le cosinus de l'angle fourni en argument (exprimé en radians).

- -

Description

- -

La méthode Math.cos() renvoie une valeur numérique comprise entre -1 et 1. Cela représente la valeur du cosinus de l'angle correspondant à cette valeur.

- -

cos est une méthode statique de Math, elle doit toujours être utilisée avec la syntaxe Math.cos(), ne pas utiliser une méthode d'un objet qui aurait été créé (Math n'est pas un constructeur).

- -

Exemples

- -

Utiliser Math.cos()

- -
Math.cos(0);           // 1
-Math.cos(1);           // 0.5403023058681398
-
-Math.cos(Math.PI);     // -1
-Math.cos(2 * Math.PI); // 1
-
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.7', 'Math.cos')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.cos', 'Math.cos')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.cos', 'Math.cos')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/cos/index.md b/files/fr/web/javascript/reference/global_objects/math/cos/index.md new file mode 100644 index 0000000000..2015708e27 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/cos/index.md @@ -0,0 +1,95 @@ +--- +title: Math.cos() +slug: Web/JavaScript/Reference/Global_Objects/Math/cos +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/cos +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/cos +--- +
{{JSRef}}
+ +

La fonction Math.cos() retourne le cosinus d'un angle dont la valeur est exprimée en radians.

+ +
{{EmbedInteractiveExample("pages/js/math-cos.html")}}
+ +

Syntaxe

+ +
Math.cos(x)
+ +

Paramètres

+ +
+
x
+
Une valeur numérique (exprimée en radians).
+
+ +

Valeur de retour

+ +

Le cosinus de l'angle fourni en argument (exprimé en radians).

+ +

Description

+ +

La méthode Math.cos() renvoie une valeur numérique comprise entre -1 et 1. Cela représente la valeur du cosinus de l'angle correspondant à cette valeur.

+ +

cos est une méthode statique de Math, elle doit toujours être utilisée avec la syntaxe Math.cos(), ne pas utiliser une méthode d'un objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Exemples

+ +

Utiliser Math.cos()

+ +
Math.cos(0);           // 1
+Math.cos(1);           // 0.5403023058681398
+
+Math.cos(Math.PI);     // -1
+Math.cos(2 * Math.PI); // 1
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.7', 'Math.cos')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.cos', 'Math.cos')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.cos', 'Math.cos')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/cosh/index.html b/files/fr/web/javascript/reference/global_objects/math/cosh/index.html deleted file mode 100644 index 76c7d9fe17..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/cosh/index.html +++ /dev/null @@ -1,103 +0,0 @@ ---- -title: Math.cosh() -slug: Web/JavaScript/Reference/Global_Objects/Math/cosh -tags: - - ECMAScript6 - - JavaScript - - Math - - Méthode - - Reference - - polyfill -translation_of: Web/JavaScript/Reference/Global_Objects/Math/cosh -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/cosh ---- -
{{JSRef}}
- -

La fonction Math.cosh() renvoie le cosinus hyperbolique d'un nombre, défini par :

- -

Math.cosh(x)=ex+e-x2\mathtt{\operatorname{Math.cosh(x)}} = \frac{e^x + e^{-x}}{2}

- -
{{EmbedInteractiveExample("pages/js/math-cosh.html")}}
- - - -

(Voir la page sur {{jsxref("Objets_globaux/Math/E","e","",1)}})

- -

Syntaxe

- -
Math.cosh(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

Le cosinus hyperbolique du nombre passé en argument.

- -

Description

- -

cosh() étant une méthode statique de Math, il faut utiliser Math.cosh() et non pas la méthode d'un objet Math créé sur mesure (Math n'est pas un constructeur).

- -

Exemple

- -

Utiliser Math.cosh()

- -
Math.cosh(0);  // 1
-Math.cosh(1);  // 1.5430806348152437
-Math.cosh(-1); // 1.5430806348152437
-
- -

Prothèse d'émulation (polyfill)

- -

Cette fonction peut être émulée grâce à la fonction {{jsxref("Objets_globaux/Math/exp", "Math.exp()")}} :

- -
Math.cosh = Math.cosh || function(x) {
-    return (Math.exp(x) + Math.exp(-x)) / 2;
-}
- -

On peut également utiliser un unique appel à {{jsxref("Objets_globaux/Math/exp", "exp()")}} :

- -
Math.cosh = Math.cosh || function(x) {
-    var y = Math.exp(x);
-    return (y + 1 / y) / 2;
-}
- -

Spécifications

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

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/cosh/index.md b/files/fr/web/javascript/reference/global_objects/math/cosh/index.md new file mode 100644 index 0000000000..76c7d9fe17 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/cosh/index.md @@ -0,0 +1,103 @@ +--- +title: Math.cosh() +slug: Web/JavaScript/Reference/Global_Objects/Math/cosh +tags: + - ECMAScript6 + - JavaScript + - Math + - Méthode + - Reference + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Math/cosh +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/cosh +--- +
{{JSRef}}
+ +

La fonction Math.cosh() renvoie le cosinus hyperbolique d'un nombre, défini par :

+ +

Math.cosh(x)=ex+e-x2\mathtt{\operatorname{Math.cosh(x)}} = \frac{e^x + e^{-x}}{2}

+ +
{{EmbedInteractiveExample("pages/js/math-cosh.html")}}
+ + + +

(Voir la page sur {{jsxref("Objets_globaux/Math/E","e","",1)}})

+ +

Syntaxe

+ +
Math.cosh(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

Le cosinus hyperbolique du nombre passé en argument.

+ +

Description

+ +

cosh() étant une méthode statique de Math, il faut utiliser Math.cosh() et non pas la méthode d'un objet Math créé sur mesure (Math n'est pas un constructeur).

+ +

Exemple

+ +

Utiliser Math.cosh()

+ +
Math.cosh(0);  // 1
+Math.cosh(1);  // 1.5430806348152437
+Math.cosh(-1); // 1.5430806348152437
+
+ +

Prothèse d'émulation (polyfill)

+ +

Cette fonction peut être émulée grâce à la fonction {{jsxref("Objets_globaux/Math/exp", "Math.exp()")}} :

+ +
Math.cosh = Math.cosh || function(x) {
+    return (Math.exp(x) + Math.exp(-x)) / 2;
+}
+ +

On peut également utiliser un unique appel à {{jsxref("Objets_globaux/Math/exp", "exp()")}} :

+ +
Math.cosh = Math.cosh || function(x) {
+    var y = Math.exp(x);
+    return (y + 1 / y) / 2;
+}
+ +

Spécifications

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

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/e/index.html b/files/fr/web/javascript/reference/global_objects/math/e/index.html deleted file mode 100644 index f4df99a2cb..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/e/index.html +++ /dev/null @@ -1,82 +0,0 @@ ---- -title: Math.E -slug: Web/JavaScript/Reference/Global_Objects/Math/E -tags: - - JavaScript - - Math - - Propriété - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/E -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/E ---- -
{{JSRef}}
- -

La propriété Math.E représente la base du logarithme naturel, e, et vaut environ 2.718.

- -

Math.E=e2.718\mathtt{\mi{Math.E}} = e \approx 2.718

- -
{{EmbedInteractiveExample("pages/js/math-e.html")}}
- - - -
{{js_property_attributes(0,0,0)}}
- -

Description

- -

E étant une propriété statique de Math, il doit toujours être utilisé avec la syntaxe Math.E, et non pas être appelé comme propriété d'un autre objet Math qui aurait été créé (Math n'est pas un constructeur).

- -

Exemples

- -

Utiliser Math.E

- -

La fonction suivante renvoie la valeur de e :

- -
function getNapier() {
-   return Math.E;
-}
-
-getNapier(); // 2.718281828459045
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.1', 'Math.E')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.e', 'Math.E')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.e', 'Math.E')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/e/index.md b/files/fr/web/javascript/reference/global_objects/math/e/index.md new file mode 100644 index 0000000000..f4df99a2cb --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/e/index.md @@ -0,0 +1,82 @@ +--- +title: Math.E +slug: Web/JavaScript/Reference/Global_Objects/Math/E +tags: + - JavaScript + - Math + - Propriété + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/E +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/E +--- +
{{JSRef}}
+ +

La propriété Math.E représente la base du logarithme naturel, e, et vaut environ 2.718.

+ +

Math.E=e2.718\mathtt{\mi{Math.E}} = e \approx 2.718

+ +
{{EmbedInteractiveExample("pages/js/math-e.html")}}
+ + + +
{{js_property_attributes(0,0,0)}}
+ +

Description

+ +

E étant une propriété statique de Math, il doit toujours être utilisé avec la syntaxe Math.E, et non pas être appelé comme propriété d'un autre objet Math qui aurait été créé (Math n'est pas un constructeur).

+ +

Exemples

+ +

Utiliser Math.E

+ +

La fonction suivante renvoie la valeur de e :

+ +
function getNapier() {
+   return Math.E;
+}
+
+getNapier(); // 2.718281828459045
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.1', 'Math.E')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.e', 'Math.E')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.e', 'Math.E')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/exp/index.html b/files/fr/web/javascript/reference/global_objects/math/exp/index.html deleted file mode 100644 index 29ac4ef407..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/exp/index.html +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: Math.exp() -slug: Web/JavaScript/Reference/Global_Objects/Math/exp -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/exp -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/exp ---- -
{{JSRef}}
- -

La fonction Math.exp() renvoie l'exponentielle d'un nombre (donnée par e^x, où x est la valeur passée en argument et e la valeur du {{jsxref("Objets_globaux/Math/E","nombre d'Euler (parfois appelé constante de Napier)","",1)}}.

- -
{{EmbedInteractiveExample("pages/js/math-exp.html")}}
- -

Syntaxe

- -
Math.exp(x)
- -

Paramètres

- -
-
x
-
-

Un nombre.

-
-
- -

Valeur de retour

- -

L'exponentielle du nombre passé en argument (e^x).

- -

Description

- -

exp() est une méthode statique de Math, elle doit toujours être utilisée avec la syntaxe Math.exp(), elle ne doit pas être utilisée avec un objet qui aurait été créé (Math n'est pas un constructeur).

- -

Exemples

- -

Utiliser Math.exp()

- -
Math.exp(-1); // 0.36787944117144233
-Math.exp(0);  // 1
-Math.exp(1);  // 2.718281828459045
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.8', 'Math.exp')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.exp', 'Math.exp')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.exp', 'Math.exp')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/exp/index.md b/files/fr/web/javascript/reference/global_objects/math/exp/index.md new file mode 100644 index 0000000000..29ac4ef407 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/exp/index.md @@ -0,0 +1,93 @@ +--- +title: Math.exp() +slug: Web/JavaScript/Reference/Global_Objects/Math/exp +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/exp +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/exp +--- +
{{JSRef}}
+ +

La fonction Math.exp() renvoie l'exponentielle d'un nombre (donnée par e^x, où x est la valeur passée en argument et e la valeur du {{jsxref("Objets_globaux/Math/E","nombre d'Euler (parfois appelé constante de Napier)","",1)}}.

+ +
{{EmbedInteractiveExample("pages/js/math-exp.html")}}
+ +

Syntaxe

+ +
Math.exp(x)
+ +

Paramètres

+ +
+
x
+
+

Un nombre.

+
+
+ +

Valeur de retour

+ +

L'exponentielle du nombre passé en argument (e^x).

+ +

Description

+ +

exp() est une méthode statique de Math, elle doit toujours être utilisée avec la syntaxe Math.exp(), elle ne doit pas être utilisée avec un objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Exemples

+ +

Utiliser Math.exp()

+ +
Math.exp(-1); // 0.36787944117144233
+Math.exp(0);  // 1
+Math.exp(1);  // 2.718281828459045
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.8', 'Math.exp')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.exp', 'Math.exp')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.exp', 'Math.exp')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/expm1/index.html b/files/fr/web/javascript/reference/global_objects/math/expm1/index.html deleted file mode 100644 index 372880a5df..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/expm1/index.html +++ /dev/null @@ -1,91 +0,0 @@ ---- -title: Math.expm1() -slug: Web/JavaScript/Reference/Global_Objects/Math/expm1 -tags: - - ECMAScript6 - - JavaScript - - Math - - Méthode - - Reference - - polyfill -translation_of: Web/JavaScript/Reference/Global_Objects/Math/expm1 -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/expm1 ---- -
{{JSRef}}
- -

La fonction Math.expm1() renvoie e^x - 1, avec x l'argument donné et {{jsxref("Objets_globaux/Math/E","e")}} la base du logarithme nepérien.

- -
{{EmbedInteractiveExample("pages/js/math-expm1.html")}}
- -

Syntaxe

- -
Math.expm1(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

Un nombre qui représente e^x- 1x est la valeur passée en argument et e^x l'exponentielle du nombre.

- -

Description

- -

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

- -

Exemple

- -

Utiliser Math.expm1()

- -
Math.expm1(-1); // -0.6321205588285577
-Math.expm1(0);  // 0
-Math.expm1(1);  // 1.718281828459045
- -

Prothèse d'émulation (polyfill)

- -

Cette fonction peut être émulée en utilisant la fonction {{jsxref("Objets_globaux/Math/exp", "Math.exp()")}} :

- -
Math.expm1 = Math.expm1 || function(x) {
-    return Math.exp(x) - 1;
-};
- -

Spécifications

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

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/expm1/index.md b/files/fr/web/javascript/reference/global_objects/math/expm1/index.md new file mode 100644 index 0000000000..372880a5df --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/expm1/index.md @@ -0,0 +1,91 @@ +--- +title: Math.expm1() +slug: Web/JavaScript/Reference/Global_Objects/Math/expm1 +tags: + - ECMAScript6 + - JavaScript + - Math + - Méthode + - Reference + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Math/expm1 +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/expm1 +--- +
{{JSRef}}
+ +

La fonction Math.expm1() renvoie e^x - 1, avec x l'argument donné et {{jsxref("Objets_globaux/Math/E","e")}} la base du logarithme nepérien.

+ +
{{EmbedInteractiveExample("pages/js/math-expm1.html")}}
+ +

Syntaxe

+ +
Math.expm1(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

Un nombre qui représente e^x- 1x est la valeur passée en argument et e^x l'exponentielle du nombre.

+ +

Description

+ +

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

+ +

Exemple

+ +

Utiliser Math.expm1()

+ +
Math.expm1(-1); // -0.6321205588285577
+Math.expm1(0);  // 0
+Math.expm1(1);  // 1.718281828459045
+ +

Prothèse d'émulation (polyfill)

+ +

Cette fonction peut être émulée en utilisant la fonction {{jsxref("Objets_globaux/Math/exp", "Math.exp()")}} :

+ +
Math.expm1 = Math.expm1 || function(x) {
+    return Math.exp(x) - 1;
+};
+ +

Spécifications

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

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/floor/index.html b/files/fr/web/javascript/reference/global_objects/math/floor/index.html deleted file mode 100644 index 4b9a6e5422..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/floor/index.html +++ /dev/null @@ -1,97 +0,0 @@ ---- -title: Math.floor() -slug: Web/JavaScript/Reference/Global_Objects/Math/floor -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/floor -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/floor ---- -
{{JSRef}}
- -

La fonction Math.floor(x) renvoie le plus grand entier qui est inférieur ou égal à un nombre x.

- -
{{EmbedInteractiveExample("pages/js/math-floor.html")}}
- -

Syntaxe

- -
Math.floor(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

Un nombre qui représente le plus grand entier inférieur ou égal à la valeur passée en argument.

- -

Description

- -

floor() est une méthode statique de l'objet Math, elle doit toujours être utilisée avec la syntaxe  Math.floor(), elle ne doit pas être utilisée avec un autre objet qui aurait été créé (Math n'est pas un constructeur).

- -
-

Note : Math.floor(null) renvoie 0 et pas {{jsxref("NaN")}}.

-
- -

Exemples

- -

Utiliser Math.floor

- -
Math.floor( 45.95); //  45
-Math.floor( 45.05); //  45
-Math.floor(  4   ); //   4
-Math.floor(-45.05); // -46
-Math.floor(-45.95); // -46
-Math.floor(null);   // 0
-
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.9', 'Math.floor')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-math.floor', 'Math.floor')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-math.floor', 'Math.floor')}}{{Spec2('ESDraft')}}
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/floor/index.md b/files/fr/web/javascript/reference/global_objects/math/floor/index.md new file mode 100644 index 0000000000..4b9a6e5422 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/floor/index.md @@ -0,0 +1,97 @@ +--- +title: Math.floor() +slug: Web/JavaScript/Reference/Global_Objects/Math/floor +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/floor +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/floor +--- +
{{JSRef}}
+ +

La fonction Math.floor(x) renvoie le plus grand entier qui est inférieur ou égal à un nombre x.

+ +
{{EmbedInteractiveExample("pages/js/math-floor.html")}}
+ +

Syntaxe

+ +
Math.floor(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

Un nombre qui représente le plus grand entier inférieur ou égal à la valeur passée en argument.

+ +

Description

+ +

floor() est une méthode statique de l'objet Math, elle doit toujours être utilisée avec la syntaxe  Math.floor(), elle ne doit pas être utilisée avec un autre objet qui aurait été créé (Math n'est pas un constructeur).

+ +
+

Note : Math.floor(null) renvoie 0 et pas {{jsxref("NaN")}}.

+
+ +

Exemples

+ +

Utiliser Math.floor

+ +
Math.floor( 45.95); //  45
+Math.floor( 45.05); //  45
+Math.floor(  4   ); //   4
+Math.floor(-45.05); // -46
+Math.floor(-45.95); // -46
+Math.floor(null);   // 0
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.9', 'Math.floor')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-math.floor', 'Math.floor')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-math.floor', 'Math.floor')}}{{Spec2('ESDraft')}}
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/fround/index.html b/files/fr/web/javascript/reference/global_objects/math/fround/index.html deleted file mode 100644 index 6b5ec47735..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/fround/index.html +++ /dev/null @@ -1,86 +0,0 @@ ---- -title: Math.fround() -slug: Web/JavaScript/Reference/Global_Objects/Math/fround -tags: - - ECMAScript6 - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/fround -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/fround ---- -
{{JSRef}}
- -

La fonction Math.fround() renvoie le nombre flottant à précision simple sur 32 bits qui est le plus proche du nombre fourni.

- -
{{EmbedInteractiveExample("pages/js/math-fround.html")}}
- -

Syntaxe

- -
Math.fround(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

Le nombre flottant à précision simple sur 32 bits qui est le plus proche de la valeur fournie en argument.

- -

Description

- -

Un moteur JavaScript utilise des nombres flottant à précision simple sur 64 bits. Cela permet d'obtenir une précision fine. Toutefois, lorsqu'on manipule des valeurs représentées sur 32 bits (par exemple des valeurs extraites d'un {{jsxref("Float32Array")}}) et qu'on souhaite comparer celles-ci avec des valeurs sur 32 bits, on peut obtenir des inégalités alors que les valeurs semblent identiques.

- -

Pour résoudre ce problème, on peut utiliser Math.fround() afin de transformer un nombre représenté sur 64 bits en un nombre représenté sur 32 bits. Pour le moteur JavaScript, la valeur sera toujours représentée sur 64 bits mais elle aura été « arrondie » à partir du 23e bit de la mantisse. Si le nombre passé en argument se situe en dehors de l'intervalle représentable sur 32 bits, la méthode renverra {{jsxref("Infinity")}} ou -Infinity.

- -

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

- -

Exemples

- -

Utiliser Math.fround()

- -
Math.fround(0);     // 0
-Math.fround(1);     // 1
-
-// 1.337 ne peut pas être représenté correctement
-// sur 32 bits
-Math.fround(1.337); // 1.3370000123977661
-
-Math.fround(1.5);   // 1.5
-Math.fround(NaN);   // NaN
- -

Spécifications

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

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/fround/index.md b/files/fr/web/javascript/reference/global_objects/math/fround/index.md new file mode 100644 index 0000000000..6b5ec47735 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/fround/index.md @@ -0,0 +1,86 @@ +--- +title: Math.fround() +slug: Web/JavaScript/Reference/Global_Objects/Math/fround +tags: + - ECMAScript6 + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/fround +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/fround +--- +
{{JSRef}}
+ +

La fonction Math.fround() renvoie le nombre flottant à précision simple sur 32 bits qui est le plus proche du nombre fourni.

+ +
{{EmbedInteractiveExample("pages/js/math-fround.html")}}
+ +

Syntaxe

+ +
Math.fround(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

Le nombre flottant à précision simple sur 32 bits qui est le plus proche de la valeur fournie en argument.

+ +

Description

+ +

Un moteur JavaScript utilise des nombres flottant à précision simple sur 64 bits. Cela permet d'obtenir une précision fine. Toutefois, lorsqu'on manipule des valeurs représentées sur 32 bits (par exemple des valeurs extraites d'un {{jsxref("Float32Array")}}) et qu'on souhaite comparer celles-ci avec des valeurs sur 32 bits, on peut obtenir des inégalités alors que les valeurs semblent identiques.

+ +

Pour résoudre ce problème, on peut utiliser Math.fround() afin de transformer un nombre représenté sur 64 bits en un nombre représenté sur 32 bits. Pour le moteur JavaScript, la valeur sera toujours représentée sur 64 bits mais elle aura été « arrondie » à partir du 23e bit de la mantisse. Si le nombre passé en argument se situe en dehors de l'intervalle représentable sur 32 bits, la méthode renverra {{jsxref("Infinity")}} ou -Infinity.

+ +

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

+ +

Exemples

+ +

Utiliser Math.fround()

+ +
Math.fround(0);     // 0
+Math.fround(1);     // 1
+
+// 1.337 ne peut pas être représenté correctement
+// sur 32 bits
+Math.fround(1.337); // 1.3370000123977661
+
+Math.fround(1.5);   // 1.5
+Math.fround(NaN);   // NaN
+ +

Spécifications

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

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/hypot/index.html b/files/fr/web/javascript/reference/global_objects/math/hypot/index.html deleted file mode 100644 index bba9aaebe8..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/hypot/index.html +++ /dev/null @@ -1,126 +0,0 @@ ---- -title: Math.hypot() -slug: Web/JavaScript/Reference/Global_Objects/Math/hypot -tags: - - ECMAScript6 - - JavaScript - - Math - - Méthode - - Reference - - polyfill -translation_of: Web/JavaScript/Reference/Global_Objects/Math/hypot -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/hypot ---- -
{{JSRef}}
- -

La fonction Math.hypot() renvoie la racine carrée de la somme des carrés de ses arguments. On peut également la définir avec la formule suivante :

- -

Math.hypot(v1,v2,,vn)=i=1nvi2=v12+v22++vn2\mathtt{\operatorname{Math.hypot}(v_1, v_2, \dots, v_n)} = \sqrt{\sum_{i=1}^n v_i^2} = \sqrt{v_1^2 + v_2^2 + \dots + v_n^2}

- -
{{EmbedInteractiveExample("pages/js/math-hypot.html")}}
- -

Syntaxe

- -
Math.hypot([valeur1[,valeur2, ...]]) 
- -

Paramètres

- -
-
valeur1, valeur2, ...
-
Des nombres.
-
- -

Valeur de retour

- -

La racine carrée de la somme des carrés des arguments. S'il existe un des arguments qui ne peut pas être converti en un nombre, c'est la valeur {{jsxref("NaN")}} qui sera renvoyée.

- -

Description

- -

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

- -

Si aucun argument n'est donné, le résultat sera +0.Si, parmi les arguments, au moins un ne peut pas être converti en un nombre, le résultat sera {{jsxref("NaN")}}.Si cette fonction est utilisée avec un argument : Math.hypot(x) sera équivalente à Math.abs(x).

- -

Cette fonction permet entre autres de gérer certains cas où, pour les grands nombres, l'utilisation de {{jsxref("Math.sqrt()")}} aurait renvoyé {{jsxref("Infinity")}} à cause des calculs intermédiaires.

- -

Exemples

- -

Utiliser Math.hypot()

- -
Math.hypot(3, 4)        // 5
-Math.hypot(3, 4, 5)     // 7.0710678118654755
-Math.hypot()            // 0
-Math.hypot(NaN)         // NaN
-Math.hypot(3, 4, "toto") // NaN, +"toto" => NaN
-Math.hypot(3, 4, "5")   // 7.0710678118654755, +"5" => 5
-Math.hypot(-3)          // 3, the same as Math.abs(-3)
-
- -

Prothèse d'émulation (polyfill)

- -

Si elle n'est pas disponible, cette fonction peut être émulée de la façon suivante :

- -
Math.hypot =  Math.hypot || function() {
-    var y = 0;
-    var length = arguments.length;
-
-    for (var i = 0; i < length; i++) {
-      if(arguments[i] === Infinity || arguments[i] === -Infinity) {
-        return Infinity;
-      }
-      y += arguments[i] * arguments[i];
-    }
-    return Math.sqrt(y);
-};
-
- -

Voici une seconde version qui évite les dépassements :

- -
Math.hypot = function (x, y) {
-  // https://bugzilla.mozilla.org/show_bug.cgi?id=896264#c28
-  var max = 0;
-  var s = 0;
-  for (var i = 0; i < arguments.length; i += 1) {
-    var arg = Math.abs(Number(arguments[i]));
-    if (arg > max) {
-      s *= (max / arg) * (max / arg);
-      max = arg;
-    }
-    s += arg === 0 && max === 0 ? 0 : (arg / max) * (arg / max);
-  }
-  return max === 1 / 0 ? 1 / 0 : max * Math.sqrt(s);
-};
-
- -

Spécifications

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

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/hypot/index.md b/files/fr/web/javascript/reference/global_objects/math/hypot/index.md new file mode 100644 index 0000000000..bba9aaebe8 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/hypot/index.md @@ -0,0 +1,126 @@ +--- +title: Math.hypot() +slug: Web/JavaScript/Reference/Global_Objects/Math/hypot +tags: + - ECMAScript6 + - JavaScript + - Math + - Méthode + - Reference + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Math/hypot +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/hypot +--- +
{{JSRef}}
+ +

La fonction Math.hypot() renvoie la racine carrée de la somme des carrés de ses arguments. On peut également la définir avec la formule suivante :

+ +

Math.hypot(v1,v2,,vn)=i=1nvi2=v12+v22++vn2\mathtt{\operatorname{Math.hypot}(v_1, v_2, \dots, v_n)} = \sqrt{\sum_{i=1}^n v_i^2} = \sqrt{v_1^2 + v_2^2 + \dots + v_n^2}

+ +
{{EmbedInteractiveExample("pages/js/math-hypot.html")}}
+ +

Syntaxe

+ +
Math.hypot([valeur1[,valeur2, ...]]) 
+ +

Paramètres

+ +
+
valeur1, valeur2, ...
+
Des nombres.
+
+ +

Valeur de retour

+ +

La racine carrée de la somme des carrés des arguments. S'il existe un des arguments qui ne peut pas être converti en un nombre, c'est la valeur {{jsxref("NaN")}} qui sera renvoyée.

+ +

Description

+ +

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

+ +

Si aucun argument n'est donné, le résultat sera +0.Si, parmi les arguments, au moins un ne peut pas être converti en un nombre, le résultat sera {{jsxref("NaN")}}.Si cette fonction est utilisée avec un argument : Math.hypot(x) sera équivalente à Math.abs(x).

+ +

Cette fonction permet entre autres de gérer certains cas où, pour les grands nombres, l'utilisation de {{jsxref("Math.sqrt()")}} aurait renvoyé {{jsxref("Infinity")}} à cause des calculs intermédiaires.

+ +

Exemples

+ +

Utiliser Math.hypot()

+ +
Math.hypot(3, 4)        // 5
+Math.hypot(3, 4, 5)     // 7.0710678118654755
+Math.hypot()            // 0
+Math.hypot(NaN)         // NaN
+Math.hypot(3, 4, "toto") // NaN, +"toto" => NaN
+Math.hypot(3, 4, "5")   // 7.0710678118654755, +"5" => 5
+Math.hypot(-3)          // 3, the same as Math.abs(-3)
+
+ +

Prothèse d'émulation (polyfill)

+ +

Si elle n'est pas disponible, cette fonction peut être émulée de la façon suivante :

+ +
Math.hypot =  Math.hypot || function() {
+    var y = 0;
+    var length = arguments.length;
+
+    for (var i = 0; i < length; i++) {
+      if(arguments[i] === Infinity || arguments[i] === -Infinity) {
+        return Infinity;
+      }
+      y += arguments[i] * arguments[i];
+    }
+    return Math.sqrt(y);
+};
+
+ +

Voici une seconde version qui évite les dépassements :

+ +
Math.hypot = function (x, y) {
+  // https://bugzilla.mozilla.org/show_bug.cgi?id=896264#c28
+  var max = 0;
+  var s = 0;
+  for (var i = 0; i < arguments.length; i += 1) {
+    var arg = Math.abs(Number(arguments[i]));
+    if (arg > max) {
+      s *= (max / arg) * (max / arg);
+      max = arg;
+    }
+    s += arg === 0 && max === 0 ? 0 : (arg / max) * (arg / max);
+  }
+  return max === 1 / 0 ? 1 / 0 : max * Math.sqrt(s);
+};
+
+ +

Spécifications

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

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/imul/index.html b/files/fr/web/javascript/reference/global_objects/math/imul/index.html deleted file mode 100644 index bdfb591384..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/imul/index.html +++ /dev/null @@ -1,90 +0,0 @@ ---- -title: Math.imul() -slug: Web/JavaScript/Reference/Global_Objects/Math/imul -tags: - - JavaScript - - Math - - Méthode - - Reference - - polyfill -translation_of: Web/JavaScript/Reference/Global_Objects/Math/imul -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/imul ---- -
{{JSRef}}
- -

La fonction Math.imul() renvoie le résultat de la multiplication de deux nombres, calculée avec la représentation sur 32 bits de ces nombres, à la façon du langage C.

- -
{{EmbedInteractiveExample("pages/js/math-imul.html")}}
- -

Syntaxe

- -
Math.imul(a, b)
- -

Paramètres

- -
-
a
-
Le premier nombre.
-
b
-
Le second nombre.
-
- -

Valeur de retour

- -

Le résultat de la multiplication sur 32 bits des valeurs passées en argument (comme en C).

- -

Description

- -

Math.imul() permet d'effectuer une multiplication rapide pour des entiers sur 32 bits avec une sémantique proche du langage C. Cela est utile pour des aspects de performance, notamment pour des projets comme Emscripten. imul() étant une méthode statique de Math, il faut utiliser Math.imul() et non pas la méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur). Attention à l'utilisation de nombres flottants avec Math.imul() car cela implique une opération de conversion des flottants vers les entiers pour la multiplication puis une opération de conversion du résultat en flottant. Dans la pratique, Math.imul() est notamment pertinent pour asm.js.

- -

Exemples

- -

Utiliser Math.imul()

- -
Math.imul(2, 4);          // 8
-Math.imul(-1, 8);         //-8
-Math.imul(-2, -2);        // 4
-Math.imul(0xffffffff, 5); //-5
-Math.imul(0xfffffffe, 5); //-10
-
- -

Prothèse d'émulation (polyfill)

- -

Si elle n'est pas disponible, cette fonction peut être émulée de la façon suivante :

- -
Math.imul = Math.imul || function(a, b) {
-  var ah  = (a >>> 16) & 0xffff;
-  var al = a & 0xffff;
-  var bh  = (b >>> 16) & 0xffff;
-  var bl = b & 0xffff;
-  // Le décalage par 0 rétablit le signe de la partie haute
-  // le |0 final convertit la valeur non-signée en une valeur signée
-  return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
-};
-
- -

Spécifications

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

Compatibilité des navigateurs

- -

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

diff --git a/files/fr/web/javascript/reference/global_objects/math/imul/index.md b/files/fr/web/javascript/reference/global_objects/math/imul/index.md new file mode 100644 index 0000000000..bdfb591384 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/imul/index.md @@ -0,0 +1,90 @@ +--- +title: Math.imul() +slug: Web/JavaScript/Reference/Global_Objects/Math/imul +tags: + - JavaScript + - Math + - Méthode + - Reference + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Math/imul +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/imul +--- +
{{JSRef}}
+ +

La fonction Math.imul() renvoie le résultat de la multiplication de deux nombres, calculée avec la représentation sur 32 bits de ces nombres, à la façon du langage C.

+ +
{{EmbedInteractiveExample("pages/js/math-imul.html")}}
+ +

Syntaxe

+ +
Math.imul(a, b)
+ +

Paramètres

+ +
+
a
+
Le premier nombre.
+
b
+
Le second nombre.
+
+ +

Valeur de retour

+ +

Le résultat de la multiplication sur 32 bits des valeurs passées en argument (comme en C).

+ +

Description

+ +

Math.imul() permet d'effectuer une multiplication rapide pour des entiers sur 32 bits avec une sémantique proche du langage C. Cela est utile pour des aspects de performance, notamment pour des projets comme Emscripten. imul() étant une méthode statique de Math, il faut utiliser Math.imul() et non pas la méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur). Attention à l'utilisation de nombres flottants avec Math.imul() car cela implique une opération de conversion des flottants vers les entiers pour la multiplication puis une opération de conversion du résultat en flottant. Dans la pratique, Math.imul() est notamment pertinent pour asm.js.

+ +

Exemples

+ +

Utiliser Math.imul()

+ +
Math.imul(2, 4);          // 8
+Math.imul(-1, 8);         //-8
+Math.imul(-2, -2);        // 4
+Math.imul(0xffffffff, 5); //-5
+Math.imul(0xfffffffe, 5); //-10
+
+ +

Prothèse d'émulation (polyfill)

+ +

Si elle n'est pas disponible, cette fonction peut être émulée de la façon suivante :

+ +
Math.imul = Math.imul || function(a, b) {
+  var ah  = (a >>> 16) & 0xffff;
+  var al = a & 0xffff;
+  var bh  = (b >>> 16) & 0xffff;
+  var bl = b & 0xffff;
+  // Le décalage par 0 rétablit le signe de la partie haute
+  // le |0 final convertit la valeur non-signée en une valeur signée
+  return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
+};
+
+ +

Spécifications

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

Compatibilité des navigateurs

+ +

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

diff --git a/files/fr/web/javascript/reference/global_objects/math/index.html b/files/fr/web/javascript/reference/global_objects/math/index.html deleted file mode 100644 index 86ab1bee47..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/index.html +++ /dev/null @@ -1,170 +0,0 @@ ---- -title: Math -slug: Web/JavaScript/Reference/Global_Objects/Math -tags: - - JavaScript - - Math - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math -original_slug: Web/JavaScript/Reference/Objets_globaux/Math ---- -
{{JSRef}}
- -

L'objet Math est un objet natif dont les méthodes et propriétés permettent l'utilisation de constantes et fonctions mathématiques. Cet objet n'est pas une fonction.

- -
-

Attention : Math fonctionne avec le type {{jsxref("Number")}}. Il ne fonctionne pas avec les grands entiers/{{jsxref("BigInt")}}.

-
- -

Description

- -

Contrairement aux autres objets globaux, Math n'est pas un constructeur. Toutes les propriétés et les méthodes de Math sont statiques (pour éventuellement étendre cette API, ce qui est fortement déconseillé, on n'utilisera donc pas Math.prototype).

- -

Pour accéder à la constante PI, on utilise Math.PI.
- Pour accéder à la fonction sinus, on utilise Math.sin(x)x est l'argument de cette méthode.

- -

Les constantes sont définies avec la précision des nombres réels en JavaScript.

- -

Propriétés

- -
-
{{jsxref("Math.E")}}
-
Nombre d'Euler, la base des logarithmes naturels, environ 2,718.
-
{{jsxref("Math.LN2")}}
-
Logarithme naturel de 2, environ 0,693.
-
{{jsxref("Math.LN10")}}
-
Logarithme naturel de 10, environ 2,302.
-
{{jsxref("Math.LOG2E")}}
-
Logarithme de base 2 de E, environ 1,442.
-
{{jsxref("Math.LOG10E")}}
-
Logarithme de base 10 de E, environ 0,434.
-
{{jsxref("Math.PI")}}
-
Quotient de la circonférence d'un cercle par son diamètre, environ 3,14159.
-
{{jsxref("Math.SQRT1_2")}}
-
Racine carrée de 1/2 ; équivalent de 1 sur la racine carrée de 2, environ 0,707.
-
{{jsxref("Math.SQRT2")}}
-
Racine carrée de 2, environ 1,414.
-
- -

Méthodes

- -

Note : Les fonctions trigonométriques (sin(), cos(), tan(), asin(), acos(), atan(), atan2()) acceptent ou retournent des angles en radians. Pour convertir des degrés en radians, multipliez la valeur en degrés par (Math.PI / 180). Pour passer des radians en degrés, divisez la valeur en radians par (Math.PI / 180).

- -

Note : La précision des fonctions mathématiques dépend notamment de l'implémentation. Cela signifie que différents navigateurs peuvent fournir des résultats différents. On peut même avoir un même moteur JavaScript qui, sur des architectures et/ou des systèmes d'exploitation différents, fournit des résultats différents.

- -
-
{{jsxref("Objets_globaux/Math/abs", "Math.abs(x)")}}
-
Retourne la valeur absolue d'un nombre.
-
{{jsxref("Objets_globaux/Math/acos", "Math.acos(x)")}}
-
Retourne l'arc cosinus d'un nombre.
-
{{jsxref("Objets_globaux/Math/acosh", "Math.acosh(x)")}}
-
Retourne l'arc cosinus hyperbolique d'un nombre.
-
{{jsxref("Objets_globaux/Math/asin", "Math.asin(x)")}}
-
Retourne l'arc sinus d'un nombre.
-
{{jsxref("Objets_globaux/Math/asinh", "Math.asinh(x)")}}
-
Retourne l'arc sinus hyperbolique d'un nombre.
-
{{jsxref("Objets_globaux/Math/atan", "Math.atan(x)")}}
-
Retourne l'arc tangente d'un nombre.
-
{{jsxref("Objets_globaux/Math/atanh", "Math.atanh(x)")}}
-
Retourne l'arc tangente hyperbolique d'un nombre
-
{{jsxref("Objets_globaux/Math/atan2", "Math.atan2(y, x)")}}
-
Retourne l'arc tangente du quotient de ses arguments.
-
{{jsxref("Objets_globaux/Math/cbrt", "Math.cbrt(x)")}}
-
Renvoie la racine cubique d'un nombre.
-
{{jsxref("Objets_globaux/Math/ceil", "Math.ceil(x)")}}
-
Retourne le plus petit entier supérieur ou égal à la valeur passée en paramètre.
-
{{jsxref("Objets_globaux/Math/clz32", "Math.clz32(x)")}}
-
Renvoie le nombre de zéros qui préfixent un entier sur 32 bits.
-
{{jsxref("Objets_globaux/Math/cos", "Math.cos(x)")}}
-
Retourne le cosinus d'un nombre.
-
{{jsxref("Objets_globaux/Math/cosh", "Math.cosh(x)")}}
-
Renvoie le cosinus hyperbolique d'un nombre.
-
{{jsxref("Objets_globaux/Math/exp", "Math.exp(x)")}}
-
Renvoie l'exponentielle d'un nombre (soit E^nombre) avec E la constante d'Euler (2,718...).
-
{{jsxref("Objets_globaux/Math/expm1", "Math.expm1(x)")}}
-
Renvoie le résultat de 1 moins l'exponentielle d'un nombre.
-
{{jsxref("Objets_globaux/Math/floor", "Math.floor(x)")}}
-
Retourne le plus grand entier inférieur ou égal à la valeur passée en paramètre.
-
{{jsxref("Objets_globaux/Math/fround", "Math.fround(x)")}}
-
Renvoie le nombre flottant exprimé sur 32 bits le plus proche de l'argument.
-
{{jsxref("Objets_globaux/Math/hypot", "Math.hypot([x[,y[,…]]])")}}
-
Retourne la racine carré de la somme des carrés des arguments.
-
{{jsxref("Objets_globaux/Math/imul", "Math.imul(x, y)")}}
-
Retourne le résultat de la multiplication d'entiers sur 32 bits.
-
{{jsxref("Objets_globaux/Math/log", "Math.log(x)")}}
-
Retourne le logarithme naturel (loge) d'un nombre.
-
{{jsxref("Objets_globaux/Math/log1p", "Math.log1p(x)")}}
-
Retourne le logarithme naturel de 1 + un nombre.
-
{{jsxref("Objets_globaux/Math/log10", "Math.log10(x)")}}
-
Retourne le logarithme en base 10 d'un nombre.
-
{{jsxref("Objets_globaux/Math/log2", "Math.log2(x)")}}
-
Retourne le logarithme en base 2 d'un nombre.
-
{{jsxref("Objets_globaux/Math/max", "Math.max([x[,y[,…]]])")}}
-
Retourne la plus grande valeur d'une liste de nombres.
-
{{jsxref("Objets_globaux/Math/min", "Math.min([x[,y[,…]]])")}}
-
Retourne la plus petite valeur d'une liste de nombres.
-
{{jsxref("Objets_globaux/Math/pow", "Math.pow(x,y)")}}
-
Retourne le calcul de x à la puissance y (x correspond à la base et y à l'exposant).
-
{{jsxref("Objets_globaux/Math/random", "Math.random()")}}
-
Retourne un nombre pseudo-aléatoire compris entre 0 (inclus) et 1 (exclu).
-
{{jsxref("Objets_globaux/Math/round", "Math.round(x)")}}
-
Retourne l'arrondi d'un nombre.
-
{{jsxref("Objets_globaux/Math/sign", "Math.sign(x)")}}
-
Retourne le signe d'un nombre, indiquant s'il est positif, négatif ou égal à zéro.
-
{{jsxref("Objets_globaux/Math/sin", "Math.sin(x)")}}
-
Retourne le sinus d'un nombre.
-
{{jsxref("Objets_globaux/Math/sinh", "Math.sinh(x)")}}
-
Retourne le sinus hyperbolique d'un nombre.
-
{{jsxref("Objets_globaux/Math/sqrt", "Math.sqrt(x)")}}
-
Retourne la racine carrée d'un nombre.
-
{{jsxref("Objets_globaux/Math/tan", "Math.tan(x)")}}
-
Retourne la tangente d'un nombre.
-
{{jsxref("Objets_globaux/Math/tanh", "Math.tanh(x)")}}
-
Retourne la tangente hyperbolique d'un nombre
-
Math.toSource() {{Non-standard_inline}}
-
Renvoie la chaîne de caractères "Math".
-
{{jsxref("Objets_globaux/Math/trunc", "Math.trunc(x)")}}
-
Retourne la partie entière d'un nombre (la partie décimale est retirée).
-
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.1
{{SpecName('ES5.1', '#sec-15.8', 'Math')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-math-object', 'Math')}}{{Spec2('ES6')}}Nouvelles méthodes ajoutées : {{jsxref("Math.log10()", "log10()")}}, {{jsxref("Math.log2()", "log2()")}}, {{jsxref("Math.log1p()", "log1p()")}}, {{jsxref("Math.expm1()", "expm1()")}}, {{jsxref("Math.cosh()", "cosh()")}}, {{jsxref("Math.sinh()", "sinh()")}}, {{jsxref("Math.tanh()", "tanh()")}}, {{jsxref("Math.acosh()", "acosh()")}}, {{jsxref("Math.asinh()", "asinh()")}}, {{jsxref("Math.atanh()", "atanh()")}}, {{jsxref("Math.hypot()", "hypot()")}}, {{jsxref("Math.trunc()", "trunc()")}}, {{jsxref("Math.sign()", "sign()")}}, {{jsxref("Math.imul()", "imul()")}}, {{jsxref("Math.fround()", "fround()")}}, {{jsxref("Math.cbrt()", "cbrt()")}} et {{jsxref("Math.clz32()", "clz32()")}}.
{{SpecName('ESDraft', '#sec-math-object', 'Math')}}{{Spec2('ESDraft')}}
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/index.md b/files/fr/web/javascript/reference/global_objects/math/index.md new file mode 100644 index 0000000000..86ab1bee47 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/index.md @@ -0,0 +1,170 @@ +--- +title: Math +slug: Web/JavaScript/Reference/Global_Objects/Math +tags: + - JavaScript + - Math + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math +original_slug: Web/JavaScript/Reference/Objets_globaux/Math +--- +
{{JSRef}}
+ +

L'objet Math est un objet natif dont les méthodes et propriétés permettent l'utilisation de constantes et fonctions mathématiques. Cet objet n'est pas une fonction.

+ +
+

Attention : Math fonctionne avec le type {{jsxref("Number")}}. Il ne fonctionne pas avec les grands entiers/{{jsxref("BigInt")}}.

+
+ +

Description

+ +

Contrairement aux autres objets globaux, Math n'est pas un constructeur. Toutes les propriétés et les méthodes de Math sont statiques (pour éventuellement étendre cette API, ce qui est fortement déconseillé, on n'utilisera donc pas Math.prototype).

+ +

Pour accéder à la constante PI, on utilise Math.PI.
+ Pour accéder à la fonction sinus, on utilise Math.sin(x)x est l'argument de cette méthode.

+ +

Les constantes sont définies avec la précision des nombres réels en JavaScript.

+ +

Propriétés

+ +
+
{{jsxref("Math.E")}}
+
Nombre d'Euler, la base des logarithmes naturels, environ 2,718.
+
{{jsxref("Math.LN2")}}
+
Logarithme naturel de 2, environ 0,693.
+
{{jsxref("Math.LN10")}}
+
Logarithme naturel de 10, environ 2,302.
+
{{jsxref("Math.LOG2E")}}
+
Logarithme de base 2 de E, environ 1,442.
+
{{jsxref("Math.LOG10E")}}
+
Logarithme de base 10 de E, environ 0,434.
+
{{jsxref("Math.PI")}}
+
Quotient de la circonférence d'un cercle par son diamètre, environ 3,14159.
+
{{jsxref("Math.SQRT1_2")}}
+
Racine carrée de 1/2 ; équivalent de 1 sur la racine carrée de 2, environ 0,707.
+
{{jsxref("Math.SQRT2")}}
+
Racine carrée de 2, environ 1,414.
+
+ +

Méthodes

+ +

Note : Les fonctions trigonométriques (sin(), cos(), tan(), asin(), acos(), atan(), atan2()) acceptent ou retournent des angles en radians. Pour convertir des degrés en radians, multipliez la valeur en degrés par (Math.PI / 180). Pour passer des radians en degrés, divisez la valeur en radians par (Math.PI / 180).

+ +

Note : La précision des fonctions mathématiques dépend notamment de l'implémentation. Cela signifie que différents navigateurs peuvent fournir des résultats différents. On peut même avoir un même moteur JavaScript qui, sur des architectures et/ou des systèmes d'exploitation différents, fournit des résultats différents.

+ +
+
{{jsxref("Objets_globaux/Math/abs", "Math.abs(x)")}}
+
Retourne la valeur absolue d'un nombre.
+
{{jsxref("Objets_globaux/Math/acos", "Math.acos(x)")}}
+
Retourne l'arc cosinus d'un nombre.
+
{{jsxref("Objets_globaux/Math/acosh", "Math.acosh(x)")}}
+
Retourne l'arc cosinus hyperbolique d'un nombre.
+
{{jsxref("Objets_globaux/Math/asin", "Math.asin(x)")}}
+
Retourne l'arc sinus d'un nombre.
+
{{jsxref("Objets_globaux/Math/asinh", "Math.asinh(x)")}}
+
Retourne l'arc sinus hyperbolique d'un nombre.
+
{{jsxref("Objets_globaux/Math/atan", "Math.atan(x)")}}
+
Retourne l'arc tangente d'un nombre.
+
{{jsxref("Objets_globaux/Math/atanh", "Math.atanh(x)")}}
+
Retourne l'arc tangente hyperbolique d'un nombre
+
{{jsxref("Objets_globaux/Math/atan2", "Math.atan2(y, x)")}}
+
Retourne l'arc tangente du quotient de ses arguments.
+
{{jsxref("Objets_globaux/Math/cbrt", "Math.cbrt(x)")}}
+
Renvoie la racine cubique d'un nombre.
+
{{jsxref("Objets_globaux/Math/ceil", "Math.ceil(x)")}}
+
Retourne le plus petit entier supérieur ou égal à la valeur passée en paramètre.
+
{{jsxref("Objets_globaux/Math/clz32", "Math.clz32(x)")}}
+
Renvoie le nombre de zéros qui préfixent un entier sur 32 bits.
+
{{jsxref("Objets_globaux/Math/cos", "Math.cos(x)")}}
+
Retourne le cosinus d'un nombre.
+
{{jsxref("Objets_globaux/Math/cosh", "Math.cosh(x)")}}
+
Renvoie le cosinus hyperbolique d'un nombre.
+
{{jsxref("Objets_globaux/Math/exp", "Math.exp(x)")}}
+
Renvoie l'exponentielle d'un nombre (soit E^nombre) avec E la constante d'Euler (2,718...).
+
{{jsxref("Objets_globaux/Math/expm1", "Math.expm1(x)")}}
+
Renvoie le résultat de 1 moins l'exponentielle d'un nombre.
+
{{jsxref("Objets_globaux/Math/floor", "Math.floor(x)")}}
+
Retourne le plus grand entier inférieur ou égal à la valeur passée en paramètre.
+
{{jsxref("Objets_globaux/Math/fround", "Math.fround(x)")}}
+
Renvoie le nombre flottant exprimé sur 32 bits le plus proche de l'argument.
+
{{jsxref("Objets_globaux/Math/hypot", "Math.hypot([x[,y[,…]]])")}}
+
Retourne la racine carré de la somme des carrés des arguments.
+
{{jsxref("Objets_globaux/Math/imul", "Math.imul(x, y)")}}
+
Retourne le résultat de la multiplication d'entiers sur 32 bits.
+
{{jsxref("Objets_globaux/Math/log", "Math.log(x)")}}
+
Retourne le logarithme naturel (loge) d'un nombre.
+
{{jsxref("Objets_globaux/Math/log1p", "Math.log1p(x)")}}
+
Retourne le logarithme naturel de 1 + un nombre.
+
{{jsxref("Objets_globaux/Math/log10", "Math.log10(x)")}}
+
Retourne le logarithme en base 10 d'un nombre.
+
{{jsxref("Objets_globaux/Math/log2", "Math.log2(x)")}}
+
Retourne le logarithme en base 2 d'un nombre.
+
{{jsxref("Objets_globaux/Math/max", "Math.max([x[,y[,…]]])")}}
+
Retourne la plus grande valeur d'une liste de nombres.
+
{{jsxref("Objets_globaux/Math/min", "Math.min([x[,y[,…]]])")}}
+
Retourne la plus petite valeur d'une liste de nombres.
+
{{jsxref("Objets_globaux/Math/pow", "Math.pow(x,y)")}}
+
Retourne le calcul de x à la puissance y (x correspond à la base et y à l'exposant).
+
{{jsxref("Objets_globaux/Math/random", "Math.random()")}}
+
Retourne un nombre pseudo-aléatoire compris entre 0 (inclus) et 1 (exclu).
+
{{jsxref("Objets_globaux/Math/round", "Math.round(x)")}}
+
Retourne l'arrondi d'un nombre.
+
{{jsxref("Objets_globaux/Math/sign", "Math.sign(x)")}}
+
Retourne le signe d'un nombre, indiquant s'il est positif, négatif ou égal à zéro.
+
{{jsxref("Objets_globaux/Math/sin", "Math.sin(x)")}}
+
Retourne le sinus d'un nombre.
+
{{jsxref("Objets_globaux/Math/sinh", "Math.sinh(x)")}}
+
Retourne le sinus hyperbolique d'un nombre.
+
{{jsxref("Objets_globaux/Math/sqrt", "Math.sqrt(x)")}}
+
Retourne la racine carrée d'un nombre.
+
{{jsxref("Objets_globaux/Math/tan", "Math.tan(x)")}}
+
Retourne la tangente d'un nombre.
+
{{jsxref("Objets_globaux/Math/tanh", "Math.tanh(x)")}}
+
Retourne la tangente hyperbolique d'un nombre
+
Math.toSource() {{Non-standard_inline}}
+
Renvoie la chaîne de caractères "Math".
+
{{jsxref("Objets_globaux/Math/trunc", "Math.trunc(x)")}}
+
Retourne la partie entière d'un nombre (la partie décimale est retirée).
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.1
{{SpecName('ES5.1', '#sec-15.8', 'Math')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-math-object', 'Math')}}{{Spec2('ES6')}}Nouvelles méthodes ajoutées : {{jsxref("Math.log10()", "log10()")}}, {{jsxref("Math.log2()", "log2()")}}, {{jsxref("Math.log1p()", "log1p()")}}, {{jsxref("Math.expm1()", "expm1()")}}, {{jsxref("Math.cosh()", "cosh()")}}, {{jsxref("Math.sinh()", "sinh()")}}, {{jsxref("Math.tanh()", "tanh()")}}, {{jsxref("Math.acosh()", "acosh()")}}, {{jsxref("Math.asinh()", "asinh()")}}, {{jsxref("Math.atanh()", "atanh()")}}, {{jsxref("Math.hypot()", "hypot()")}}, {{jsxref("Math.trunc()", "trunc()")}}, {{jsxref("Math.sign()", "sign()")}}, {{jsxref("Math.imul()", "imul()")}}, {{jsxref("Math.fround()", "fround()")}}, {{jsxref("Math.cbrt()", "cbrt()")}} et {{jsxref("Math.clz32()", "clz32()")}}.
{{SpecName('ESDraft', '#sec-math-object', 'Math')}}{{Spec2('ESDraft')}}
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/ln10/index.html b/files/fr/web/javascript/reference/global_objects/math/ln10/index.html deleted file mode 100644 index f3818a3665..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/ln10/index.html +++ /dev/null @@ -1,82 +0,0 @@ ---- -title: Math.LN10 -slug: Web/JavaScript/Reference/Global_Objects/Math/LN10 -tags: - - JavaScript - - Math - - Propriété - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/LN10 -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/LN10 ---- -
{{JSRef}}
- -

La propriété Math.LN10 représente la valeur du logarithme naturel de 10, environ 2.302 :

- -

Math.LN10=ln(10)2.302\mathtt{\mi{Math.LN10}} = \ln(10) \approx 2.302

- -
{{EmbedInteractiveExample("pages/js/math-ln10.html")}}
- - - -
{{js_property_attributes(0,0,0)}}
- -

Description

- -

LN10 est une propriété statique de Math, elle doit toujours être utilisée avec la syntaxe Math.LN10, et ne pas être appelée comme propriété d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

- -

Exemples

- -

Utiliser Math.LN10

- -

La fonction suivante renvoie le logarithme naturel de 10 :

- -
function getNatLog10() {
-   return Math.LN10;
-}
-
-getNatLog10(); // 2.302585092994046
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.2', 'Math.LN10')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.ln10', 'Math.LN10')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.ln10', 'Math.LN10')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/ln10/index.md b/files/fr/web/javascript/reference/global_objects/math/ln10/index.md new file mode 100644 index 0000000000..f3818a3665 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/ln10/index.md @@ -0,0 +1,82 @@ +--- +title: Math.LN10 +slug: Web/JavaScript/Reference/Global_Objects/Math/LN10 +tags: + - JavaScript + - Math + - Propriété + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/LN10 +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/LN10 +--- +
{{JSRef}}
+ +

La propriété Math.LN10 représente la valeur du logarithme naturel de 10, environ 2.302 :

+ +

Math.LN10=ln(10)2.302\mathtt{\mi{Math.LN10}} = \ln(10) \approx 2.302

+ +
{{EmbedInteractiveExample("pages/js/math-ln10.html")}}
+ + + +
{{js_property_attributes(0,0,0)}}
+ +

Description

+ +

LN10 est une propriété statique de Math, elle doit toujours être utilisée avec la syntaxe Math.LN10, et ne pas être appelée comme propriété d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Exemples

+ +

Utiliser Math.LN10

+ +

La fonction suivante renvoie le logarithme naturel de 10 :

+ +
function getNatLog10() {
+   return Math.LN10;
+}
+
+getNatLog10(); // 2.302585092994046
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.2', 'Math.LN10')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.ln10', 'Math.LN10')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.ln10', 'Math.LN10')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/ln2/index.html b/files/fr/web/javascript/reference/global_objects/math/ln2/index.html deleted file mode 100644 index 0a7fc56029..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/ln2/index.html +++ /dev/null @@ -1,82 +0,0 @@ ---- -title: Math.LN2 -slug: Web/JavaScript/Reference/Global_Objects/Math/LN2 -tags: - - JavaScript - - Math - - Propriété - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/LN2 -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/LN2 ---- -
{{JSRef}}
- -

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

- -
{{EmbedInteractiveExample("pages/js/math-ln2.html")}}
- - - -
{{js_property_attributes(0,0,0)}}
- -

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

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.3', 'Math.LN2')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.ln2', 'Math.LN2')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.ln2', 'Math.LN2')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/ln2/index.md b/files/fr/web/javascript/reference/global_objects/math/ln2/index.md new file mode 100644 index 0000000000..0a7fc56029 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/ln2/index.md @@ -0,0 +1,82 @@ +--- +title: Math.LN2 +slug: Web/JavaScript/Reference/Global_Objects/Math/LN2 +tags: + - JavaScript + - Math + - Propriété + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/LN2 +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/LN2 +--- +
{{JSRef}}
+ +

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

+ +
{{EmbedInteractiveExample("pages/js/math-ln2.html")}}
+ + + +
{{js_property_attributes(0,0,0)}}
+ +

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

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.3', 'Math.LN2')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.ln2', 'Math.LN2')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.ln2', 'Math.LN2')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/log/index.html b/files/fr/web/javascript/reference/global_objects/math/log/index.html deleted file mode 100644 index 25d7a48e8b..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/log/index.html +++ /dev/null @@ -1,104 +0,0 @@ ---- -title: Math.log() -slug: Web/JavaScript/Reference/Global_Objects/Math/log -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/log -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/log ---- -
{{JSRef}}
- -

La fonction Math.log() renvoie le logarithme naturel (aussi appelé logarithme népérien) d'un nombre, défini par :

- -

x>0,Math.log(x)=ln(x)=le seul ytel queey=x\forall x > 0, \mathtt{\operatorname{Math.log}(x)} = \ln(x) = \text{the unique} \; y \; \text{such that} \; e^y = x

- -
{{EmbedInteractiveExample("pages/js/math-log.html")}}
- -

Syntaxe

- -
Math.log(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

Le logarithme naturelle de la valeur passée en argument. Si cette valeur est négative, c'est {{jsxref("NaN")}} qui est renvoyé.

- -

Description

- -

Si la valeur de l'argument est négative, la valeur renvoyée sera {{jsxref("NaN")}}. Si la valeur de l'argument est 0, la valeur de retour sera {{jsxref("Number.NEGATIVE_INFINITY", "-Infinity")}}.

- -

log() est une méthode statique de Math, elle doit toujours être utilisée avec la syntaxe Math.log(), elle ne doit pas être utilisée à partir d'un autre objet qui aurait été créé (Math n'est pas un constructeur). Si on veut utiliser les constantes données par les logarithmes naturels de 2 ou 10, on pourra utiliser les constantes {{jsxref("Math.LN2")}} ou {{jsxref("Math.LN10")}}. De même pour les logarithmes en base 2 ou en base 10, on pourra utiliser {{jsxref("Math.log2()")}} or {{jsxref("Math.log10()")}}.

- -

Exemples

- -

Utiliser Math.log()

- -
Math.log(-1); // NaN, valeur en dehors de l'intervalle de définition
-Math.log(0);  // -Infinity
-Math.log(1);  // 0
-Math.log(10); // 2.302585092994046
- -

Utiliser Math.log pour construire un logarithme sur une autre base

- -

La fonction suivante renvoie le logarithme de y en base x (c'est-à-dire logx y):

- -
function getBaseLog(x, y) {
-    return Math.log(y) / Math.log(x);
-}
- -

Si on exécute getBaseLog(10, 1000), on obtiendra 2.9999999999999996 en raison de l'arrondi du à la représentation en nombre flottant (le résultat exact étant 3).

- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.10', 'Math.log')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-math.log', 'Math.log')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-math.log', 'Math.log')}}{{Spec2('ESDraft')}}
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/log/index.md b/files/fr/web/javascript/reference/global_objects/math/log/index.md new file mode 100644 index 0000000000..25d7a48e8b --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/log/index.md @@ -0,0 +1,104 @@ +--- +title: Math.log() +slug: Web/JavaScript/Reference/Global_Objects/Math/log +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/log +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/log +--- +
{{JSRef}}
+ +

La fonction Math.log() renvoie le logarithme naturel (aussi appelé logarithme népérien) d'un nombre, défini par :

+ +

x>0,Math.log(x)=ln(x)=le seul ytel queey=x\forall x > 0, \mathtt{\operatorname{Math.log}(x)} = \ln(x) = \text{the unique} \; y \; \text{such that} \; e^y = x

+ +
{{EmbedInteractiveExample("pages/js/math-log.html")}}
+ +

Syntaxe

+ +
Math.log(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

Le logarithme naturelle de la valeur passée en argument. Si cette valeur est négative, c'est {{jsxref("NaN")}} qui est renvoyé.

+ +

Description

+ +

Si la valeur de l'argument est négative, la valeur renvoyée sera {{jsxref("NaN")}}. Si la valeur de l'argument est 0, la valeur de retour sera {{jsxref("Number.NEGATIVE_INFINITY", "-Infinity")}}.

+ +

log() est une méthode statique de Math, elle doit toujours être utilisée avec la syntaxe Math.log(), elle ne doit pas être utilisée à partir d'un autre objet qui aurait été créé (Math n'est pas un constructeur). Si on veut utiliser les constantes données par les logarithmes naturels de 2 ou 10, on pourra utiliser les constantes {{jsxref("Math.LN2")}} ou {{jsxref("Math.LN10")}}. De même pour les logarithmes en base 2 ou en base 10, on pourra utiliser {{jsxref("Math.log2()")}} or {{jsxref("Math.log10()")}}.

+ +

Exemples

+ +

Utiliser Math.log()

+ +
Math.log(-1); // NaN, valeur en dehors de l'intervalle de définition
+Math.log(0);  // -Infinity
+Math.log(1);  // 0
+Math.log(10); // 2.302585092994046
+ +

Utiliser Math.log pour construire un logarithme sur une autre base

+ +

La fonction suivante renvoie le logarithme de y en base x (c'est-à-dire logx y):

+ +
function getBaseLog(x, y) {
+    return Math.log(y) / Math.log(x);
+}
+ +

Si on exécute getBaseLog(10, 1000), on obtiendra 2.9999999999999996 en raison de l'arrondi du à la représentation en nombre flottant (le résultat exact étant 3).

+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.10', 'Math.log')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-math.log', 'Math.log')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-math.log', 'Math.log')}}{{Spec2('ESDraft')}}
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/log10/index.html b/files/fr/web/javascript/reference/global_objects/math/log10/index.html deleted file mode 100644 index d0e65dca47..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/log10/index.html +++ /dev/null @@ -1,97 +0,0 @@ ---- -title: Math.log10() -slug: Web/JavaScript/Reference/Global_Objects/Math/log10 -tags: - - ECMAScript 2015 - - JavaScript - - Math - - Méthode - - Reference - - polyfill -translation_of: Web/JavaScript/Reference/Global_Objects/Math/log10 -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/log10 ---- -
{{JSRef}}
- -

La fonction Math.log10() renvoie le logarithme en base 10 d'un nombre, donné par la formule :

- -

x>0,Math.log10(x)=log10(x)=l'unique  ytel que10y=x\forall x > 0, \mathtt{\operatorname{Math.log10}(x)} = \log_10(x) = \text{the unique} \; y \; \text{such that} \; 10^y = x

- -
{{EmbedInteractiveExample("pages/js/math-log10.html")}}
- -

Syntaxe

- -
Math.log10(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

Le logarithme en base 10 du nombre passé en argument. Si cette valeur est négative, c'est {{jsxref("NaN")}} qui sera renvoyé.

- -

Description

- -

Si la valeur de l'argument est strictement inférieure à 0, la valeur renvoyée à {{jsxref("NaN")}}.

- -

log10() étant une méthode statique de Math, il faut utiliser Math.log10()et non pas la méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur). Cette fonction est équivalente à la fonction donnée par Math.log(x) / Math.log(10).

- -

Exemple

- -

Utiliser Math.log10()

- -
Math.log10(2);      // 0.3010299956639812
-Math.log10(1);      // 0
-Math.log10(0);      // -Infinity
-Math.log10(-2);     // NaN
-Math.log10(100000); // 5
-
- -

Prothèse d'émulation (polyfill)

- -

Il est possible d'avoir un résultat approximatif avec la fonction suivante :

- -
Math.log10 = Math.log10 || function(x) {
-  return Math.log(x) * Math.LOG10E;
-};
-
- -

Spécifications

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

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/log10/index.md b/files/fr/web/javascript/reference/global_objects/math/log10/index.md new file mode 100644 index 0000000000..d0e65dca47 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/log10/index.md @@ -0,0 +1,97 @@ +--- +title: Math.log10() +slug: Web/JavaScript/Reference/Global_Objects/Math/log10 +tags: + - ECMAScript 2015 + - JavaScript + - Math + - Méthode + - Reference + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Math/log10 +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/log10 +--- +
{{JSRef}}
+ +

La fonction Math.log10() renvoie le logarithme en base 10 d'un nombre, donné par la formule :

+ +

x>0,Math.log10(x)=log10(x)=l'unique  ytel que10y=x\forall x > 0, \mathtt{\operatorname{Math.log10}(x)} = \log_10(x) = \text{the unique} \; y \; \text{such that} \; 10^y = x

+ +
{{EmbedInteractiveExample("pages/js/math-log10.html")}}
+ +

Syntaxe

+ +
Math.log10(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

Le logarithme en base 10 du nombre passé en argument. Si cette valeur est négative, c'est {{jsxref("NaN")}} qui sera renvoyé.

+ +

Description

+ +

Si la valeur de l'argument est strictement inférieure à 0, la valeur renvoyée à {{jsxref("NaN")}}.

+ +

log10() étant une méthode statique de Math, il faut utiliser Math.log10()et non pas la méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur). Cette fonction est équivalente à la fonction donnée par Math.log(x) / Math.log(10).

+ +

Exemple

+ +

Utiliser Math.log10()

+ +
Math.log10(2);      // 0.3010299956639812
+Math.log10(1);      // 0
+Math.log10(0);      // -Infinity
+Math.log10(-2);     // NaN
+Math.log10(100000); // 5
+
+ +

Prothèse d'émulation (polyfill)

+ +

Il est possible d'avoir un résultat approximatif avec la fonction suivante :

+ +
Math.log10 = Math.log10 || function(x) {
+  return Math.log(x) * Math.LOG10E;
+};
+
+ +

Spécifications

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

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/log10e/index.html b/files/fr/web/javascript/reference/global_objects/math/log10e/index.html deleted file mode 100644 index 175018cc26..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/log10e/index.html +++ /dev/null @@ -1,82 +0,0 @@ ---- -title: Math.LOG10E -slug: Web/JavaScript/Reference/Global_Objects/Math/LOG10E -tags: - - JavaScript - - Math - - Propriété - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/LOG10E -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/LOG10E ---- -
{{JSRef}}
- -

La propriété Math.LOG10E fournit la valeur du logarithme en base 10 de e, environ 0.434 :

- -

Math.LOG10E=log10(e)0.434\mathtt{\mi{Math.LOG10E}} = \log_10(e) \approx 0.434

- -
{{EmbedInteractiveExample("pages/js/math-log10e.html")}}
- - - -
{{js_property_attributes(0,0,0)}}
- -

Description

- -

LOG10E étant une propriété statique de Math, elle doit toujours être utilisée avec la syntaxe Math.LOG10E et ne pas être appelée comme propriété d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

- -

Exemples

- -

Utiliser Math.LOG10E

- -

La fonction suivante renvoie le logarithme en base 10 de e :

- -
function getLog10e() {
-   return Math.LOG10E;
-}
-
-getLog10e(); // 0.4342944819032518
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.5', 'Math.LOG10E')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.log10e', 'Math.LOG10E')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.log10e', 'Math.LOG10E')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/log10e/index.md b/files/fr/web/javascript/reference/global_objects/math/log10e/index.md new file mode 100644 index 0000000000..175018cc26 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/log10e/index.md @@ -0,0 +1,82 @@ +--- +title: Math.LOG10E +slug: Web/JavaScript/Reference/Global_Objects/Math/LOG10E +tags: + - JavaScript + - Math + - Propriété + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/LOG10E +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/LOG10E +--- +
{{JSRef}}
+ +

La propriété Math.LOG10E fournit la valeur du logarithme en base 10 de e, environ 0.434 :

+ +

Math.LOG10E=log10(e)0.434\mathtt{\mi{Math.LOG10E}} = \log_10(e) \approx 0.434

+ +
{{EmbedInteractiveExample("pages/js/math-log10e.html")}}
+ + + +
{{js_property_attributes(0,0,0)}}
+ +

Description

+ +

LOG10E étant une propriété statique de Math, elle doit toujours être utilisée avec la syntaxe Math.LOG10E et ne pas être appelée comme propriété d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Exemples

+ +

Utiliser Math.LOG10E

+ +

La fonction suivante renvoie le logarithme en base 10 de e :

+ +
function getLog10e() {
+   return Math.LOG10E;
+}
+
+getLog10e(); // 0.4342944819032518
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.5', 'Math.LOG10E')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.log10e', 'Math.LOG10E')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.log10e', 'Math.LOG10E')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/log1p/index.html b/files/fr/web/javascript/reference/global_objects/math/log1p/index.html deleted file mode 100644 index 04913b856c..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/log1p/index.html +++ /dev/null @@ -1,96 +0,0 @@ ---- -title: Math.log1p() -slug: Web/JavaScript/Reference/Global_Objects/Math/log1p -tags: - - ECMAScript 2015 - - JavaScript - - Math - - Méthode - - Reference - - polyfill -translation_of: Web/JavaScript/Reference/Global_Objects/Math/log1p -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/log1p ---- -
{{JSRef}}
- -

La fonction Math.log1p() renvoie le logarithme népérien (en base {{jsxref("Math/E","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)

- -
{{EmbedInteractiveExample("pages/js/math-log1p.html")}}
- -

Syntaxe

- -
Math.log1p(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

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

- -

Description

- -

Si x est strictement inférieur à -1, la valeur renvoyée est {{jsxref("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

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

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/log1p/index.md b/files/fr/web/javascript/reference/global_objects/math/log1p/index.md new file mode 100644 index 0000000000..04913b856c --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/log1p/index.md @@ -0,0 +1,96 @@ +--- +title: Math.log1p() +slug: Web/JavaScript/Reference/Global_Objects/Math/log1p +tags: + - ECMAScript 2015 + - JavaScript + - Math + - Méthode + - Reference + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Math/log1p +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/log1p +--- +
{{JSRef}}
+ +

La fonction Math.log1p() renvoie le logarithme népérien (en base {{jsxref("Math/E","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)

+ +
{{EmbedInteractiveExample("pages/js/math-log1p.html")}}
+ +

Syntaxe

+ +
Math.log1p(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

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

+ +

Description

+ +

Si x est strictement inférieur à -1, la valeur renvoyée est {{jsxref("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

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

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/log2/index.html b/files/fr/web/javascript/reference/global_objects/math/log2/index.html deleted file mode 100644 index c1700ae5c1..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/log2/index.html +++ /dev/null @@ -1,89 +0,0 @@ ---- -title: Math.log2() -slug: Web/JavaScript/Reference/Global_Objects/Math/log2 -tags: - - ECMAScript 2015 - - JavaScript - - Math - - Méthode - - Reference - - polyfill -translation_of: Web/JavaScript/Reference/Global_Objects/Math/log2 -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/log2 ---- -
{{JSRef}}
- -

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

- -
{{EmbedInteractiveExample("pages/js/math-log2.html")}}
- -

Syntaxe

- -
Math.log2(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

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é.

- -

Description

- -

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")}}.

- -

Exemples

- -

Utiliser Math.log2()

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

- - 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 new file mode 100644 index 0000000000..c1700ae5c1 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/log2/index.md @@ -0,0 +1,89 @@ +--- +title: Math.log2() +slug: Web/JavaScript/Reference/Global_Objects/Math/log2 +tags: + - ECMAScript 2015 + - JavaScript + - Math + - Méthode + - Reference + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Math/log2 +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/log2 +--- +
{{JSRef}}
+ +

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

+ +
{{EmbedInteractiveExample("pages/js/math-log2.html")}}
+ +

Syntaxe

+ +
Math.log2(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

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é.

+ +

Description

+ +

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")}}.

+ +

Exemples

+ +

Utiliser Math.log2()

+ +
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

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/log2e/index.html b/files/fr/web/javascript/reference/global_objects/math/log2e/index.html deleted file mode 100644 index ef33a48cf1..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/log2e/index.html +++ /dev/null @@ -1,82 +0,0 @@ ---- -title: Math.LOG2E -slug: Web/JavaScript/Reference/Global_Objects/Math/LOG2E -tags: - - JavaScript - - Math - - Propriété - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/LOG2E -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/LOG2E ---- -
{{JSRef}}
- -

La propriété Math.LOG2E représente la valeur du logarithme en base 2 de e, environ 1.442 :

- -

Math.LOG2E=log2(e)1.442\mathtt{\mi{Math.LOG2E}} = \log_2(e) \approx 1.442

- -
{{EmbedInteractiveExample("pages/js/math-log2e.html")}}
- - - -
{{js_property_attributes(0,0,0)}}
- -

Description

- -

LOG2E est une propriété statique de l'objet Math et doit toujours être utilisé avec la syntaxe Math.LOG2E plutôt que comme la propriété d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

- -

Exemples

- -

Utiliser Math.LOG2E

- -

La fonction suivante renvoie la valeur du logarithme en base 2 de e :

- -
function getLog2e() {
-   return Math.LOG2E;
-}
-
-getLog2e(); // 1.4426950408889634
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.4', 'Math.LOG2E')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.log2e', 'Math.LOG2E')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.log2e', 'Math.LOG2E')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/log2e/index.md b/files/fr/web/javascript/reference/global_objects/math/log2e/index.md new file mode 100644 index 0000000000..ef33a48cf1 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/log2e/index.md @@ -0,0 +1,82 @@ +--- +title: Math.LOG2E +slug: Web/JavaScript/Reference/Global_Objects/Math/LOG2E +tags: + - JavaScript + - Math + - Propriété + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/LOG2E +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/LOG2E +--- +
{{JSRef}}
+ +

La propriété Math.LOG2E représente la valeur du logarithme en base 2 de e, environ 1.442 :

+ +

Math.LOG2E=log2(e)1.442\mathtt{\mi{Math.LOG2E}} = \log_2(e) \approx 1.442

+ +
{{EmbedInteractiveExample("pages/js/math-log2e.html")}}
+ + + +
{{js_property_attributes(0,0,0)}}
+ +

Description

+ +

LOG2E est une propriété statique de l'objet Math et doit toujours être utilisé avec la syntaxe Math.LOG2E plutôt que comme la propriété d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Exemples

+ +

Utiliser Math.LOG2E

+ +

La fonction suivante renvoie la valeur du logarithme en base 2 de e :

+ +
function getLog2e() {
+   return Math.LOG2E;
+}
+
+getLog2e(); // 1.4426950408889634
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.4', 'Math.LOG2E')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.log2e', 'Math.LOG2E')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.log2e', 'Math.LOG2E')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/max/index.html b/files/fr/web/javascript/reference/global_objects/math/max/index.html deleted file mode 100644 index 78e3810bca..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/max/index.html +++ /dev/null @@ -1,112 +0,0 @@ ---- -title: Math.max() -slug: Web/JavaScript/Reference/Global_Objects/Math/max -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/max -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/max ---- -
{{JSRef}}
- -

La fonction Math.max() renvoie le plus grand nombre d'une série de 0 ou plusieurs nombres.

- -
{{EmbedInteractiveExample("pages/js/math-max.html")}}
- -

Syntaxe

- -
Math.max([valeur1[,valeur2, ...]]) 
- -

Paramètres

- -
-
valeur1, valeur2, ...
-
Des nombres.
-
- -

Valeur de retour

- -

Le plus grand des nombres passés en arguments. S'il existe un des arguments qui ne peut pas être converti en nombre, c'est {{jsxref("NaN")}} qui sera renvoyé.

- -

Description

- -

max() est une méthode statique de Math et doit toujours être utilisée avec la syntaxe Math.max(), elle ne doit pas être appelée comme la méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

- -

Si aucun argument n'est fourni, le résultat sera -{{jsxref("Infinity")}}.

- -

Si au moins un des arguments ne peut pas être converti en un nombre, le résultat sera {{jsxref("NaN")}}.

- -

Exemple

- -

Utiliser Math.max()

- -
Math.max(10, 20);   //  20
-Math.max(-10, -20); // -10
-Math.max(-10, 20);  //  20
-
- -

Obtenir l'élément maximum d'un tableau

- -

La méthode {{jsxref("Array.prototype.reduce()")}} peut être utilisée pour déterminer la valeur maximale d'un tableau de nombre en comparant les valeurs qui se suivent :

- -
var arr = [1, 2, 3];
-var max = arr.reduce(function(a,b) {
-  return Math.max(a, b);
-});
- -

On peut également utiliser {{jsxref("Function.prototype.apply()")}} afin de trouver le maximum parmi un tableau de nombres. getMaxTableau([1,2,3]) sera équivalent à Math.max(1, 2, 3), mais getMaxTableau pourra être utilisé sur des tableaux de n'importe quelle taille.

- -
function getMaxTableau(tableauNumérique) {
-    return Math.max.apply(null, tableauNumérique);
-}
- -

Avec le nouvel {{jsxref("Opérateurs/Affecter_par_décomposition","opérateur de décomposition","","1")}}, on pourra également utiliser cette syntaxe, plus concise et plus simple :

- -
var arr = [1, 2, 3];
-var max = Math.max(...arr);
- -

Attention avec la décomposition et apply() qui pourront échouer s'il y a trop d'éléments dans le tableau (car ceux-ci seront passés en arguments). Pour plus d'informations, consulter Utiliser apply() et les fonctions natives. La méthode proposée avec reduce() n'a pas cette contrainte.

- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.11', 'Math.max')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.max', 'Math.max')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.max', 'Math.max')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/max/index.md b/files/fr/web/javascript/reference/global_objects/math/max/index.md new file mode 100644 index 0000000000..78e3810bca --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/max/index.md @@ -0,0 +1,112 @@ +--- +title: Math.max() +slug: Web/JavaScript/Reference/Global_Objects/Math/max +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/max +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/max +--- +
{{JSRef}}
+ +

La fonction Math.max() renvoie le plus grand nombre d'une série de 0 ou plusieurs nombres.

+ +
{{EmbedInteractiveExample("pages/js/math-max.html")}}
+ +

Syntaxe

+ +
Math.max([valeur1[,valeur2, ...]]) 
+ +

Paramètres

+ +
+
valeur1, valeur2, ...
+
Des nombres.
+
+ +

Valeur de retour

+ +

Le plus grand des nombres passés en arguments. S'il existe un des arguments qui ne peut pas être converti en nombre, c'est {{jsxref("NaN")}} qui sera renvoyé.

+ +

Description

+ +

max() est une méthode statique de Math et doit toujours être utilisée avec la syntaxe Math.max(), elle ne doit pas être appelée comme la méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Si aucun argument n'est fourni, le résultat sera -{{jsxref("Infinity")}}.

+ +

Si au moins un des arguments ne peut pas être converti en un nombre, le résultat sera {{jsxref("NaN")}}.

+ +

Exemple

+ +

Utiliser Math.max()

+ +
Math.max(10, 20);   //  20
+Math.max(-10, -20); // -10
+Math.max(-10, 20);  //  20
+
+ +

Obtenir l'élément maximum d'un tableau

+ +

La méthode {{jsxref("Array.prototype.reduce()")}} peut être utilisée pour déterminer la valeur maximale d'un tableau de nombre en comparant les valeurs qui se suivent :

+ +
var arr = [1, 2, 3];
+var max = arr.reduce(function(a,b) {
+  return Math.max(a, b);
+});
+ +

On peut également utiliser {{jsxref("Function.prototype.apply()")}} afin de trouver le maximum parmi un tableau de nombres. getMaxTableau([1,2,3]) sera équivalent à Math.max(1, 2, 3), mais getMaxTableau pourra être utilisé sur des tableaux de n'importe quelle taille.

+ +
function getMaxTableau(tableauNumérique) {
+    return Math.max.apply(null, tableauNumérique);
+}
+ +

Avec le nouvel {{jsxref("Opérateurs/Affecter_par_décomposition","opérateur de décomposition","","1")}}, on pourra également utiliser cette syntaxe, plus concise et plus simple :

+ +
var arr = [1, 2, 3];
+var max = Math.max(...arr);
+ +

Attention avec la décomposition et apply() qui pourront échouer s'il y a trop d'éléments dans le tableau (car ceux-ci seront passés en arguments). Pour plus d'informations, consulter Utiliser apply() et les fonctions natives. La méthode proposée avec reduce() n'a pas cette contrainte.

+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.11', 'Math.max')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.max', 'Math.max')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.max', 'Math.max')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/min/index.html b/files/fr/web/javascript/reference/global_objects/math/min/index.html deleted file mode 100644 index 39cd2d8567..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/min/index.html +++ /dev/null @@ -1,108 +0,0 @@ ---- -title: Math.min() -slug: Web/JavaScript/Reference/Global_Objects/Math/min -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/min -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/min ---- -
{{JSRef}}
- -

La fonction Math.min() renvoie le plus petit nombre d'une série de 0 ou plusieurs nombres ou bien {{jsxref("NaN")}} si au moins un des arguments fourni n'est pas un nombre ou ne peut pas être converti en nombre.

- -
{{EmbedInteractiveExample("pages/js/math-min.html")}}
- -

Syntaxe

- -
Math.min([valeur1[,valeur2, ...]]) 
- -

Paramètres

- -
-
valeur1, valeur2, ...
-
Des nombres.
-
- -

Valeur de retour

- -

Le plus petit des nombres passés en arguments. S'il existe un argument qui ne peut pas être converti en nombre, c'est {{jsxref("NaN")}} qui sera renvoyé. Le résultat sera {{jsxref("Infinity")}} si aucun paramètre n'est fourni.

- -

Description

- -

min() est une méthode statique de Math, elle doit toujours être utilisée avec la syntaxe Math.min() et ne doit pas être utilisée comme la méthode d'un objet qui aurait été créé (Math n'est pas un constructeur).

- -

Si aucun argument n'est fourni, le résultat renvoyé par la fonction sera {{jsxref("Infinity")}}.

- -

Si au moins un des arguments ne peut pas être converti en un nombre, le résultat sera {{jsxref("NaN")}}.

- -

Exemples

- -

Utiliser Math.min()

- -

Dans cet exemple, on trouve le minimum de x et y et on affecte cette valeur à z :

- -
var x = 10, y = -20;
-var z = Math.min(x, y);
-
- -

Ramener une valeur dans un intervalle (clipping) avec Math.min()

- -

Math.min() est souvent utilisée afin de ramener une certaine valeur dans un intervalle donné. Par exemple :

- -
var x = f(toto);
-
-if (x > limite) {
-  x = limite;
-}
-
- -

peut s'écrire

- -
var x = Math.min(f(toto), limite);
- -
{{jsxref("Math.max()")}} peut être utilisée de façon semblable pour ramener une valeur vers un minimum d'un intervalle donné.
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.12', 'Math.min')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.min', 'Math.min')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.min', 'Math.min')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/min/index.md b/files/fr/web/javascript/reference/global_objects/math/min/index.md new file mode 100644 index 0000000000..39cd2d8567 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/min/index.md @@ -0,0 +1,108 @@ +--- +title: Math.min() +slug: Web/JavaScript/Reference/Global_Objects/Math/min +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/min +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/min +--- +
{{JSRef}}
+ +

La fonction Math.min() renvoie le plus petit nombre d'une série de 0 ou plusieurs nombres ou bien {{jsxref("NaN")}} si au moins un des arguments fourni n'est pas un nombre ou ne peut pas être converti en nombre.

+ +
{{EmbedInteractiveExample("pages/js/math-min.html")}}
+ +

Syntaxe

+ +
Math.min([valeur1[,valeur2, ...]]) 
+ +

Paramètres

+ +
+
valeur1, valeur2, ...
+
Des nombres.
+
+ +

Valeur de retour

+ +

Le plus petit des nombres passés en arguments. S'il existe un argument qui ne peut pas être converti en nombre, c'est {{jsxref("NaN")}} qui sera renvoyé. Le résultat sera {{jsxref("Infinity")}} si aucun paramètre n'est fourni.

+ +

Description

+ +

min() est une méthode statique de Math, elle doit toujours être utilisée avec la syntaxe Math.min() et ne doit pas être utilisée comme la méthode d'un objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Si aucun argument n'est fourni, le résultat renvoyé par la fonction sera {{jsxref("Infinity")}}.

+ +

Si au moins un des arguments ne peut pas être converti en un nombre, le résultat sera {{jsxref("NaN")}}.

+ +

Exemples

+ +

Utiliser Math.min()

+ +

Dans cet exemple, on trouve le minimum de x et y et on affecte cette valeur à z :

+ +
var x = 10, y = -20;
+var z = Math.min(x, y);
+
+ +

Ramener une valeur dans un intervalle (clipping) avec Math.min()

+ +

Math.min() est souvent utilisée afin de ramener une certaine valeur dans un intervalle donné. Par exemple :

+ +
var x = f(toto);
+
+if (x > limite) {
+  x = limite;
+}
+
+ +

peut s'écrire

+ +
var x = Math.min(f(toto), limite);
+ +
{{jsxref("Math.max()")}} peut être utilisée de façon semblable pour ramener une valeur vers un minimum d'un intervalle donné.
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.12', 'Math.min')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.min', 'Math.min')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.min', 'Math.min')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/pi/index.html b/files/fr/web/javascript/reference/global_objects/math/pi/index.html deleted file mode 100644 index d9aa0848db..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/pi/index.html +++ /dev/null @@ -1,80 +0,0 @@ ---- -title: Math.PI -slug: Web/JavaScript/Reference/Global_Objects/Math/PI -tags: - - JavaScript - - Math - - Propriété - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/PI -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/PI ---- -
{{JSRef}}
- -

La propriété Math.PI représente le ratio entre le périmètre d'un cercle et son diamètre. Elle vaut environ 3.14159:

- -

Math.PI=π3.14159\mathtt{\mi{Math.PI}} = \pi \approx 3.14159

- -
{{EmbedInteractiveExample("pages/js/math-pi.html")}}
- - - -
{{js_property_attributes(0,0,0)}}
- -

Description

- -

PI est une propriété statique de l'objet Math et doit toujours être utilisée avec la syntaxe Math.PI plutôt que d'être appelée comme la propriété d'un autre objet qui aurait été crée (Math n'est pas un constructeur).

- -

Exemples

- -

Utiliser Math.PI

- -

La fonction suivante utilise Math.PI afin de calculer le périmètre d'un cercle à partir du rayon passé en argument.

- -
function calculPérimètre(rayon) {
-  return 2 * Math.PI * rayon;
-}
-
-calculPérimètre(1);  // 6.283185307179586
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.6', 'Math.PI')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.pi', 'Math.PI')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.pi', 'Math.PI')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/pi/index.md b/files/fr/web/javascript/reference/global_objects/math/pi/index.md new file mode 100644 index 0000000000..d9aa0848db --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/pi/index.md @@ -0,0 +1,80 @@ +--- +title: Math.PI +slug: Web/JavaScript/Reference/Global_Objects/Math/PI +tags: + - JavaScript + - Math + - Propriété + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/PI +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/PI +--- +
{{JSRef}}
+ +

La propriété Math.PI représente le ratio entre le périmètre d'un cercle et son diamètre. Elle vaut environ 3.14159:

+ +

Math.PI=π3.14159\mathtt{\mi{Math.PI}} = \pi \approx 3.14159

+ +
{{EmbedInteractiveExample("pages/js/math-pi.html")}}
+ + + +
{{js_property_attributes(0,0,0)}}
+ +

Description

+ +

PI est une propriété statique de l'objet Math et doit toujours être utilisée avec la syntaxe Math.PI plutôt que d'être appelée comme la propriété d'un autre objet qui aurait été crée (Math n'est pas un constructeur).

+ +

Exemples

+ +

Utiliser Math.PI

+ +

La fonction suivante utilise Math.PI afin de calculer le périmètre d'un cercle à partir du rayon passé en argument.

+ +
function calculPérimètre(rayon) {
+  return 2 * Math.PI * rayon;
+}
+
+calculPérimètre(1);  // 6.283185307179586
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.6', 'Math.PI')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.pi', 'Math.PI')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.pi', 'Math.PI')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/pow/index.html b/files/fr/web/javascript/reference/global_objects/math/pow/index.html deleted file mode 100644 index b12f348e80..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/pow/index.html +++ /dev/null @@ -1,103 +0,0 @@ ---- -title: Math.pow() -slug: Web/JavaScript/Reference/Global_Objects/Math/pow -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/pow -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/pow ---- -
{{JSRef}}
- -

La fonction Math.pow() renvoie un nombre à une certaine puissance, c'est-à-dire base^exposant.

- -
{{EmbedInteractiveExample("pages/js/math-pow.html")}}
- -

Syntaxe

- -
Math.pow(base, exposant);
- -

Paramètres

- -
-
base
-
Le nombre correspondant à la base.
-
exponent
-
L'exposant auquel on élève le paramètre précédent.
-
- -

Valeur de retour

- -

Un nombre qui représente un nombre (premier argument) élevé à une puissance donné (second argument).

- -

Description

- -

pow() est une méthode statique de Math et doit toujours être utilisée avec la syntaxe Math.pow(), elle ne doit pas être utilisée comme une méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

- -

Exemple

- -

Utiliser Math.pow()

- -
// Utilisation simple
-Math.pow(7, 2); // 49
-
-// Exposants négatifs
-Math.pow(7, -2); // 0.02040816326530612 (1/49)
-
-// Exposants fractionnaires
-Math.pow(2, 1/2); // 1.4142135623730951 (racine carrée de 2)
-
-// Cas aux limites
-Math.pow(-7, 0.5); // NaN
-// (les nombres négatifs n'ont pas de racine carrée)
-Math.pow(-7, 1/3); // NaN
-// Nombre négatif avec une base décimale
-
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.13', 'Math.pow')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-math.pow', 'Math.pow')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-math.pow', 'Math.pow')}}{{Spec2('ESDraft')}}
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/pow/index.md b/files/fr/web/javascript/reference/global_objects/math/pow/index.md new file mode 100644 index 0000000000..b12f348e80 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/pow/index.md @@ -0,0 +1,103 @@ +--- +title: Math.pow() +slug: Web/JavaScript/Reference/Global_Objects/Math/pow +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/pow +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/pow +--- +
{{JSRef}}
+ +

La fonction Math.pow() renvoie un nombre à une certaine puissance, c'est-à-dire base^exposant.

+ +
{{EmbedInteractiveExample("pages/js/math-pow.html")}}
+ +

Syntaxe

+ +
Math.pow(base, exposant);
+ +

Paramètres

+ +
+
base
+
Le nombre correspondant à la base.
+
exponent
+
L'exposant auquel on élève le paramètre précédent.
+
+ +

Valeur de retour

+ +

Un nombre qui représente un nombre (premier argument) élevé à une puissance donné (second argument).

+ +

Description

+ +

pow() est une méthode statique de Math et doit toujours être utilisée avec la syntaxe Math.pow(), elle ne doit pas être utilisée comme une méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Exemple

+ +

Utiliser Math.pow()

+ +
// Utilisation simple
+Math.pow(7, 2); // 49
+
+// Exposants négatifs
+Math.pow(7, -2); // 0.02040816326530612 (1/49)
+
+// Exposants fractionnaires
+Math.pow(2, 1/2); // 1.4142135623730951 (racine carrée de 2)
+
+// Cas aux limites
+Math.pow(-7, 0.5); // NaN
+// (les nombres négatifs n'ont pas de racine carrée)
+Math.pow(-7, 1/3); // NaN
+// Nombre négatif avec une base décimale
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.13', 'Math.pow')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-math.pow', 'Math.pow')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-math.pow', 'Math.pow')}}{{Spec2('ESDraft')}}
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/random/index.html b/files/fr/web/javascript/reference/global_objects/math/random/index.html deleted file mode 100644 index c5b3df93df..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/random/index.html +++ /dev/null @@ -1,113 +0,0 @@ ---- -title: Math.random() -slug: Web/JavaScript/Reference/Global_Objects/Math/random -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/random -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/random ---- -
{{JSRef}}
- -

La fonction Math.random() renvoie un nombre flottant pseudo-aléatoire compris dans l'intervalle [0, 1[ (ce qui signifie que 0 est compris dans l'intervalle mais que 1 en est exclu) selon une distribution approximativement uniforme sur cet intervalle. Ce nombre peut ensuite être multiplié afin de couvrir un autre intervalle. La graine (seed) du générateur est choisie par l'algorithme et ne peut pas être choisie ou réinitialisée par l'utilisateur.

- -
{{EmbedInteractiveExample("pages/js/math-random.html")}}
- -
-

Note : Math.random() ne fournit pas de nombres aléatoires propres à une cryptographie sécurisée. Les résultats de cette méthode ne doivent pas être utilisées dans des applications liées à la sécurité. À la place, on préfèrera utiliser l'API Web Crypto et plus précisément la méthode {{domxref("RandomSource.getRandomValues()", "window.crypto.getRandomValues()")}}.

-
- -

Syntaxe

- -
Math.random()
- -

Valeur de retour

- -

Un nombre flottant pseudo-aléatoire, généré entre 0 (inclus) et 1 (exclu)

- -

Exemples

- -

En JavaScript, les nombres sont représentés comme des nombres flottants selon la norme IEEE 754 et les arrondis sont pris aux plus près. Aussi, les intervalles revendiqués par les fonctions ci-après (en dehors de Math.random()) ne sont pas théoriquement et précisément exacts. Si on utilise des bornes supérieures très grande (2^53 ou plus), il est alors possible, dans de très rares cas, d'obtenir la borne supérieure comme résultat alors que celle-ci devrait être exclue de l'intervalle.

- -

Obtenir un nombre aléatoire entre 0 et 1

- -
// On renvoie un nombre aléatoire entre 0 (inclus) et 1 (exclus)
-function getRandom() {
-  return Math.random();
-}
- -

Obtenir un nombre aléatoire dans un intervalle

- -
// On renvoie un nombre aléatoire entre une valeur min (incluse)
-// et une valeur max (exclue)
-function getRandomArbitrary(min, max) {
-  return Math.random() * (max - min) + min;
-}
- -

Obtenir un entier aléatoire dans un intervalle ouvert à droite

- -
// On renvoie un entier aléatoire entre une valeur min (incluse)
-// et une valeur max (exclue).
-// Attention : si on utilisait Math.round(), on aurait une distribution
-// non uniforme !
-function getRandomInt(min, max) {
-  min = Math.ceil(min);
-  max = Math.floor(max);
-  return Math.floor(Math.random() * (max - min)) + min;
-}
-
- -
-

Attention : Utiliser Math.round() entraînerait une distribution non-uniforme et réduirait le caractère aléatoire de la méthode.

-
- -

Obtenir un entier aléatoire dans un intervalle fermé

- -
// On renvoie un entier aléatoire entre une valeur min (incluse)
-// et une valeur max (incluse).
-// Attention : si on utilisait Math.round(), on aurait une distribution
-// non uniforme !
-function getRandomIntInclusive(min, max) {
-  min = Math.ceil(min);
-  max = Math.floor(max);
-  return Math.floor(Math.random() * (max - min +1)) + min;
-}
-
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0 (UNIX) et 1.1 (toutes plateformes).
{{SpecName('ES5.1', '#sec-15.8.2.14', 'Math.random')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-math.random', 'Math.random')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-math.random', 'Math.random')}}{{Spec2('ESDraft')}}
- -

Compatibilité des navigateurs

- -

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

diff --git a/files/fr/web/javascript/reference/global_objects/math/random/index.md b/files/fr/web/javascript/reference/global_objects/math/random/index.md new file mode 100644 index 0000000000..c5b3df93df --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/random/index.md @@ -0,0 +1,113 @@ +--- +title: Math.random() +slug: Web/JavaScript/Reference/Global_Objects/Math/random +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/random +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/random +--- +
{{JSRef}}
+ +

La fonction Math.random() renvoie un nombre flottant pseudo-aléatoire compris dans l'intervalle [0, 1[ (ce qui signifie que 0 est compris dans l'intervalle mais que 1 en est exclu) selon une distribution approximativement uniforme sur cet intervalle. Ce nombre peut ensuite être multiplié afin de couvrir un autre intervalle. La graine (seed) du générateur est choisie par l'algorithme et ne peut pas être choisie ou réinitialisée par l'utilisateur.

+ +
{{EmbedInteractiveExample("pages/js/math-random.html")}}
+ +
+

Note : Math.random() ne fournit pas de nombres aléatoires propres à une cryptographie sécurisée. Les résultats de cette méthode ne doivent pas être utilisées dans des applications liées à la sécurité. À la place, on préfèrera utiliser l'API Web Crypto et plus précisément la méthode {{domxref("RandomSource.getRandomValues()", "window.crypto.getRandomValues()")}}.

+
+ +

Syntaxe

+ +
Math.random()
+ +

Valeur de retour

+ +

Un nombre flottant pseudo-aléatoire, généré entre 0 (inclus) et 1 (exclu)

+ +

Exemples

+ +

En JavaScript, les nombres sont représentés comme des nombres flottants selon la norme IEEE 754 et les arrondis sont pris aux plus près. Aussi, les intervalles revendiqués par les fonctions ci-après (en dehors de Math.random()) ne sont pas théoriquement et précisément exacts. Si on utilise des bornes supérieures très grande (2^53 ou plus), il est alors possible, dans de très rares cas, d'obtenir la borne supérieure comme résultat alors que celle-ci devrait être exclue de l'intervalle.

+ +

Obtenir un nombre aléatoire entre 0 et 1

+ +
// On renvoie un nombre aléatoire entre 0 (inclus) et 1 (exclus)
+function getRandom() {
+  return Math.random();
+}
+ +

Obtenir un nombre aléatoire dans un intervalle

+ +
// On renvoie un nombre aléatoire entre une valeur min (incluse)
+// et une valeur max (exclue)
+function getRandomArbitrary(min, max) {
+  return Math.random() * (max - min) + min;
+}
+ +

Obtenir un entier aléatoire dans un intervalle ouvert à droite

+ +
// On renvoie un entier aléatoire entre une valeur min (incluse)
+// et une valeur max (exclue).
+// Attention : si on utilisait Math.round(), on aurait une distribution
+// non uniforme !
+function getRandomInt(min, max) {
+  min = Math.ceil(min);
+  max = Math.floor(max);
+  return Math.floor(Math.random() * (max - min)) + min;
+}
+
+ +
+

Attention : Utiliser Math.round() entraînerait une distribution non-uniforme et réduirait le caractère aléatoire de la méthode.

+
+ +

Obtenir un entier aléatoire dans un intervalle fermé

+ +
// On renvoie un entier aléatoire entre une valeur min (incluse)
+// et une valeur max (incluse).
+// Attention : si on utilisait Math.round(), on aurait une distribution
+// non uniforme !
+function getRandomIntInclusive(min, max) {
+  min = Math.ceil(min);
+  max = Math.floor(max);
+  return Math.floor(Math.random() * (max - min +1)) + min;
+}
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0 (UNIX) et 1.1 (toutes plateformes).
{{SpecName('ES5.1', '#sec-15.8.2.14', 'Math.random')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-math.random', 'Math.random')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-math.random', 'Math.random')}}{{Spec2('ESDraft')}}
+ +

Compatibilité des navigateurs

+ +

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

diff --git a/files/fr/web/javascript/reference/global_objects/math/round/index.html b/files/fr/web/javascript/reference/global_objects/math/round/index.html deleted file mode 100644 index fb671af237..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/round/index.html +++ /dev/null @@ -1,94 +0,0 @@ ---- -title: Math.round() -slug: Web/JavaScript/Reference/Global_Objects/Math/round -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/round -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/round ---- -
{{JSRef}}
- -

La fonction Math.round() retourne la valeur d'un nombre arrondi à l'entier le plus proche.

- -
{{EmbedInteractiveExample("pages/js/math-round.html")}}
- -

Syntaxe

- -
Math.round(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

La valeur de l'entier le plus proche du nombre passé en argument.

- -

Description

- -

Si la partie décimale du nombre est plus grande que 0.5, l'argument est arrondi à l'entier le plus proche dont la valeur absolue est plus grande. Si elle est plus petite que 0.5, l'argument est arrondi à l'entier le plus proche dont la valeur absolue est plus petite. Si la partie décimale du nombre vaut exactement 0.5, l'argument est arrondi à l'entier le plus proche en direction de l'infini positif (attention, pour la plupart des langages de programmation, c'est le nombre avec la plus grande valeur absolue qui est renvoyé ; on a donc une différence de comportement pour les nombres négatifs dont la partie décimale vaut exactement 0.5).

- -

round() étant une méthode statique de Math, elle doit toujours être utilisée avec la syntaxe Math.round(), elle ne doit pas être utilisée comme une méthode d'un objet qui aurait été créé (Math n'est pas un constructeur).

- -

Exemples

- -
Math.round(20.49); //  20
-Math.round(20.5);  //  21
-Math.round(42);    //  42
-Math.round(-20.5); // -20
-Math.round(-20.51);// -21
-
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.15', 'Math.round')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-math.round', 'Math.round')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-math.round', 'Math.round')}}{{Spec2('ESDraft')}}
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/round/index.md b/files/fr/web/javascript/reference/global_objects/math/round/index.md new file mode 100644 index 0000000000..fb671af237 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/round/index.md @@ -0,0 +1,94 @@ +--- +title: Math.round() +slug: Web/JavaScript/Reference/Global_Objects/Math/round +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/round +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/round +--- +
{{JSRef}}
+ +

La fonction Math.round() retourne la valeur d'un nombre arrondi à l'entier le plus proche.

+ +
{{EmbedInteractiveExample("pages/js/math-round.html")}}
+ +

Syntaxe

+ +
Math.round(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

La valeur de l'entier le plus proche du nombre passé en argument.

+ +

Description

+ +

Si la partie décimale du nombre est plus grande que 0.5, l'argument est arrondi à l'entier le plus proche dont la valeur absolue est plus grande. Si elle est plus petite que 0.5, l'argument est arrondi à l'entier le plus proche dont la valeur absolue est plus petite. Si la partie décimale du nombre vaut exactement 0.5, l'argument est arrondi à l'entier le plus proche en direction de l'infini positif (attention, pour la plupart des langages de programmation, c'est le nombre avec la plus grande valeur absolue qui est renvoyé ; on a donc une différence de comportement pour les nombres négatifs dont la partie décimale vaut exactement 0.5).

+ +

round() étant une méthode statique de Math, elle doit toujours être utilisée avec la syntaxe Math.round(), elle ne doit pas être utilisée comme une méthode d'un objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Exemples

+ +
Math.round(20.49); //  20
+Math.round(20.5);  //  21
+Math.round(42);    //  42
+Math.round(-20.5); // -20
+Math.round(-20.51);// -21
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.15', 'Math.round')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-math.round', 'Math.round')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-math.round', 'Math.round')}}{{Spec2('ESDraft')}}
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/sign/index.html b/files/fr/web/javascript/reference/global_objects/math/sign/index.html deleted file mode 100644 index c27e808527..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/sign/index.html +++ /dev/null @@ -1,89 +0,0 @@ ---- -title: Math.sign() -slug: Web/JavaScript/Reference/Global_Objects/Math/sign -tags: - - ECMAScript 2015 - - JavaScript - - Math - - Méthode - - Reference - - polyfill -translation_of: Web/JavaScript/Reference/Global_Objects/Math/sign -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/sign ---- -
{{JSRef}}
- -

La fonction Math.sign() renvoie le signe d'un nombre et permet de savoir si un nombre est positif, négatif ou nul.

- -
{{EmbedInteractiveExample("pages/js/math-sign.html")}}
- -

Syntaxe

- -
Math.sign(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

Un nombre qui représente le signe de l'argument. Si l'argument est un nombre positif, négatif, un zéro positif ou un zéro négatif, la fonction renverra respectivement 1, -1, 0, -0. Sinon, ce sera {{jsxref("NaN")}} qui sera renvoyé.

- -

Description

- -

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

- -

Cette fonction peut renvoyer 5 valeurs : 1, -1, 0, -0, NaN, qui indiquent respectivement que x est un nombre positif, un nombre négatif, zéro, la limite négative de zéro, et n'est pas un nombre pour {{jsxref("NaN")}}.

- -

L'argument passé à cette fonction sera implicitement converti au type number.

- -

Exemples

- -
Math.sign(3)     //  1
-Math.sign(-3)    // -1
-Math.sign("-3")  // -1
-Math.sign(0)     //  0
-Math.sign(-0)    // -0
-Math.sign(NaN)   // NaN
-Math.sign("foo") // NaN
-Math.sign()      // NaN
-
- -

Spécifications

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

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/sign/index.md b/files/fr/web/javascript/reference/global_objects/math/sign/index.md new file mode 100644 index 0000000000..c27e808527 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/sign/index.md @@ -0,0 +1,89 @@ +--- +title: Math.sign() +slug: Web/JavaScript/Reference/Global_Objects/Math/sign +tags: + - ECMAScript 2015 + - JavaScript + - Math + - Méthode + - Reference + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Math/sign +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/sign +--- +
{{JSRef}}
+ +

La fonction Math.sign() renvoie le signe d'un nombre et permet de savoir si un nombre est positif, négatif ou nul.

+ +
{{EmbedInteractiveExample("pages/js/math-sign.html")}}
+ +

Syntaxe

+ +
Math.sign(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

Un nombre qui représente le signe de l'argument. Si l'argument est un nombre positif, négatif, un zéro positif ou un zéro négatif, la fonction renverra respectivement 1, -1, 0, -0. Sinon, ce sera {{jsxref("NaN")}} qui sera renvoyé.

+ +

Description

+ +

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

+ +

Cette fonction peut renvoyer 5 valeurs : 1, -1, 0, -0, NaN, qui indiquent respectivement que x est un nombre positif, un nombre négatif, zéro, la limite négative de zéro, et n'est pas un nombre pour {{jsxref("NaN")}}.

+ +

L'argument passé à cette fonction sera implicitement converti au type number.

+ +

Exemples

+ +
Math.sign(3)     //  1
+Math.sign(-3)    // -1
+Math.sign("-3")  // -1
+Math.sign(0)     //  0
+Math.sign(-0)    // -0
+Math.sign(NaN)   // NaN
+Math.sign("foo") // NaN
+Math.sign()      // NaN
+
+ +

Spécifications

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

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/sin/index.html b/files/fr/web/javascript/reference/global_objects/math/sin/index.html deleted file mode 100644 index 3f3ea2afe8..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/sin/index.html +++ /dev/null @@ -1,91 +0,0 @@ ---- -title: Math.sin() -slug: Web/JavaScript/Reference/Global_Objects/Math/sin -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/sin -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/sin ---- -
{{JSRef}}
- -

La fonction Math.sin() renvoie le sinus d'un nombre.

- -
{{EmbedInteractiveExample("pages/js/math-sin.html")}}
- -

Syntaxe

- -
Math.sin(x)
- -

Paramètres

- -
-
x
-
Un nombre (qui exprime un angle en radians).
-
- -

Valeur de retour

- -

Le sinus de la valeur passée en argument (qui correspond à un angle en radians).

- -

Description

- -

La méthode sin() renvoie une valeur numérique comprise (au sens large) entre 1 et -1 et qui représente le sinus d'un angle donné en radians.

- -

sin() est une méthode statique de Math, elle doit être utilisée avec la syntaxe Math.sin(), elle ne doit pas être utilisée comme une méthode d'un objet qui aurait été créé (Math n'est pas un constructeur).

- -

Exemples

- -
Math.sin(0);           // 0
-Math.sin(1);           // 0.8414709848078965
-
-Math.sin(Math.PI / 2); // 1
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.16', 'Math.sin')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.sin', 'Math.sin')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.sin', 'Math.sin')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/sin/index.md b/files/fr/web/javascript/reference/global_objects/math/sin/index.md new file mode 100644 index 0000000000..3f3ea2afe8 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/sin/index.md @@ -0,0 +1,91 @@ +--- +title: Math.sin() +slug: Web/JavaScript/Reference/Global_Objects/Math/sin +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/sin +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/sin +--- +
{{JSRef}}
+ +

La fonction Math.sin() renvoie le sinus d'un nombre.

+ +
{{EmbedInteractiveExample("pages/js/math-sin.html")}}
+ +

Syntaxe

+ +
Math.sin(x)
+ +

Paramètres

+ +
+
x
+
Un nombre (qui exprime un angle en radians).
+
+ +

Valeur de retour

+ +

Le sinus de la valeur passée en argument (qui correspond à un angle en radians).

+ +

Description

+ +

La méthode sin() renvoie une valeur numérique comprise (au sens large) entre 1 et -1 et qui représente le sinus d'un angle donné en radians.

+ +

sin() est une méthode statique de Math, elle doit être utilisée avec la syntaxe Math.sin(), elle ne doit pas être utilisée comme une méthode d'un objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Exemples

+ +
Math.sin(0);           // 0
+Math.sin(1);           // 0.8414709848078965
+
+Math.sin(Math.PI / 2); // 1
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.16', 'Math.sin')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.sin', 'Math.sin')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.sin', 'Math.sin')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/sinh/index.html b/files/fr/web/javascript/reference/global_objects/math/sinh/index.html deleted file mode 100644 index 4edf3a2ad5..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/sinh/index.html +++ /dev/null @@ -1,95 +0,0 @@ ---- -title: Math.sinh() -slug: Web/JavaScript/Reference/Global_Objects/Math/sinh -tags: - - ECMAScript 2015 - - JavaScript - - Math - - Méthode - - Reference - - polyfill -translation_of: Web/JavaScript/Reference/Global_Objects/Math/sinh -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/sinh ---- -
{{JSRef}}
- -

La fonction Math.sinh() renvoie le sinus hyperbolique d'un nombre, dont la formule, utilisant la constante {{jsxref("Math.E","e")}}, est :

- -

Math.sinh(x)=ex-e-x2\mathtt{\operatorname{Math.sinh(x)}} = \frac{e^x - e^{-x}}{2}

- -
{{EmbedInteractiveExample("pages/js/math-sinh.html")}}
- -

Syntaxe

- -
Math.sinh(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

Le sinus hyperbolique de la valeur passée en argument.

- -

Description

- -

sinh() est une méthode statique de Math, il faut utiliser la syntaxe Math.sinh(). Cette méthode ne doit pas être appelée depuis un autre objet qui aurait été créé (Math n'est pas un constructeur).

- -

Exemples

- -
Math.sinh(0) // 0
-Math.sinh(1) // 1.1752011936438014
- -

Prothèse d'émulation (polyfill)

- -

Si cette fonction n'est pas disponible, elle peut être émulée en utilisant la fonction {{jsxref("Math.exp()")}} :

- -
Math.sinh = Math.sinh || function(x){
-    return (Math.exp(x) - Math.exp(-x)) / 2;
-};
- -

ou encore, si on n'utilise qu'une fois {{jsxref("Math.exp()")}}, avec :

- -
Math.sinh = Math.sinh || function(x){
-    var y = Math.exp(x);
-    return (y - 1/y) / 2;
-};
- -

Spécifications

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

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/sinh/index.md b/files/fr/web/javascript/reference/global_objects/math/sinh/index.md new file mode 100644 index 0000000000..4edf3a2ad5 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/sinh/index.md @@ -0,0 +1,95 @@ +--- +title: Math.sinh() +slug: Web/JavaScript/Reference/Global_Objects/Math/sinh +tags: + - ECMAScript 2015 + - JavaScript + - Math + - Méthode + - Reference + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Math/sinh +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/sinh +--- +
{{JSRef}}
+ +

La fonction Math.sinh() renvoie le sinus hyperbolique d'un nombre, dont la formule, utilisant la constante {{jsxref("Math.E","e")}}, est :

+ +

Math.sinh(x)=ex-e-x2\mathtt{\operatorname{Math.sinh(x)}} = \frac{e^x - e^{-x}}{2}

+ +
{{EmbedInteractiveExample("pages/js/math-sinh.html")}}
+ +

Syntaxe

+ +
Math.sinh(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

Le sinus hyperbolique de la valeur passée en argument.

+ +

Description

+ +

sinh() est une méthode statique de Math, il faut utiliser la syntaxe Math.sinh(). Cette méthode ne doit pas être appelée depuis un autre objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Exemples

+ +
Math.sinh(0) // 0
+Math.sinh(1) // 1.1752011936438014
+ +

Prothèse d'émulation (polyfill)

+ +

Si cette fonction n'est pas disponible, elle peut être émulée en utilisant la fonction {{jsxref("Math.exp()")}} :

+ +
Math.sinh = Math.sinh || function(x){
+    return (Math.exp(x) - Math.exp(-x)) / 2;
+};
+ +

ou encore, si on n'utilise qu'une fois {{jsxref("Math.exp()")}}, avec :

+ +
Math.sinh = Math.sinh || function(x){
+    var y = Math.exp(x);
+    return (y - 1/y) / 2;
+};
+ +

Spécifications

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

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/sqrt/index.html b/files/fr/web/javascript/reference/global_objects/math/sqrt/index.html deleted file mode 100644 index 6b309e4d01..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/sqrt/index.html +++ /dev/null @@ -1,94 +0,0 @@ ---- -title: Math.sqrt() -slug: Web/JavaScript/Reference/Global_Objects/Math/sqrt -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/sqrt -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/sqrt ---- -
{{JSRef}}
- -

La fonction Math.sqrt() renvoie la racine carrée d'un nombre. Cette fonction est définie par :

- -

x0,Math.sqrt(x)=x=l'uniquey0tel quey2=x\forall x \geq 0, \mathtt{Math.sqrt(x)} = \sqrt{x} = \text{the unique} \; y \geq 0 \; \text{such that} \; y^2 = x

- -
{{EmbedInteractiveExample("pages/js/math-sqrt.html")}}
- -

Syntaxe

- -
Math.sqrt(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

La racine carrée du nombre passé en argument. Si le nombre fourni est négatif, c'est {{jsxref("NaN")}} qui sera renvoyé.

- -

Description

- -

Si la valeur de x est négative, sqrt renverra {{jsxref("NaN")}}.

- -

sqrt() est une méthode statique de Math, elle doit être utilisée avec la syntaxe Math.sqrt(), elle ne doit pas être appelée comme méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

- -

Exemples

- -
Math.sqrt(9);  // 3
-Math.sqrt(2);  // 1.414213562373095
-
-Math.sqrt(1);  // 1
-Math.sqrt(0);  // 0
-Math.sqrt(-1); // NaN
-Math.sqrt(-0); // -0
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.17', 'Math.sqrt')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.sqrt', 'Math.sqrt')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.sqrt', 'Math.sqrt')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/sqrt/index.md b/files/fr/web/javascript/reference/global_objects/math/sqrt/index.md new file mode 100644 index 0000000000..6b309e4d01 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/sqrt/index.md @@ -0,0 +1,94 @@ +--- +title: Math.sqrt() +slug: Web/JavaScript/Reference/Global_Objects/Math/sqrt +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/sqrt +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/sqrt +--- +
{{JSRef}}
+ +

La fonction Math.sqrt() renvoie la racine carrée d'un nombre. Cette fonction est définie par :

+ +

x0,Math.sqrt(x)=x=l'uniquey0tel quey2=x\forall x \geq 0, \mathtt{Math.sqrt(x)} = \sqrt{x} = \text{the unique} \; y \geq 0 \; \text{such that} \; y^2 = x

+ +
{{EmbedInteractiveExample("pages/js/math-sqrt.html")}}
+ +

Syntaxe

+ +
Math.sqrt(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

La racine carrée du nombre passé en argument. Si le nombre fourni est négatif, c'est {{jsxref("NaN")}} qui sera renvoyé.

+ +

Description

+ +

Si la valeur de x est négative, sqrt renverra {{jsxref("NaN")}}.

+ +

sqrt() est une méthode statique de Math, elle doit être utilisée avec la syntaxe Math.sqrt(), elle ne doit pas être appelée comme méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Exemples

+ +
Math.sqrt(9);  // 3
+Math.sqrt(2);  // 1.414213562373095
+
+Math.sqrt(1);  // 1
+Math.sqrt(0);  // 0
+Math.sqrt(-1); // NaN
+Math.sqrt(-0); // -0
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.17', 'Math.sqrt')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.sqrt', 'Math.sqrt')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.sqrt', 'Math.sqrt')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/sqrt1_2/index.html b/files/fr/web/javascript/reference/global_objects/math/sqrt1_2/index.html deleted file mode 100644 index 7a1037786c..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/sqrt1_2/index.html +++ /dev/null @@ -1,79 +0,0 @@ ---- -title: Math.SQRT1_2 -slug: Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2 -tags: - - JavaScript - - Math - - Propriété - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2 -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/SQRT1_2 ---- -
{{JSRef}}
- -

La propriété Math.SQRT1_2 représente la racine carrée d'1/2 et vaut environ 0.707 :

- -

Math.SQRT1_2=12=120.707\mathtt{\mi{Math.SQRT1_2}} = \sqrt{\frac{1}{2}} = \frac{1}{\sqrt{2}} \approx 0.707

- -
{{EmbedInteractiveExample("pages/js/math-sqrt1_2.html")}}
- - - -
{{js_property_attributes(0,0,0)}}
- -

Description

- -

SQRT1_2 est une propriété statique de Math et doit toujours être utilisée avec la syntaxe Math.SQRT1_2. Elle ne doit pas être obtenue à partir d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

- -

Exemples

- -

La fonction suivante renvoie la valeur de cette constante :

- -
function getRoot1_2() {
-   return Math.SQRT1_2;
-}
-
-getRoot1_2(); // 0.7071067811865476
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.7', 'Math.SQRT1_2')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.sqrt1_2', 'Math.SQRT1_2')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.sqrt1_2', 'Math.SQRT1_2')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/sqrt1_2/index.md b/files/fr/web/javascript/reference/global_objects/math/sqrt1_2/index.md new file mode 100644 index 0000000000..7a1037786c --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/sqrt1_2/index.md @@ -0,0 +1,79 @@ +--- +title: Math.SQRT1_2 +slug: Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2 +tags: + - JavaScript + - Math + - Propriété + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2 +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/SQRT1_2 +--- +
{{JSRef}}
+ +

La propriété Math.SQRT1_2 représente la racine carrée d'1/2 et vaut environ 0.707 :

+ +

Math.SQRT1_2=12=120.707\mathtt{\mi{Math.SQRT1_2}} = \sqrt{\frac{1}{2}} = \frac{1}{\sqrt{2}} \approx 0.707

+ +
{{EmbedInteractiveExample("pages/js/math-sqrt1_2.html")}}
+ + + +
{{js_property_attributes(0,0,0)}}
+ +

Description

+ +

SQRT1_2 est une propriété statique de Math et doit toujours être utilisée avec la syntaxe Math.SQRT1_2. Elle ne doit pas être obtenue à partir d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Exemples

+ +

La fonction suivante renvoie la valeur de cette constante :

+ +
function getRoot1_2() {
+   return Math.SQRT1_2;
+}
+
+getRoot1_2(); // 0.7071067811865476
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.7', 'Math.SQRT1_2')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.sqrt1_2', 'Math.SQRT1_2')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.sqrt1_2', 'Math.SQRT1_2')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/sqrt2/index.html b/files/fr/web/javascript/reference/global_objects/math/sqrt2/index.html deleted file mode 100644 index 964c355404..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/sqrt2/index.html +++ /dev/null @@ -1,79 +0,0 @@ ---- -title: Math.SQRT2 -slug: Web/JavaScript/Reference/Global_Objects/Math/SQRT2 -tags: - - JavaScript - - Math - - Propriété - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/SQRT2 -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/SQRT2 ---- -
{{JSRef}}
- -

La propriété Math.SQRT2 représente la racine carrée de 2 et vaut environ 1.414 :

- -

Math.SQRT2=21.414\mathtt{\mi{Math.SQRT2}} = \sqrt{2} \approx 1.414

- -
{{EmbedInteractiveExample("pages/js/math-sqrt2.html")}}
- - - -
{{js_property_attributes(0,0,0)}}
- -

Description

- -

SQRT2 est une propriété statique de Math et doit toujours être utilisée avec la syntaxe Math.SQRT2, elle ne doit pas être appelée comme propriété d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

- -

Exemples

- -

La fonction suivante renvoie la valeur de la racine carrée de 2 :

- -
function getRoot2() {
-   return Math.SQRT2;
-}
-
-getRoot2(); // 1.4142135623730951
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.8', 'Math.SQRT2')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.sqrt2', 'Math.SQRT2')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.sqrt2', 'Math.SQRT2')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/sqrt2/index.md b/files/fr/web/javascript/reference/global_objects/math/sqrt2/index.md new file mode 100644 index 0000000000..964c355404 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/sqrt2/index.md @@ -0,0 +1,79 @@ +--- +title: Math.SQRT2 +slug: Web/JavaScript/Reference/Global_Objects/Math/SQRT2 +tags: + - JavaScript + - Math + - Propriété + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/SQRT2 +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/SQRT2 +--- +
{{JSRef}}
+ +

La propriété Math.SQRT2 représente la racine carrée de 2 et vaut environ 1.414 :

+ +

Math.SQRT2=21.414\mathtt{\mi{Math.SQRT2}} = \sqrt{2} \approx 1.414

+ +
{{EmbedInteractiveExample("pages/js/math-sqrt2.html")}}
+ + + +
{{js_property_attributes(0,0,0)}}
+ +

Description

+ +

SQRT2 est une propriété statique de Math et doit toujours être utilisée avec la syntaxe Math.SQRT2, elle ne doit pas être appelée comme propriété d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Exemples

+ +

La fonction suivante renvoie la valeur de la racine carrée de 2 :

+ +
function getRoot2() {
+   return Math.SQRT2;
+}
+
+getRoot2(); // 1.4142135623730951
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.8', 'Math.SQRT2')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.sqrt2', 'Math.SQRT2')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.sqrt2', 'Math.SQRT2')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/tan/index.html b/files/fr/web/javascript/reference/global_objects/math/tan/index.html deleted file mode 100644 index 17d938acab..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/tan/index.html +++ /dev/null @@ -1,98 +0,0 @@ ---- -title: Math.tan() -slug: Web/JavaScript/Reference/Global_Objects/Math/tan -tags: - - JavaScript - - Math - - Méthode - - Reference -translation_of: Web/JavaScript/Reference/Global_Objects/Math/tan -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/tan ---- -
{{JSRef}}
- -

La fonction Math.tan() renvoie la tangente d'un nombre exprimant un angle en radians.

- -
{{EmbedInteractiveExample("pages/js/math-tan.html")}}
- -

Syntaxe

- -
Math.tan(x)
- -

Paramètres

- -
-
x
-
Un nombre qui représente un angle en radians.
-
- -

Valeur de retour

- -

La tangente de l'angle fourni en argument (exprimé en radians).

- -

Description

- -

La méthode Math.tan() renvoie une valeur numérique qui représente la tangente d'un angle.

- -

tan() est une méthode statique de Math et doit toujours être utilisée avec la syntaxe Math.tan(), elle ne doit pas être utilisée comme méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

- -

Exemples

- -

Utiliser Math.tan()

- -
Math.tan(1); // 1.5574077246549023
- -

Math.tan() considère un argument exprimé en radians. Cependant, on peut vouloir travailler avec des valeurs en degrés. Pour cela, on pourra utiliser la fonction suivante qui calcule la tangente après avoir converti l'argument en radians :

- -
function getTanDeg(deg) {
-   var rad = deg * Math.PI/180;
-   return Math.tan(rad);
-}
-
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.18', 'Math.tan')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.tan', 'Math.tan')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.tan', 'Math.tan')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/tan/index.md b/files/fr/web/javascript/reference/global_objects/math/tan/index.md new file mode 100644 index 0000000000..17d938acab --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/tan/index.md @@ -0,0 +1,98 @@ +--- +title: Math.tan() +slug: Web/JavaScript/Reference/Global_Objects/Math/tan +tags: + - JavaScript + - Math + - Méthode + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/tan +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/tan +--- +
{{JSRef}}
+ +

La fonction Math.tan() renvoie la tangente d'un nombre exprimant un angle en radians.

+ +
{{EmbedInteractiveExample("pages/js/math-tan.html")}}
+ +

Syntaxe

+ +
Math.tan(x)
+ +

Paramètres

+ +
+
x
+
Un nombre qui représente un angle en radians.
+
+ +

Valeur de retour

+ +

La tangente de l'angle fourni en argument (exprimé en radians).

+ +

Description

+ +

La méthode Math.tan() renvoie une valeur numérique qui représente la tangente d'un angle.

+ +

tan() est une méthode statique de Math et doit toujours être utilisée avec la syntaxe Math.tan(), elle ne doit pas être utilisée comme méthode d'un autre objet qui aurait été créé (Math n'est pas un constructeur).

+ +

Exemples

+ +

Utiliser Math.tan()

+ +
Math.tan(1); // 1.5574077246549023
+ +

Math.tan() considère un argument exprimé en radians. Cependant, on peut vouloir travailler avec des valeurs en degrés. Pour cela, on pourra utiliser la fonction suivante qui calcule la tangente après avoir converti l'argument en radians :

+ +
function getTanDeg(deg) {
+   var rad = deg * Math.PI/180;
+   return Math.tan(rad);
+}
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.18', 'Math.tan')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.tan', 'Math.tan')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.tan', 'Math.tan')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/tanh/index.html b/files/fr/web/javascript/reference/global_objects/math/tanh/index.html deleted file mode 100644 index be6fc10fd0..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/tanh/index.html +++ /dev/null @@ -1,105 +0,0 @@ ---- -title: Math.tanh() -slug: Web/JavaScript/Reference/Global_Objects/Math/tanh -tags: - - ECMAScript 2015 - - JavaScript - - Math - - Méthode - - Reference - - polyfill -translation_of: Web/JavaScript/Reference/Global_Objects/Math/tanh -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/tanh ---- -
{{JSRef}}
- -

La fonction Math.tanh() renvoie la tangente hyperbolique d'un nombre définie par :

- -

tanhx=sinhxcoshx=ex-e-xex+e-x=e2x-1e2x+1\tanh x = \frac{\sinh x}{\cosh x} = \frac {e^x - e^{-x}} {e^x + e^{-x}} = \frac{e^{2x} - 1}{e^{2x}+1}

- -
{{EmbedInteractiveExample("pages/js/math-tanh.html")}}
- -

Syntaxe

- -
Math.tanh(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

La tangente hyperbolique du nombre fourni en argument.

- -

Description

- -

tanh() est une méthode statique de l'objet Math, elle doit toujours être utilisée avec la syntaxe Math.tanh(), elle ne doit pas être utilisée comme une méthode d'un objet Math qui aurait été instancié (Math n'est pas une constructeur).

- -

Exemples

- -

Utiliser Math.tanh()

- -
Math.tanh(0);        // 0
-Math.tanh(Infinity); // 1
-Math.tanh(1);        // 0.7615941559557649
- -

Prothèse d'émulation (polyfill)

- -

Cette méthode peut être émulée grâce à la fonction {{jsxref("Objets_globaux/Math/exp", "Math.exp()")}} :

- -
Math.tanh = Math.tanh || function(x){
-  var a = Math.exp(+x), b = Math.exp(-x);
-  return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (a + b);
-}
- -

et si on souhaite n'utiliser qu'un seul appel à {{jsxref("Objets_globaux/Math/exp", "Math.exp()")}} :

- -
Math.tanhx = Math.tanhx || function(x) {
-  if(x === Infinity) {
-    return 1;
-  } else if(x === -Infinity) {
-    return -1;
-  } else {
-    var y = Math.exp(2 * x);
-    return (y - 1) / (y + 1);
-  }
-};
- -

Spécifications

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

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/tanh/index.md b/files/fr/web/javascript/reference/global_objects/math/tanh/index.md new file mode 100644 index 0000000000..be6fc10fd0 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/tanh/index.md @@ -0,0 +1,105 @@ +--- +title: Math.tanh() +slug: Web/JavaScript/Reference/Global_Objects/Math/tanh +tags: + - ECMAScript 2015 + - JavaScript + - Math + - Méthode + - Reference + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Math/tanh +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/tanh +--- +
{{JSRef}}
+ +

La fonction Math.tanh() renvoie la tangente hyperbolique d'un nombre définie par :

+ +

tanhx=sinhxcoshx=ex-e-xex+e-x=e2x-1e2x+1\tanh x = \frac{\sinh x}{\cosh x} = \frac {e^x - e^{-x}} {e^x + e^{-x}} = \frac{e^{2x} - 1}{e^{2x}+1}

+ +
{{EmbedInteractiveExample("pages/js/math-tanh.html")}}
+ +

Syntaxe

+ +
Math.tanh(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

La tangente hyperbolique du nombre fourni en argument.

+ +

Description

+ +

tanh() est une méthode statique de l'objet Math, elle doit toujours être utilisée avec la syntaxe Math.tanh(), elle ne doit pas être utilisée comme une méthode d'un objet Math qui aurait été instancié (Math n'est pas une constructeur).

+ +

Exemples

+ +

Utiliser Math.tanh()

+ +
Math.tanh(0);        // 0
+Math.tanh(Infinity); // 1
+Math.tanh(1);        // 0.7615941559557649
+ +

Prothèse d'émulation (polyfill)

+ +

Cette méthode peut être émulée grâce à la fonction {{jsxref("Objets_globaux/Math/exp", "Math.exp()")}} :

+ +
Math.tanh = Math.tanh || function(x){
+  var a = Math.exp(+x), b = Math.exp(-x);
+  return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (a + b);
+}
+ +

et si on souhaite n'utiliser qu'un seul appel à {{jsxref("Objets_globaux/Math/exp", "Math.exp()")}} :

+ +
Math.tanhx = Math.tanhx || function(x) {
+  if(x === Infinity) {
+    return 1;
+  } else if(x === -Infinity) {
+    return -1;
+  } else {
+    var y = Math.exp(2 * x);
+    return (y - 1) / (y + 1);
+  }
+};
+ +

Spécifications

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

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/javascript/reference/global_objects/math/trunc/index.html b/files/fr/web/javascript/reference/global_objects/math/trunc/index.html deleted file mode 100644 index c78b0cb6ec..0000000000 --- a/files/fr/web/javascript/reference/global_objects/math/trunc/index.html +++ /dev/null @@ -1,94 +0,0 @@ ---- -title: Math.trunc() -slug: Web/JavaScript/Reference/Global_Objects/Math/trunc -tags: - - ECMAScript 2015 - - JavaScript - - Math - - Méthode - - Reference - - polyfill -translation_of: Web/JavaScript/Reference/Global_Objects/Math/trunc -original_slug: Web/JavaScript/Reference/Objets_globaux/Math/trunc ---- -
{{JSRef}}
- -

La fonction Math.trunc() retourne la troncature entière d'un nombre en retirant sa partie décimale.

- -

Math.trunc(x)={xsix0xsix<0\mathtt{\operatorname{Math.trunc}(x)} = \begin{cases} \left\lfloor x \right\rfloor & \text{if} & x \geq 0 \\ \left\lceil x \right\rceil & \text{if} &x < 0 \end{cases}

- -
{{EmbedInteractiveExample("pages/js/math-trunc.html")}}
- -

Syntaxe

- -
Math.trunc(x)
- -

Paramètres

- -
-
x
-
Un nombre.
-
- -

Valeur de retour

- -

La partie entière du nombre passé en argument.

- -

Description

- -

Contrairement aux autres méthodes {{jsxref("Math.floor()")}}, {{jsxref("Math.ceil()")}} et {{jsxref("Math.round()")}}, Math.trunc() fonctionne de façon très simple : la partie décimale du nombre est retirée et on conserve la partie entière (que le nombre soit positif ou négatif).
-
- Ainsi, si l'argument est un nombre positif, Math.trunc() sera équivalent à Math.floor(), sinon Math.trunc() sera équivalent à Math.ceil().

- -

On notera que l'argument passé à la méthode est converti en nombre de façon implicite.

- -

trunc() est une méthode statique de Math, elle doit toujours être utilisée avec la syntaxe Math.trunc(), elle ne doit pas être utilisée comme la méthode d'un objet qui aurait été instancié (Math n'est pas un constructeur).

- -

Exemples

- -

Utiliser Math.trunc()

- -
Math.trunc(13.37);   // 13
-Math.trunc(42.84);   // 42
-Math.trunc(0.123);   //  0
-Math.trunc(-0.123);  // -0
-Math.trunc("-1.123");// -1
-Math.trunc(NaN);     // NaN
-Math.trunc("toto");  // NaN
-Math.trunc();        // NaN
- -

Spécifications

- - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaire
{{SpecName('ES2015', '#sec-math.trunc', 'Math.trunc')}}{{Spec2('ES2015')}}Première définition.
{{SpecName('ESDraft', '#sec-math.trunc', 'Math.trunc')}}{{Spec2('ESDraft')}}
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/math/trunc/index.md b/files/fr/web/javascript/reference/global_objects/math/trunc/index.md new file mode 100644 index 0000000000..c78b0cb6ec --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/math/trunc/index.md @@ -0,0 +1,94 @@ +--- +title: Math.trunc() +slug: Web/JavaScript/Reference/Global_Objects/Math/trunc +tags: + - ECMAScript 2015 + - JavaScript + - Math + - Méthode + - Reference + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Math/trunc +original_slug: Web/JavaScript/Reference/Objets_globaux/Math/trunc +--- +
{{JSRef}}
+ +

La fonction Math.trunc() retourne la troncature entière d'un nombre en retirant sa partie décimale.

+ +

Math.trunc(x)={xsix0xsix<0\mathtt{\operatorname{Math.trunc}(x)} = \begin{cases} \left\lfloor x \right\rfloor & \text{if} & x \geq 0 \\ \left\lceil x \right\rceil & \text{if} &x < 0 \end{cases}

+ +
{{EmbedInteractiveExample("pages/js/math-trunc.html")}}
+ +

Syntaxe

+ +
Math.trunc(x)
+ +

Paramètres

+ +
+
x
+
Un nombre.
+
+ +

Valeur de retour

+ +

La partie entière du nombre passé en argument.

+ +

Description

+ +

Contrairement aux autres méthodes {{jsxref("Math.floor()")}}, {{jsxref("Math.ceil()")}} et {{jsxref("Math.round()")}}, Math.trunc() fonctionne de façon très simple : la partie décimale du nombre est retirée et on conserve la partie entière (que le nombre soit positif ou négatif).
+
+ Ainsi, si l'argument est un nombre positif, Math.trunc() sera équivalent à Math.floor(), sinon Math.trunc() sera équivalent à Math.ceil().

+ +

On notera que l'argument passé à la méthode est converti en nombre de façon implicite.

+ +

trunc() est une méthode statique de Math, elle doit toujours être utilisée avec la syntaxe Math.trunc(), elle ne doit pas être utilisée comme la méthode d'un objet qui aurait été instancié (Math n'est pas un constructeur).

+ +

Exemples

+ +

Utiliser Math.trunc()

+ +
Math.trunc(13.37);   // 13
+Math.trunc(42.84);   // 42
+Math.trunc(0.123);   //  0
+Math.trunc(-0.123);  // -0
+Math.trunc("-1.123");// -1
+Math.trunc(NaN);     // NaN
+Math.trunc("toto");  // NaN
+Math.trunc();        // NaN
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaire
{{SpecName('ES2015', '#sec-math.trunc', 'Math.trunc')}}{{Spec2('ES2015')}}Première définition.
{{SpecName('ESDraft', '#sec-math.trunc', 'Math.trunc')}}{{Spec2('ESDraft')}}
+ +

Compatibilité des navigateurs

+ +

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

+ +

Voir aussi

+ + -- cgit v1.2.3-54-g00ecf