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/left_shift | |
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/left_shift')
-rw-r--r-- | files/fr/web/javascript/reference/operators/left_shift/index.html | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/files/fr/web/javascript/reference/operators/left_shift/index.html b/files/fr/web/javascript/reference/operators/left_shift/index.html new file mode 100644 index 0000000000..325adc9947 --- /dev/null +++ b/files/fr/web/javascript/reference/operators/left_shift/index.html @@ -0,0 +1,62 @@ +--- +title: Décalage binaire à gauche (<<) +slug: Web/JavaScript/Reference/Operators/Left_shift +tags: + - Bitwise operator + - JavaScript + - Language feature + - Operator + - Reference +browser-compat: javascript.operators.left_shift +translation-of: Web/JavaScript/Reference/Operators/Left_shift +--- +<div>{{jsSidebar("Operators")}}</div> + +<p>L'opérateur de <strong>décalage binaire à gauche (<code><<</code>)</strong> décale la séquence de bits représentée par le premier opérande d'autant de bits vers la gauche que le nombre indiqué par le second opérande. Les bits en excès à gauche sont écartés et des bits à zéro sont introduits à droite.</p> + +<div>{{EmbedInteractiveExample("pages/js/expressions-left-shift.html")}}</div> + +<h2 id="syntax">Syntaxe</h2> + +<pre class="brush: js"> +<var>a</var> << <var>b</var> +</pre> + +<h2 id="description">Description</h2> + +<p>Cet opérateur décale les bits du premier opérande vers la gauche, d'autant que le nombre indiqué par le second opérande. Les bits qui dépassent à gauche sont abandonnés et des zéros sont introduits à droite.</p> + +<p>Ainsi, <code>9 << 2</code> donnera la valeur 36 (en base 10) :</p> + +<pre class="brush: js"> + 9 (base 10): 00000000000000000000000000001001 (base 2) + -------------------------------- + 9 << 2 (base 10): 00000000000000000000000000100100 (base 2) = 36 (base 10) +</pre> + +<p>Le décalage binaire de tout nombre <code>x</code> de <code>y</code> bits vers la gauche donnera comme résultat <code>x * 2 ** y</code>. Par exemple, <code>9 << 3</code> pourra être reformulé en <code>9 * (2 ** 3) = 9 * (8) = 72</code>.</p> + +<h2 id="examples">Exemples</h2> + +<h3 id="using_left_shift">Utiliser le décalage binaire à gauche</h3> + +<pre class="brush: js"> +9 << 3; // 72 + +// 9 * (2 ** 3) = 9 * (8) = 72 +</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/Guide/Expressions_and_Operators#bitwise">Les opérateurs binaires dans le guide JavaScript</a></li> + <li><a href="/fr/docs/Web/JavaScript/Reference/Operators/Left_shift_assignment">L'opérateur de décalage binaire à gauche et d'affectation</a></li> +</ul> |