更新时间:2023-02-19 22:27:30
Javascript数字实际上是双精度浮点数。可以精确存储的最大整数是2 53 ,远低于你的2 63 -1。
Javascript numbers are actually double precision floats. The largest integer that can be precisely stored is 253, much less then your 263-1.
alert( Math.pow(2, 53) - 1 ) // 9007199254740991
alert( Math.pow(2, 53) ) // 9007199254740992
alert( Math.pow(2, 53) + 1 ) // 9007199254740992