For AI agents: the complete documentation index is available at /tc39-atlas/en/llms.txt, the full documentation bundle is available at /tc39-atlas/en/llms-full.txt, and this page is available as Markdown at /tc39-atlas/en/proposals/year/pending/proposal-intl-keep-trailing-zeros.md.
  • English
  • Keep trailing zeros in Intl.NumberFormat and Intl.PluralRules S3

    Proposal details
    Proposal overview

    This proposal addresses the loss of trailing zeros when numeric strings are formatted by Intl.NumberFormat or used in Intl.PluralRules.select, which currently discards them. It proposes to retain these trailing zeros in the internal mathematical value, so that formatting '1.0' yields '1.0' and plural selection treats it as 'other'.

    Note

    The README below comes from the upstream repository and may contain outdated stage or status metadata. Use the proposal details above as the current source of truth.

    Keep trailing zeros in Intl.NumberFormat and Intl.PluralRules

    Status

    Stage: 3

    Champion: Eemeli Aro

    Reviewers: Richard Gibson (#7) and Shane Carr (#8)

    Presentations:

    Polyfill: eemeli/formatjs-for-keep-trailing-zeros

    Motivation

    Trailing zeros are important when formatting numbers or selecting their plural categories, and should be retained when included in a numeric string input value.

    Use cases

    Currently, trailing zeros are discarded:

    const nf = new Intl.NumberFormat("en");
    nf.format("1.0") === "1";
    
    const pr = new Intl.PluralRules("en");
    pr.select("1.0") === "one";

    Instead, they should be retained:

    const nf = new Intl.NumberFormat("en");
    nf.format("1.0") === "1.0";
    
    const pr = new Intl.PluralRules("en");
    pr.select("1.0") === "other";

    Description

    Currently, Intl.NumberFormat and Intl.PluralRules accept numeric strings as input, converting such internally to an Intl Mathematical Value with arbitrary decimal precision.

    If accepted, this proposal would change the internals of these interfaces such that trailing zeros would be retained, and included in the formatted or selected value. The treatment of Number or BigInt values would not change, and options such as maximumFractionDigits would still work as before:

    const nf = new Intl.NumberFormat('en', { minimumFractionDigits: 1 });
    
    nf.format('1') === '1.0'
    nf.format('1.00') === '1.00'
    nf.format('1.0000') === '1.000'
      // maximumFractionDigits default is 3.

    Background

    The treatment of numeric string values was previously changed in 2023 as a part of the Intl.NumberFormat V3 proposal, before which they were parsed into lower-precision Number values.

    The Decimal proposal is looking to introduce a numeric type capable of representing values with up to 34 decimal places of precision, along with a separate representation of the value's precision via Decimal.Amount or some other representation. Currently, the effective limits for the precision of Intl.NumberFormat and Intl.PluralRules are around 300 decimal places for the integer part, and 100 places for the fraction part. The maximum limit for the fraction precision was increased in 2023 from 20 to 100 in ECMA-402 PR #786.

    A numerical string representation of a Number with trailing zeros is available as Number.prototype.toPrecision:

    (42).toPrecision(4) === "42.00"
    (4200).toPrecision(2) === "4.2e+3"