I have noticed a weird behaviour using bitwise AND operator in JS:
console.log((0xd41ddb80 & 0xd41ddb80).toString(16))
The operands of all bitwise operators are converted to signed 32-bit integers in two's complement format.
When interpreted as a signed 32-bit integer, the value
0xd41ddb80 represents the number
-736240768. Using any bitwise operator on this number will coerce it into a signed 32-bit integer:
console.log(~~0xd41ddb80) console.log(0xd41ddb80 & 0xffffffff) console.log(0xd41ddb80 | 0)
The the base-16 equivalent of
-2be22480, and that is what you are seeing .
You can observe similar behavior for any number greater than or equal to