Skip to content

Add tests for keep-trailing-zeros proposal#4608

Open
eemeli wants to merge 6 commits intotc39:mainfrom
eemeli:keep-trailing-zeros
Open

Add tests for keep-trailing-zeros proposal#4608
eemeli wants to merge 6 commits intotc39:mainfrom
eemeli:keep-trailing-zeros

Conversation

@eemeli
Copy link
Member

@eemeli eemeli commented Oct 29, 2025

Proposal repo: https://github.com/tc39/proposal-intl-keep-trailing-zeros

The currently proposed spec text won't satisfy all of these tests; I'll be filing a PR incorporating the required changes.

I've created a patched fork of the FormatJS Intl.NumberFormat polyfill to run these tests: https://github.com/eemeli/formatjs-for-keep-trailing-zeros

Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
eemeli added a commit to tc39/proposal-intl-keep-trailing-zeros that referenced this pull request Feb 18, 2026
@eemeli eemeli requested a review from gibson042 February 19, 2026 07:28
Copy link
Member

@gibson042 gibson042 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after filling in pending front matter.

assert.sameValue(nf.format('12.30e-1'), '1.230');
assert.sameValue(nf.format('12.30e-2'), '0.1230');
assert.sameValue(nf.format('12.30e-3'), '0.01230');
assert.sameValue(nf.format('1.2345e-1000'), '0.0000');
Copy link
Member

@gibson042 gibson042 Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tc39/proposal-intl-keep-trailing-zeros#15

Suggested change
assert.sameValue(nf.format('1.2345e-1000'), '0.0000');
assert.sameValue(nf.format('1.2345e-1000'), '0.00000000000000000000');

(1.2345e-1000 formats exactly as "0.0…0…12345", which maximumFractionDigits rounds to "0.0…0". In the absence of trailing zero preservation it would be further transformed to "0", but that no longer happens here.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants