| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/zh-CN/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
// Expected output: 1
console.log(c >>> b); // 00111111111111111111111111111110
// Expected output: 1073741822
a >>> b
0 32
10 9 -9 32
9 (base 10): 00000000000000000000000000001001 (base 2)
-9 (base 10): 11111111111111111111111111110111 (base 2)
10 -9 10 9 00000000000000000000000000001001 1
9 0 -9 1
9 (base 10): 00000000000000000000000000001001 (base 2)
--------------------------------
9 >> 2 (base 10): 00000000000000000000000000000010 (base 2) = 2 (base 10)
9 >>> 2 (base 10): 00000000000000000000000000000010 (base 2) = 2 (base 10)
01
-9 -9 >> 2 -3 -9 >>> 2 1073741821
-9 (base 10): 11111111111111111111111111110111 (base 2)
--------------------------------
-9 >> 2 (base 10): 11111111111111111111111111111101 (base 2) = -3 (base 10)
-9 >>> 2 (base 10): 00111111111111111111111111111101 (base 2) = 1073741821 (base 10)
32 32 /
32 32 0 31 0 31100 >>> 32 100 >>> 0 100 32 32 0
9 >>> 2; // 2
-9 >>> 2; // 1073741821
| ECMAScript 2027 LanguageSpecification # sec-unsigned-right-shift-operator |
| Web Proxy Viewer | New URL | Original Page |