Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

[BUG]JS浮点数运算结果不精确,导致公式计算结果错误 #49

Closed
danielcai1987 opened this issue Sep 23, 2020 · 1 comment

Comments

@danielcai1987
Copy link
Contributor

描述错误
JS浮点数运算结果不精确,导致公式计算结果错误

重现
重现错误的步骤:

  1. https://mengshukeji.github.io/LuckysheetDemo/ 输入数据
A1: 0.3
B1: 0.3
C1: 0.3
D1: 0.1
A2: =1-SUM(A1:D1)
  1. 期待结果 A2 = 0
  2. 实际计算结果 A2 = 1.11022e-16

期望的结果
解决JS浮点数运算结果不精确的Bug
参考1:https://juejin.im/post/6844903903071322119
参考2: camsong/blog#9

屏幕截图或演示
image

环境:
-操作系统:[Windows]
-浏览器 版本号:[例如 Chrome Version 85.0.4183.83 (Official Build) (64-bit)]
-Luckysheet版本:[最新]

@DR-Univer
Copy link
Collaborator

使用numral解决了

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants