因为自己找这个问题很多遍了,来记录一下
Math.pow(2,53);
=>9007199254740992
Math.pow(2,53) + 1 === Math.pow(2, 53); //不准确了
=>true
Math.pow(2,53) - 1 === Math.pow(2, 53);
=>false
Number.MAX_SAFE_INTEGER
=>9007199254740991
日常会使用这个Number.MAX_SAFE_INTEGER
因为自己找这个问题很多遍了,来记录一下
Math.pow(2,53);
=>9007199254740992
Math.pow(2,53) + 1 === Math.pow(2, 53); //不准确了
=>true
Math.pow(2,53) - 1 === Math.pow(2, 53);
=>false
Number.MAX_SAFE_INTEGER
=>9007199254740991
日常会使用这个Number.MAX_SAFE_INTEGER