I believe the reason behind this is the different kinds of bits operating system. Bitwise operators work on 32 bit integers. Bitwise operations results differently based on the bits used in the operating system.
The difference in the result of bitwise operations in Javascript
-
13-10-2022 - |
문제
To test, I wrote a simple function:
function test() {
var val = -1878897367 & 0xfffffff0;
console.log(val);
val = -2146277048 & 0xfffffff0;
console.log(val);
}
The result of running on a desktop computer:
-1878897376
-2146277056
The result of running on phones (Phonegap on Android 4.2 or 2.3.4):
268586281
1206600
Why is this happening?
해결책
다른 팁
Surely that is a bug:
toInt32(-1878897367) & toInt32(0xfffffff0) =
-1878897367 & -16 =
10010000000000100100110100101001 & 11111111111111111111111111110000 =
10010000000000100100110100100000 =
-1878897376
제휴하지 않습니다 StackOverflow