I did a code migration from javascript to java, but the results for the following operation are different:
in javascript:-1316818646 >>> 0
= 2978148650
but in java: -1316818646 >>> 0
= -1316818646
Could someone help me, please? I didn't find the answer elsewhere
CodePudding user response:
As @Pydawan said, 2978148650
is just the unsigned value of -1316818646
or 10110001100000101111000100101010
. To get that in Java, call
Integer.toUnsignedLong(-1316818646)
CodePudding user response:
In Java the operator returns you the same number as an int. In JavaScript the >>> operator always returns you an unsigned 32-bit integer.