|
2 | 2 | title: Bitwise NOT (~)
|
3 | 3 | slug: Web/JavaScript/Reference/Operators/Bitwise_NOT
|
4 | 4 | tags:
|
5 |
| -- Bitwise operator |
6 |
| -- JavaScript |
7 |
| -- Language feature |
8 |
| -- Operator |
9 |
| -- Reference |
| 5 | + - Bitwise operator |
| 6 | + - JavaScript |
| 7 | + - Language feature |
| 8 | + - Operator |
| 9 | + - Reference |
10 | 10 | browser-compat: javascript.operators.bitwise_not
|
11 | 11 | ---
|
12 | 12 | <div>{{jsSidebar("Operators")}}</div>
|
|
17 | 17 |
|
18 | 18 | <h2 id="Syntax">Syntax</h2>
|
19 | 19 |
|
20 |
| -<pre class="brush: js"><code><var>~a</var></code> |
| 20 | +<pre class="brush: js">~a |
21 | 21 | </pre>
|
22 | 22 |
|
23 | 23 | <h2 id="Description">Description</h2>
|
24 | 24 |
|
25 |
| -<p>The operands are converted to 32-bit integers and expressed by a series of bits (zeroes |
| 25 | +<p>The operand is converted to a 32-bit integer and expressed as a series of bits (zeroes |
26 | 26 | and ones). Numbers with more than 32 bits get their most significant bits discarded. For
|
27 |
| - example, the following integer with more than 32 bits will be converted to a 32 bit |
| 27 | + example, the following integer, with more than 32 bits, will be converted to a 32 bit |
28 | 28 | integer:</p>
|
29 | 29 |
|
30 | 30 | <pre class="brush: js">Before: 11100110111110100000000000000110000000000001
|
31 | 31 | After: 10100000000000000110000000000001</pre>
|
32 | 32 |
|
33 |
| -<p>Each bit in the first operand is paired with the corresponding bit in the second |
34 |
| - operand: <em>first bit</em> to <em>first bit</em>, <em>second bit</em> to <em>second |
35 |
| - bit</em>, and so on.</p> |
36 |
| - |
37 |
| -<p>The operator is applied to each pair of bits, and the result is constructed bitwise. |
| 33 | +<p>Each bit in the operand is inverted in the result. |
38 | 34 | </p>
|
39 | 35 |
|
40 | 36 | <p>The truth table for the <code>NOT</code> operation is:</p>
|
@@ -89,6 +85,6 @@ <h2 id="Browser_compatibility">Browser compatibility</h2>
|
89 | 85 | <h2 id="See_also">See also</h2>
|
90 | 86 |
|
91 | 87 | <ul>
|
92 |
| - <li><a href="/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Bitwise">Bitwise |
| 88 | + <li><a href="/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#bitwise">Bitwise |
93 | 89 | operators in the JS guide</a></li>
|
94 | 90 | </ul>
|
0 commit comments