Reputation: 103
This line of code:
console.log((90000000000000|0).toString());
output:
-1039687680 ( bin -111101111110000110000000000000 )
According to 32-bit signed integer conversion, I expect:
/--discarded--\/---------significant----------\
10100011101101011000010000001111010000000000000 = 90000000000000
│
11000010000001111010000000000000 OR
00000000000000000000000000000000
================================
11000010000001111010000000000000 = -1107795968
sign/\------significant bits-------/
Why I obtain -1039687680 instead of -1107795968?
Upvotes: 1
Views: 56
Reputation: 227
As mentioned in post you linked, it's in two's complement format.
negative 11000010000001111010000000000000 xor 1 plus 1 equals
positive 11110111111000011000000000000000, 1039687680
finally -1039687680 gained.
Upvotes: 1