Skip to content
New issue

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

sum方法求和精度在某些情况下失真 #68

Open
zkzgs opened this issue Nov 13, 2024 · 1 comment
Open

sum方法求和精度在某些情况下失真 #68

zkzgs opened this issue Nov 13, 2024 · 1 comment
Labels
bug fix has been fix

Comments

@zkzgs
Copy link

zkzgs commented Nov 13, 2024

可复现的链接:

https://codesandbox.io/p/sandbox/5qhxzr?file=%2Fsrc%2Fviews%2FDemo1.vue%3A27%2C1

问题描述与截图:

得出结果精度不一致,与实际精度有偏差,放在数组前面和中间和放在最后计算出的结果也不相同
const a = [ 30, 3, 0.0175, 18, 0.0145, 0.38, 13, 15600, 0.7, 14, 1.57, 1, 30, 760, 0.15, 45, 1.6, 1, 1011.468, 13, 3, 1, 1.76, 0.018, 13, 15600, 3, 3, 80, 15600, 2.3, 14.6, 485, 0.2749008, 760, 2.3, 760, 13, 123, 109.073, 760, 0.68, 0.68, 1900, 14, 22.5, 1900, 1900, 15600, 2.05, 550, 1.23, 485, 13, 2.3, 0.2, 1900, 220, 760, 20, 13, 1900, 485, 2050, 30, 0.65, 1, 500, 1.68, 30, 0.015, 3, 14, 1, 3, 1.69, 13, 13, 1.68, 14.5, 1.75, 485, ]; const b = 0.26710027;
image

期望的结果:

计算结果与最高小数位保持一致

操作系统:

window 10

浏览器版本:

Chrome 130.0.6723.117

@zkzgs zkzgs added the bug label Nov 13, 2024
@xuliangzhan xuliangzhan added the fix has been fix label Nov 22, 2024
@xuliangzhan
Copy link
Collaborator

fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix has been fix
Projects
None yet
Development

No branches or pull requests

2 participants