| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Bitwise_NOT | [Back] [Original] |
Get to know MDN better
const a = 5; // 00000000000000000000000000000101
const b = -3; // 11111111111111111111111111111101
console.log(~a); // 11111111111111111111111111111010
// : -6
console.log(~b); // 00000000000000000000000000000010
// : 2
~x
~ 2 32 NOT 32 NOT
NOT
| x | NOT x |
|---|---|
| 0 | 1 |
| 1 | 0 |
9 (10 ) = 00000000000000000000000000001001 (2 )
--------------------------------
~9 (10 ) = 11111111111111111111111111110110 (2 ) = -10 (10 )
x -(x + 1) ~-5 4
32 32 32
Before: 11100110111110100000000000000110000000000001 After: 10100000000000000110000000000001
:
~~ x NOT 2 x 32 -2147483648 2147483647 Math.trunc()
0 1
~0; // -1
~-1; // 0
~1; // -2
~0n; // -1n
~4294967295n; // -4294967296n
| ECMAScript 2027 LanguageSpecification # sec-bitwise-not-operator |
| Web Proxy Viewer | New URL | Original Page |