我遇到了问题,我无法解释它.其实我很惊讶.当我尝试将数字9933272057275866增加1时,它会自动添加2 !!! 请参阅以下代码:
let test = 9933272057275866;
let test2 = test+1;
console.log('Before:', test);
console.log('After:', test2);
console.log('Sub:', test2-test);
Run Code Online (Sandbox Code Playgroud)
各自的输出:
Before: 9933272057275866
After: 9933272057275868
Sub: 2
Run Code Online (Sandbox Code Playgroud)
这怎么可能?
环境是Javascript.我在Hackerrank提交了一个挑战时发现了这个问题,然后我也尝试在我自己的node.js环境中做同样的事情.结果相同!
怎么了?