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

fix(formula): js precision problem #2371

Merged
merged 6 commits into from
Jun 6, 2024
Merged

Conversation

Dushusir
Copy link
Member

@Dushusir Dushusir commented May 31, 2024

close #1712

  1. 移除 Big.js 的使用。由于 Excel 计算也遵循 IEEE 754 规范,计算过程无需处理精度
  2. Excel仅展示前15位数字,但是XML中存储了原始值,我们参照这个做法,仅在公式结果展示的时候处理 15位舍入

如何测试?

  1. js控制台测试会出问题的计算,比如 0.1+0.2,0.07/0.1
  2. 在单元格中输入公式计算:=0.1+0.2,=0.07/0.1

close #2344
safari下反复缩放 sheet,查看是否有内存持续增长问题。自测已经OK

Pull Request Checklist

  • Related tickets or issues have been linked in the PR description (or missing issue).
  • Naming convention is followed (do please check it especially when you created new plugins, commands and resources).
  • Unit tests have been added for the changes (if applicable).
  • Breaking changes have been documented (or no breaking changes introduced in this PR).

@Dushusir Dushusir changed the title Dushusir/fix formula bug 0530 fix(formula): js precision problem May 31, 2024
Copy link

github-actions bot commented May 31, 2024

View Deployment

📑 Examples 📚 Storybook
🔗 Preview link 🔗 Preview link

Copy link

codecov bot commented May 31, 2024

Codecov Report

Attention: Patch coverage is 78.57143% with 15 lines in your changes missing coverage. Please review.

Project coverage is 27.13%. Comparing base (2d036a3) to head (5bff2b0).

Files Patch % Lines
...-formula/src/services/calculate-formula.service.ts 0.00% 5 Missing ⚠️
...es/core/src/common/request-immediate-macro-task.ts 0.00% 3 Missing ⚠️
...rmula/src/controllers/formula-render.controller.ts 0.00% 3 Missing ⚠️
...ormula/src/engine/value-object/primitive-object.ts 86.66% 2 Missing ⚠️
...rc/controllers/array-formula-display.controller.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #2371   +/-   ##
=======================================
  Coverage   27.12%   27.13%           
=======================================
  Files        1646     1646           
  Lines       83040    83067   +27     
  Branches    17211    17211           
=======================================
+ Hits        22526    22541   +15     
- Misses      60514    60526   +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Dushusir Dushusir marked this pull request as ready for review May 31, 2024 12:16
@univer-bot univer-bot bot added the qa:untested This PR is ready to be tested label May 31, 2024
@univer-bot
Copy link

univer-bot bot commented May 31, 2024

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

Origin Title: fix(formula): js precision problem

Title: fix(formula): js precision problem


close #1712

  1. Remove the use of Big.js. Since Excel calculations also follow the IEEE 754 specification, the calculation process does not need to deal with precision
  2. Excel only displays the first 15 digits, but the original value is stored in XML. We follow this approach and only process 15-digit rounding when the formula result is displayed.

How to test?

  1. JS console test will cause problems with calculations, such as 0.1+0.2, 0.07/0.1
  2. Enter the formula in the cell to calculate: =0.1+0.2, =0.07/0.1

close #2344
Zoom the sheet repeatedly in Safari to see if there is any problem of continuous memory growth. Self-test is OK

Pull Request Checklist

  • Related tickets or issues have been linked in the PR description (or missing issue).
  • Naming convention is followed (do please check it especially when you created new plugins , commands and resources).
  • Unit tests have been added for the changes (if applicable).
  • Breaking changes have been documented (or no breaking changes introduced in this PR).

@zhaolixin7
Copy link

@Dushusir 1/3*3不等于1
2024_6_3 14_10_14 video.webm

@univer-bot
Copy link

univer-bot bot commented Jun 3, 2024

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

@Dushusir 1/3*3 is not equal to 1
2024_6_3 14_10_14 video.webm

@univer-bot univer-bot bot removed the qa:untested This PR is ready to be tested label Jun 4, 2024
@Dushusir Dushusir force-pushed the dushusir/fix-formula-bug-0530 branch from 729482d to d497149 Compare June 4, 2024 07:59
@Dushusir Dushusir added qa:untested This PR is ready to be tested and removed qa:rejected labels Jun 4, 2024
@zhaolixin7 zhaolixin7 added the qa:verified This PR has already by verified by a QA and is considered good enough to be merge label Jun 5, 2024
@univer-bot univer-bot bot removed the qa:untested This PR is ready to be tested label Jun 5, 2024
@Dushusir Dushusir force-pushed the dushusir/fix-formula-bug-0530 branch from 9622f67 to 455d34f Compare June 6, 2024 02:51
@Dushusir Dushusir merged commit d2c9eeb into dev Jun 6, 2024
9 checks passed
@Dushusir Dushusir deleted the dushusir/fix-formula-bug-0530 branch June 6, 2024 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
qa:verified This PR has already by verified by a QA and is considered good enough to be merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] sheet page have out of memory issue [Bug] Formula calculation accuracy problem =1/3*3
3 participants