2

Javascript:

var a=209348540618090 | 0;//-1050290838

PHP:

$a= 209348540618090|0;//209348540618090
$a=(209348540618090 & 0xffffffff) | 0;  //3244676458

Why is the result of the bitwise operation in PHP different to the bitwise operation in Javascript?

dev4life
  • 10,785
  • 6
  • 60
  • 73
  • Bitwise operators and shift operators operate on 32-bit ints (in javascript), see http://stackoverflow.com/questions/307179/what-is-javascripts-highest-integer-value-that-a-number-can-go-to-without-losin – bruchowski Mar 10 '16 at 03:15
  • @bruchowski the operation `& 0xffffffff` is meant to convert the number to 32-bit, even so the result is not the same. – dev4life Mar 10 '16 at 05:27

0 Answers0