tc39 / proposal-intl-numberformat-v3

Additional features for Intl.NumberFormat to solve key pain points.
MIT License
53 stars 12 forks source link

Normative: Limit exponent of intl mathematical value #117

Closed romulocintra closed 1 year ago

romulocintra commented 1 year ago

Closes #98

Address 2022-05-19 discussion: https://github.com/tc39/ecma402/blob/master/meetings/notes-2022-05-19.md#limit-exponent-of-intl-mathematical-value-98

FrankYFTang commented 1 year ago

can you show me the impact of this PR by using some sample JS code of the before change and after change? or by some unit tests?

sffc commented 1 year ago

@FrankYFTang

The impact of this PR, if it lands, is as follows

new Intl.NumberFormat("en").format("1e99999999")
// Current proposal: "1,000,000,000,000,......" or similar
// This PR: "∞"

new Intl.NumberFormat("en").format("1000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000")
// Current proposal: "1,000,000,000,100,000,..." or similar
// This PR: "∞"

If this is hard to implement, I think we should close this PR to unblock Stage 4 and then re-evaluate as a normative change soon after Stage 4.

romulocintra commented 1 year ago

@FrankYFTang

The impact of this PR, if it lands, is as follows

new Intl.NumberFormat("en").format("1e99999999")
// Current proposal: "1,000,000,000,000,......" or similar
// This PR: "∞"

new Intl.NumberFormat("en").format("1000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000")
// Current proposal: "1,000,000,000,100,000,..." or similar
// This PR: "∞"

If this is hard to implement, I think we should close this PR to unblock Stage 4 and then re-evaluate as a normative change soon after Stage 4.

Currently if you use this example :

new Intl.NumberFormat("en-US").format("987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321")

Looks like there are some limitations at the level we propose in place, where for example Chrome returns '∞' but Safari and Firefox return "987,654,321,987,654,321,987,654,321,987,654,321....", so maybe a recommendation to respect a certain number of digits will be ok

sffc commented 1 year ago

It looks like the web reality in Chrome is to support approximately 300 digits. I start getting '∞' at 309 digits.

I think this is great actually. If web reality is that a major browser is already limiting the size, then making a change (either now or later) to express that in the spec will be much easier.

sffc commented 1 year ago

As discussed in TG1, please update this PR to set a minimum precision. I suggest writing the minimum in such a way that it reflects web reality.

sffc commented 1 year ago

@romulocintra Can you update this PR so that we can put up the proposal for Stage 4 this month? Thanks!

sffc commented 1 year ago

This PR is superseded by https://github.com/tc39/proposal-intl-numberformat-v3/pull/128