This has nothing to do with the floating point type or overflows. It returns -9219 because the standard requires it, since all binary bitwise operations must be performed using signed 32-bit integers (ECMA-262 & sect; 11.10).
The product A: A @B, where @ is one of the bitwise operators in the above products, is estimated as follows:
- Let lref be the result of A.
- Let lval be GetValue (lref).
- Let rref be the result of B.
- Let rval be GetValue (rref).
- Let lnum be ToInt32 (lval).
- Let rnum be ToInt32 (rval).
- Return the result of applying the bitwise operator @ to lnum and rnum. The result is a 32-bit integer.
4294958077, converted to a 32-bit integer (using the algorithm in ECMA-262, section 9.5), is -9219, and 0 is still 0, so bitwise or will return -9219.
source share