Skip to content

fix(formula): read complex numbers whose parts use a signed exponent - #8167

Merged
DR-Univer merged 1 commit into
dream-num:devfrom
kevin9327:fix/complex-exponent-sign
Nov 11, 2026
Merged

DR-Univer merged 1 commit into
dream-num:devfrom
kevin9327:fix/complex-exponent-sign

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

Complex finds the sign between the real and imaginary parts with the first + or - after index 0. A signed exponent also contains one, so a value like 1e-7-i splits at 1e, the real part is NaN, and the number is treated as invalid.

Complex.getComplex writes such values itself. ${1e-7} is 1e-7, so COMPLEX(0.0000001, -1) returns 1e-7-i, and IMREAL, IMAGINARY and the other IM* functions then reject that result. Excel reads these values (it returns 1E-07-i for the same COMPLEX call and IMREAL gives 0.0000001).

The sign search now skips a sign that follows e or E. Values with two separators, such as 1+2-3i, are still invalid.

How to test

packages/engine-formula/src/basics/__tests__/complex.spec.ts covers 1e-7-i, -1E+3-2e-3j, a round trip through createByComplexStr(1e-7, -1, 'i'), and the two-separator case. The first three fail before the change and pass after it. I ran the spec with vitest against complex.ts in a scratch project, not the full monorepo test suite.

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).

This PR was written with AI assistance; I reproduced the bug and checked the fix and tests myself.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T11:11:13.644584Z 9c464e7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.14%. Comparing base (f2c9b62) to head (8eb52fd).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #8167      +/-   ##
==========================================
- Coverage   83.14%   83.14%   -0.01%     
==========================================
  Files        3073     3073              
  Lines      202472   202469       -3     
  Branches    52719    52988     +269     
==========================================
- Hits       168352   168347       -5     
- Misses      34067    34069       +2     
  Partials       53       53              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DR-Univer
DR-Univer force-pushed the fix/complex-exponent-sign branch from 9c464e7 to 8eb52fd Compare November 11, 2026 14:22
@DR-Univer
DR-Univer merged commit 9897a43 into dream-num:dev Nov 11, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants