We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NP.divide(33.3333, 100) = 0.33333300000000005
The text was updated successfully, but these errors were encountered:
@UnlimitedGalaxy @camsong Chrome 表现不太一致
console.log('divide', divide(33.3333, 100), 33.3333 / 100);
Chrome浏览器 异常
divide 0.33333300000000005 0.333333
Firefox、IE、Edge 正常
divide 0.333333 0.333333
node v10.16.3 正常
Sorry, something went wrong.
@camsong 问题的环节定位到了
原因是 Math.pow(10, 0 - 4) => 在 Chrome 上 0.00009999999999999999,在 FF、IE、Edge、node 上都是 0.0001
Math.pow(10, 0 - 4)
0.00009999999999999999
0.0001
在 divide 最后一步的计算就变成了 times(3333.33, 0.00009999999999999999)
divide
times(3333.33, 0.00009999999999999999)
接着 float2Fixed(num2) => 10000000000000000 这个数已经超过了 Number.MAX_SAFE_INTEGER
float2Fixed(num2)
10000000000000000
Number.MAX_SAFE_INTEGER
后面的计算就没有意义了, num1Changed * num2Changed => 会变得更大
num1Changed * num2Changed
6d29b95
No branches or pull requests
NP.divide(33.3333, 100) = 0.33333300000000005
The text was updated successfully, but these errors were encountered: