diff options
| author | julieng <julien.gattelier@gmail.com> | 2021-08-03 08:03:23 +0200 |
|---|---|---|
| committer | SphinxKnight <SphinxKnight@users.noreply.github.com> | 2021-09-03 08:08:25 +0200 |
| commit | bf8e099b9c8b3c60d60b3712b4fc97b052c39887 (patch) | |
| tree | c101746d082c9581c94f5937519c7d0e2f4af8cb /files/fr/web/javascript/reference/global_objects/math/sign | |
| parent | 844f5103992238c0c23203286dad16a466e89c97 (diff) | |
| download | translated-content-bf8e099b9c8b3c60d60b3712b4fc97b052c39887.tar.gz translated-content-bf8e099b9c8b3c60d60b3712b4fc97b052c39887.tar.bz2 translated-content-bf8e099b9c8b3c60d60b3712b4fc97b052c39887.zip | |
convert content to md
Diffstat (limited to 'files/fr/web/javascript/reference/global_objects/math/sign')
| -rw-r--r-- | files/fr/web/javascript/reference/global_objects/math/sign/index.md | 92 |
1 files changed, 37 insertions, 55 deletions
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 index c27e808527..44a438171e 100644 --- a/files/fr/web/javascript/reference/global_objects/math/sign/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/sign/index.md @@ -11,38 +11,37 @@ tags: translation_of: Web/JavaScript/Reference/Global_Objects/Math/sign original_slug: Web/JavaScript/Reference/Objets_globaux/Math/sign --- -<div>{{JSRef}}</div> +{{JSRef}} -<p>La fonction <code><strong>Math.sign()</strong></code> renvoie le signe d'un nombre et permet de savoir si un nombre est positif, négatif ou nul.</p> +La fonction **`Math.sign()`** renvoie le signe d'un nombre et permet de savoir si un nombre est positif, négatif ou nul. -<div>{{EmbedInteractiveExample("pages/js/math-sign.html")}}</div> +{{EmbedInteractiveExample("pages/js/math-sign.html")}} -<h2 id="Syntaxe">Syntaxe</h2> +## Syntaxe -<pre class="syntaxbox">Math.sign(<var>x</var>)</pre> + Math.sign(x) -<h3 id="Paramètres">Paramètres</h3> +### Paramètres -<dl> - <dt><code>x</code></dt> - <dd>Un nombre.</dd> -</dl> +- `x` + - : Un nombre. -<h3 id="Valeur_de_retour">Valeur de retour</h3> +### Valeur de retour -<p>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 <code>1</code>, <code>-1</code>, <code>0</code>, <code>-0</code>. Sinon, ce sera {{jsxref("NaN")}} qui sera renvoyé.</p> +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é. -<h2 id="Description">Description</h2> +## Description -<p><code>sign()</code> étant une méthode statique de <code>Math</code>, il faut utiliser <code>Math.<code>sign</code>()</code> et non pas la méthode d'un autre objet qui aurait été créé (<code>Math </code>n'est pas un constructeur).</p> +`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). -<p>Cette fonction peut renvoyer 5 valeurs : <code>1, -1, 0, -0, NaN,</code> qui indiquent respectivement que <code>x</code> 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")}}.</p> +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")}}. -<p>L'argument passé à cette fonction sera implicitement converti au type <code>number</code>.</p> +L'argument passé à cette fonction sera implicitement converti au type `number`. -<h2 id="Exemples">Exemples</h2> +## Exemples -<pre class="brush:js">Math.sign(3) // 1 +```js +Math.sign(3) // 1 Math.sign(-3) // -1 Math.sign("-3") // -1 Math.sign(0) // 0 @@ -50,40 +49,23 @@ Math.sign(-0) // -0 Math.sign(NaN) // NaN Math.sign("foo") // NaN Math.sign() // NaN -</pre> - -<h2 id="Spécifications">Spécifications</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">Spécification</th> - <th scope="col">État</th> - <th scope="col">Commentaires</th> - </tr> - <tr> - <td>{{SpecName('ES6', '#sec-math.sign', 'Math.sign')}}</td> - <td>{{Spec2('ES6')}}</td> - <td>Définition initiale.</td> - </tr> - <tr> - <td>{{SpecName('ESDraft', '#sec-math.sign', 'Math.sign')}}</td> - <td>{{Spec2('ESDraft')}}</td> - <td></td> - </tr> - </tbody> -</table> - -<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2> - -<p>{{Compat("javascript.builtins.Math.sign")}}</p> - -<h2 id="Voir_aussi">Voir aussi</h2> - -<ul> - <li>{{jsxref("Math.abs()")}}</li> - <li>{{jsxref("Math.ceil()")}}</li> - <li>{{jsxref("Math.floor()")}}</li> - <li>{{jsxref("Math.round()")}}</li> - <li>{{jsxref("Math.trunc()")}}</li> -</ul> +``` + +## Spécifications + +| Spécification | État | Commentaires | +| ------------------------------------------------------------------------ | ---------------------------- | -------------------- | +| {{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 + +- {{jsxref("Math.abs()")}} +- {{jsxref("Math.ceil()")}} +- {{jsxref("Math.floor()")}} +- {{jsxref("Math.round()")}} +- {{jsxref("Math.trunc()")}} |
