Repository navigation
fix(HF-162): scale TEXT percentage formats before rounding - #1776
Tobiadefami wants to merge 2 commits into
Conversation
|
@Tobiadefami thanks for the pull request. No CLA step needed here — our records show you signed the Contributor License Agreement on 2026-07-31. That signature came from our previous signing form and has been carried over, so there is nothing for you to re-sign. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit eb63d50. Configure here.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
hyperformula-docs | 0a2fb42 | Commit Preview URL Branch Preview URL |
Sep 17 2026, 10:11 PM |
Performance comparison of head (0a2fb42) vs base (c920375) |
marcin-kordas-hoc
left a comment
There was a problem hiding this comment.
Recommendation: Request changes — hold for merge-order, not for correctness.
The percent-scaling fix itself is solid. I reproduced the reported defect on develop
(TEXT(0.0123,"0.00%") returned 0.01% instead of 1.23% — off by 100x) and confirmed it's
fixed at this PR's head (1.23%). The paired test suite (hyperformula-tests #58) passes 83/83,
and reverting the source change while keeping the tests fails 22 of them, so the suite genuinely
discriminates fixed from unfixed behavior. Measured via MS Graph against a live Excel Online
session (pl-PL locale): once the format masks are written in valid pl-PL syntax (comma as decimal
separator — a .-based mask errors under this locale regardless of percent, which is worth
knowing but is unrelated to this PR), Excel's output matches this fix's output across rounding,
sign handling, zero, and overflow.
The reason I can't approve as-is: this PR modifies numberFormat() and the number-format
tokenizer (matchNumberFormat()) in src/format/format.ts / parser.ts, and the already-approved
#1716 rewrites those same two functions on an incompatible architecture (a Config-driven,
section-based renderer vs. this PR's percent-scaling loop on the old signature). A test merge of
the two produces real conflicts in both source files and in the compatibility guide — not a
rebase-and-resolve, since the two designs overlap on the same functions. Since #1716 is approved
and further along, I'd suggest it lands first, and this PR's percent-scaling logic gets
re-implemented on top of its section-based formatter rather than carried over as-is. As part of
that: this PR's new doc paragraph says percentage formats like 0.00% are supported, directly
above the sentence #1716 rewrites to say the opposite — that sentence doesn't exist yet on this
branch, so the contradiction will need a manual edit at merge time either way.
|
@marcin-kordas-hoc Agreed. Let's wait for #1716 to land, then I'll port the percentage scaling to its section-based formatter, reconcile the compatibility guide, and rerun the paired test suite (hyperformula-tests #58) before requesting another review. I've updated this PR's description to reflect that merge order. Thanks for the thorough review. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1776 +/- ##
========================================
Coverage 97.32% 97.32%
========================================
Files 195 195
Lines 15739 15758 +19
Branches 3390 3468 +78
========================================
+ Hits 15318 15337 +19
+ Misses 421 413 -8
- Partials 0 8 +8
🚀 New features to boost your workflow:
|

Context
TEXT(0.0123,"0.00%")currently returns0.01%instead of Excel's1.23%because the built-in number formatter rounds before applying percentage scaling. This PR fixes the reported behavior in #1565.Changes
%in a numeric mask as an operator that multiplies the value by 100 before rounding. Quoted and escaped percent signs remain literal.#VALUE!if percentage scaling overflows, matching the observed Excel behavior.Merge order
Formatter PR #1716 rewrites the same parser and renderer on a section-based architecture. As Marcin recommended, #1716 should land first. I will then port this percentage behavior to its formatter, reconcile the compatibility guide, and rerun the paired tests before this PR merges. The current head still implements the fix on the pre-#1716 formatter.
How did you test your changes?
Types of changes
Related issues
Checklist
CHANGELOG.md.Note
Medium Risk
Changes default
TEXToutput for%formats (behavior fix aligned with Excel), which may affect spreadsheets that relied on the old scaling or manual*100workarounds.Overview
Fixes
TEXTpercentage number formats so they match Excel: each active%in the format string multiplies the numeric value by 100 before rounding, soTEXT(0.0123,"0.00%")returns1.23%instead of0.01%.The number-format parser now tokenizes
%, quoted literals, and escapes separately (quoted or escaped%stay literal and do not scale).numberFormatapplies scaling once per percent token, surfaces#VALUE!if scaling overflows, and appends%in the output. CHANGELOG and the Excel compatibility guide document the behavior and note that workarounds that manually multiply by 100 can be removed.Reviewed by Cursor Bugbot for commit 0a2fb42. Bugbot is set up for automated code reviews on this repo. Configure here.