Repository navigation
fix(xlsx): render large fixed decimals without binary artifacts - #24
Merged
pierreneter merged 1 commit intoNov 18, 2026
Merged
Conversation
pierreneter
reviewed
Nov 18, 2026
pierreneter
left a comment
Member
There was a problem hiding this comment.
Thanks, the core holds: fixedDecimal matches the old output at ordinary magnitudes (|v| < 1e8, up to 6 decimals, 4M differential checks), and the new tests pass.
A few things around it. Outputs below were run on this branch; line numbers are at 6e3735e.
src/react/xlsx/fit.ts:12:fitNumberre-parses the text withNumber(text).toFixed(keep), so the grid and print bring back what this PR removes as soon as the column is 1-3 characters too narrow.1e21with0.00is1000000000000000000000.00at full width and1e+21one notch narrower. For1e21 - 1e7the digits change while the column is resized:999999999999990000000.00, then999999999999990038528.0.- Speed on the hot path:
src/core/xlsx/numfmt.ts:211:formatValuewith format0on 2M values takes about 1.08 s here against 0.65 s before. The coefficient has at most 15 digits and is exact in a double, so BigInt is not needed; a Number-only variant gave the same output on 3M fuzzed inputs.numfmt.ts:199:group()is a backtracking lookahead and now gets integer strings of up to 309 digits.formatValue(1e308, '#,##0.00')went from about 0.5 µs to 75 µs per call. A slice-by-3 loop is linear.
src/core/xlsx/formula/format.ts:71:TEXT()still goes throughroundHalf(...).toFixed(decs), so the formula and the cell format now disagree for the same value:=TEXT(1E+22,"0.00")gives1e+22., a cell formatted0.00shows all the digits.
Non-blocking, but the description lists these as covered:
- Fractions:
formatValue(1e21, '# ?/?')is still1e+21(numfmt.ts:362). - Percent is scaled in binary before the conversion:
formatValue(1e307, '0%')givesInfinity%(numfmt.ts:223). Folding the scale into the exponent shift avoids it. - Scientific:
formatValue(5e-324, '0.00E+00')givesInfinity.E-323(numfmt.ts:251). fixedDecimalrepeats the digit / exponent split thatnumToTextalready has (src/core/xlsx/formula/values.ts:59-73). One shared helper would also close theTEXT()gap.
pierreneter
added a commit
that referenced
this pull request
Nov 18, 2026
…s; TEXT() shows large numbers as cells do After #25 (review of the QA pass): - a cell whose reference names another row than the one it is in, or a row number with leading zeros (A02), was dropped with its value: it is kept, in its row, at the column named. - a <col> running past the last column, a width over 255, a row height over 409.5 pt dropped the whole record (the column back to the default width, hidden or not): they are capped. - an anchor corner without <xdr:colOff> / <xdr:rowOff> discarded the picture: the offsets are 0. - the cells of a row are kept in column order, one per column (the last read wins), whatever order the file has them in: editing a row relies on it, and this engine wrote rows out of order before this version. Such a row is written in order when it is edited. After #24: TEXT() formatted with its own code, which still went through a double (TEXT(1E+21,"0.00") was 999999999999999868928.00, and TEXT(9.995E+20,"0%") was 9%). It uses the same digits as the cells. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed formats such as
0.00now display1e21as1000000000000000000000.00, without binary artifacts or unintended exponential notation. Rendering retains 15 significant decimal digits through rounding and expansion.Follows up on #16. Reference checks in Excel 16.115 confirmed that date-only formats carry across midnight after rounding to seconds in both date systems. That behavior is preserved, with regression coverage and a corrected explanatory comment.
Tests cover neighboring and negative large values, grouping/scaling, percentages, scientific/fraction formats, precision, and date boundaries. Existing serial-zero and negative-time behavior remains unchanged. Extreme finite values are unit-tested, but exact Excel parity at those magnitudes is not claimed.
Validation with Bun 1.4.4: frozen dependencies, all 544 unit tests, typecheck, full build, and diff whitespace checks passed. No browser suite was rerun for this pure number-format change.