JavaScript Bitwise Masking

前端 未结 2 635
孤独总比滥情好
孤独总比滥情好 2021-01-19 06:07

This question is similar to this other question; however, I\'d like to understand why this is working as it is.

The following code:

console.log((pars         


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-19 06:40

    Because bitwise operations (like &) are done on signed 32-bit integers in javascript. 0xFFFFFFFF, where all bits are set, is actually -1, and the 0xde000000 you are expecting is actually -570425344.

提交回复
热议问题