How is the Number of value 0x80000000 organised in JavaScript?

2

As far as I know, JavaScript's Number holds a max value of 2^53 - 1, which is far more than 0x80000000 in case of absolute value.

But here's the code:

let N = 2147483648
console.log(N >> 1)

prints:

-1073741824

What I expected is:

let N = 2147483648
// 1000 0000 0000 0000 0000 0000 0000 0000
N >>= 1
// 0100 0000 0000 0000 0000 0000 0000 0000

The only rule I know may cause this is the bit of sign is filled with 1, if so, how can it be filled with 1 since left / right shift should fill bits with 0. Is there any thing to do with the rule that builds the float?

javascript
asked on Stack Overflow Aug 5, 2020 by Ron Kahuu

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0