| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/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); // 11111111111111111111111111111110
// : -2
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 >> 2 2
9 (10 ): 00000000000000000000000000001001 (2 )
--------------------------------
9 >> 2 (10 ): 00000000000000000000000000000010 (2 ) = 2 (10 )
2 01 0 2
-9 >> 2 -3
-9 (10 ): 11111111111111111111111111110111 (2 )
--------------------------------
-9 >> 2 (10 ): 11111111111111111111111111111101 (2 ) = -3 (10 )
2 11 1 1 2
2 1111111111111111111111111111101 10 -3 2 10 3 2 00000000000000000000000000000011 1
32 32 32
Before: 11100110111110100000000000000110000000000001 After: 10100000000000000110000000000001
32 32 0 31 100 >> 32 100 >> 0 (100) 32 32 0
:
>> 0 x 0 x 32 -2147483648 2147483647 Math.trunc()
0 1
9 >> 2; // 2
-9 >> 2; // -3
9n >> 2n; // 2n
| ECMAScript 2027 LanguageSpecification # sec-signed-right-shift-operator |
| Web Proxy Viewer | New URL | Original Page |