diff options
| author | SphinxKnight <SphinxKnight@users.noreply.github.com> | 2021-06-27 15:03:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-27 15:03:56 +0200 |
| commit | 9f030ef5fd3a0dc15d94c01d0e1bbd1aba1eed54 (patch) | |
| tree | e6aa6c44ea4c523dbf72464e77745bed1efc8c51 /files/fr/web/javascript/reference/operators/remainder | |
| parent | dc9842009bd95e0db7e058a5ebb98f27d6a3f650 (diff) | |
| download | translated-content-9f030ef5fd3a0dc15d94c01d0e1bbd1aba1eed54.tar.gz translated-content-9f030ef5fd3a0dc15d94c01d0e1bbd1aba1eed54.tar.bz2 translated-content-9f030ef5fd3a0dc15d94c01d0e1bbd1aba1eed54.zip | |
Fix #756 by updating the JS operators in fr (#1306)
* Update Operators landing + revamp L10N for 4 operators
* Added NOT / ! -
* +multiplication
* Addition, exponentiation and comparison
* Operateurs de comparaison
* Binary ops
* Missing newline, thx GH UI
* Logical AND / OR
* Assignment ops
* Conflicting clean-up
* Missing EOF newline
* Fix history and redirects
* FIX: fix flaws
* FIX: minox typo fix
* FIX: link flaws
* FIX: fix tags detection
Co-authored-by: tristantheb <tristantheb@gmail.com>
Diffstat (limited to 'files/fr/web/javascript/reference/operators/remainder')
| -rw-r--r-- | files/fr/web/javascript/reference/operators/remainder/index.html | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/files/fr/web/javascript/reference/operators/remainder/index.html b/files/fr/web/javascript/reference/operators/remainder/index.html new file mode 100644 index 0000000000..c5df6dd43d --- /dev/null +++ b/files/fr/web/javascript/reference/operators/remainder/index.html @@ -0,0 +1,80 @@ +--- +title: Reste (%) +slug: Web/JavaScript/Reference/Operators/Remainder +tags: + - JavaScript + - Language feature + - Operator + - Reference +browser-compat: javascript.operators.remainder +translation-of: Web/JavaScript/Reference/Operators/Remainder +--- +<div>{{jsSidebar("Operators")}}</div> + +<p>L'opérateur du reste (<code>%</code>) renvoie le reste de la division de l'opérande gauche par l'opérande droit. Le résultat a toujours le signe du numérateur.</p> + +<div>{{EmbedInteractiveExample("pages/js/expressions-remainder.html")}}</div> + +<p>Bien que dans la plupart des langages, <code>%</code> est un opérateur de reste, pour d'autres (par exemple <a href="https://en.wikipedia.org/wiki/Modulo_operation#In_programming_languages">Python, Perl</a>) c'est un opérateur de modulo. Lorsqu'on utilise des valeurs positives, les deux opérateurs sont équivalents mais lorsque le numérateur et de dénominateur ont des signes différents, le reste et le modulo fourniront des signes différents. Pour obtenir une opération équivalente au modulo en JavaScript, on pourra utiliser <code>((a % n ) + n ) % n</code>.</p> + +<h2 id="syntax">Syntaxe</h2> + +<pre class="brush: js"> +<strong>Opérateur :</strong> <var>var1</var> % <var>var2</var> +</pre> + +<h2 id="examples">Exemples</h2> + +<h3 id="remainder_with_positive_dividend">Reste avec numérateur positif</h3> + +<pre class="brush: js"> +12 % 5 // 2 + 1 % -2 // 1 + 1 % 2 // 1 + 2 % 3 // 2 +5.5 % 2 // 1.5 +</pre> + +<h3 id="remainder_with_negative_dividend">Reste avec numérateur négatif</h3> + +<pre class="brush: js"> +-12 % 5 // -2 +-1 % 2 // -1 +-4 % 2 // -0 +</pre> + +<h3 id="remainder_with_nan">Reste avec NaN</h3> + +<pre class="brush: js"> +NaN % 2 // NaN +</pre> + +<h3 id="remainder_with_infinity">Reste avec l'infini</h3> + +<pre class="brush: js"> +Infinity % 2 // NaN +Infinity % 0 // NaN +Infinity % Infinity // NaN +</pre> + +<h2 id="specifications">Spécifications</h2> + +<p>{{Specifications}}</p> + +<h2 id="browser_compatibility">Compatibilité des navigateurs</h2> + +<p>{{Compat}}</p> + +<h2 id="see_also">Voir aussi</h2> + +<ul> + <li><a href="/fr/docs/Web/JavaScript/Reference/Operators/Addition">Opérateur d'addition</a></li> + <li><a href="/fr/docs/Web/JavaScript/Reference/Operators/Subtraction">Opérateur de soustraction</a></li> + <li><a href="/fr/docs/Web/JavaScript/Reference/Operators/Multiplication">Opérateur de multiplication</a></li> + <li><a href="/fr/docs/Web/JavaScript/Reference/Operators/Division">Opérateur de division</a></li> + <li><a href="/fr/docs/Web/JavaScript/Reference/Operators/Exponentiation">Opérateur d'exponentiation</a></li> + <li><a href="/fr/docs/Web/JavaScript/Reference/Operators/Increment">Opérateur d'incrémentation</a></li> + <li><a href="/fr/docs/Web/JavaScript/Reference/Operators/Decrement">Opérateur de décrémentation</a></li> + <li><a href="/fr/docs/Web/JavaScript/Reference/Operators/Unary_negation">Opérateur de négation unaire</a></li> + <li><a href="/fr/docs/Web/JavaScript/Reference/Operators/Unary_plus">Opérateur plus unaire</a></li> +</ul> |
