Bitshift in javascript

后端 未结 3 1768
眼角桃花
眼角桃花 2020-12-06 15:56

I\'ve got a really big number: 5799218898. And want to shift it right to 13 bits.
So, windows-calculator or python gives me:

5799218898 >> 13 | 10001010010000         


        
3条回答
  •  旧巷少年郎
    2020-12-06 16:40

    The number you have (5799218898) is beyond 32 bits. You didn't mention the JavaScript engine you're testing with, but it's very likely that it is 32-bit.

    To test, trim the "5" at the beginning of your number so that you fall inside the 32-bit boundary. Then your shift should work fine.

提交回复
热议问题