Skip to content

serializeEpsil takes a numberFormat option to choose the printed digit grouping - #654

Closed
enumeratio wants to merge 1 commit into
cortex-js:mainfrom
enumeratio:epsil-number-format
Closed

enumeratio wants to merge 1 commit into
cortex-js:mainfrom
enumeratio:epsil-number-format

Conversation

@enumeratio

Copy link
Copy Markdown
Contributor

serializeEpsil printed every number through a fixed format, so 3811 was always 3_811. options.numberFormat (EpsilNumberFormat: digitGroup, digitGroupSeparator, notation, avoidExponentsInRange) is now merged over that format once per call and used at every number call site. { digitGroup: 0 } or { digitGroupSeparator: '' } prints 3811.

The default is unchanged. The fields that are Epsil syntax (decimal separator, exponent markers, the spellings of Infinity, NaN and i) are left out of the type, and a separator other than '' or _ throws a RangeError, so the output always reads back as the same number.

Tests: test/compute-engine/epsil-number-format.test.ts covers the default, ungrouped integer, negative, decimal, big integer and rational, that the output re-parses to the same expression, and the rejected separator. The existing Epsil serialize, parse and round-trip tests pass unchanged.

Closes #653

@arnog arnog closed this Nov 22, 2026
arnog added a commit that referenced this pull request Nov 22, 2026
…, PR #654 by enumeratio)

options.numberFormat (EpsilNumberFormat: digitGroup, digitGroupSeparator)
is merged over the fixed format once per call and used at every number
call site. A separator other than "" or "_" throws a RangeError, so the
output reads back as the same number.

Changed from the PR: EpsilNumberFormat leaves out notation and
avoidExponentsInRange. A scientific notation writes the integer 3811 as
3.811e3, which reads back as a float, and the engineering notation of
serializeNumber writes 0.000012 as 120.0e-3, which reads back as 0.12.
The serializeEpsil doc comment is moved onto the function (it sat above
SUPERSCRIPT_OF), and the Epsil implementation guide describes the option.

Co-authored-by: enumeratio <314378874+enumeratio@users.noreply.github.com>
arnog added a commit that referenced this pull request Nov 22, 2026
…eAll with a symbol rule and a pattern rule (CE-1691)

Both found while landing GitHub PRs #654 and #637.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

serializeEpsil cannot print numbers without digit grouping

2 participants