| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Unsigned_right_shift | [Back] [Original] |
Get to know MDN better
const a = 5; // 00000000000000000000000000000101
const b = 2; // 00000000000000000000000000000010
const c = -5; // 11111111111111111111111111111011
console.log(a >>> b); // 00000000000000000000000000000001
// : 1
console.log(c >>> b); // 00111111111111111111111111111110
// : 1073741822
x >>> y
2 10 9 -9 32 2
9 (10 ): 00000000000000000000000000001001 (2 )
-9 (10 ): 11111111111111111111111111110111 (2 )
2 10 -9 2 9 2 00000000000000000000000000001001 1
2 10 9 2 0 10 -9 2 1
10 9 -9 2
9 (10 ): 00000000000000000000000000001001 (2 )
--------------------------------
9 >> 2 (10 ): 00000000000000000000000000000010 (2 ) = 2 (10 )
9 >>> 2 (10 ): 00000000000000000000000000000010 (2 ) = 2 (10 )
2 01 2
-9 -9 >> 2 -3 -9 >>> 2 1073741821
-9 (10 ): 11111111111111111111111111110111 (2 )
--------------------------------
-9 >> 2 (10 ): 11111111111111111111111111111101 (2 ) = -3 (10 )
-9 >>> 2 (10 ): 00111111111111111111111111111101 (2 ) = 1073741821 (10 )
32 32 32
Before: 11100110111110100000000000000110000000000001 After: 10100000000000000110000000000001
32 32 0 31 100 >>> 32 100 >>> 0 (100) 32 32 0
9 >>> 2; // 2
-9 >>> 2; // 1073741821
9n >>> 2n; // TypeError: BigInts have no unsigned right shift, use >> instead
| ECMAScript 2027 LanguageSpecification # sec-unsigned-right-shift-operator |
| Web Proxy Viewer | New URL | Original Page |