php bitwise XOR and js bitwise XOR producing different results

前端 未结 1 1521
醉酒成梦
醉酒成梦 2021-01-26 18:46

When I try to perform bitwise XOR operation in php and js, they are producing different results in some cases , for example

2166136261 ^ 101 = -2128831072 on bro         


        
相关标签:
1条回答
  • 2021-01-26 18:55

    2,147,483,647 is the biggest possible positive value for an integer in 32 bit computing, (it's 2^16, half of the 32 bits we have, the other half are reserved for negative numbers.)

    Once you use a number bigger than that in a 32 bit system you start getting screwy results as the computer thinks it's a negative number. see https://en.wikipedia.org/wiki/Integer_(computer_science)

    0 讨论(0)
提交回复
热议问题