| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Bitwise_XOR | [Back] [Original] |
Get to know MDN better
const a = 5; // 00000000000000000000000000000101
const b = 3; // 00000000000000000000000000000011
console.log(a ^ b); // 00000000000000000000000000000110
// : 6
x ^ y
2 2 1 2
XOR
| x | y | x XOR y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
9 (10 ) = 00000000000000000000000000001001 (2 )
14 (10 ) = 00000000000000000000000000001110 (2 )
--------------------------------
14 ^ 9 (10 ) = 00000000000000000000000000000111 (2 ) = 7 (10 )
32 ( 1) 32 32 32
: 11100110111110100000000000000110000000000001 : 10100000000000000110000000000001
:
^ 0 x 0 XOR x 32 -2147483648 2147483647 Math.trunc()
0 1
// 9 (00000000000000000000000000001001)
// 14 (00000000000000000000000000001110)
14 ^ 9;
// 7 (00000000000000000000000000000111)
14n ^ 9n; // 7n
| ECMAScript 2027 LanguageSpecification # prod-BitwiseXORExpression |
| Web Proxy Viewer | New URL | Original Page |