0
var a = 1<<31
var b = 0x80000000
console.log(a, b)
console.log(a.toString(16), b.toString(16))

output

-2147483648 2147483648
-80000000 80000000
  • How to write an unsigned version of toString(16) to get the expected result 80000000?

I suggest that bitwise the a variable still holds 10000000 00000000 00000000 00000000, but a and b are not equal. Although bitwise they are the same.

exebook
  • 32,014
  • 33
  • 141
  • 226

0 Answers0