Intl Number Format V3
for Stage 4
Shane Carr
January 2023 TC39
What is this?
Dozens of feature requests get filed against ECMA-402 every year.
How do we decide which ones to prioritize?
Decision Process Examples
Feature | Stakeholders | CLDR Support | Verdict |
Partial | No | ||
Google, CaixaBank, Community | Yes | Yes |
Proposal Changes
green text = changed since previous Stage 3 update in November 2022
Intl.NumberFormat formatRange: Overview
Main issue: #393
Use cases:
Rounding Priority (Details: #8)
Problem: what happens when you specify
{ maximumFractionDigits: 2, maximumSignificantDigits: 2 }
You specified two conflicting strategies [example: 4.321]:
New setting roundingPriority resolves this conflict:
Interpret Strings as Decimals
Main issue: #334
We already accept strings, but they get parsed as a Number, losing precision. This part of the proposal will interpret the decimal string at full precision.
How it works: a new type called Intl mathematical value: "a mathematical value together with +∞, -∞, NaN, and -0" [#82]. The range of an Intl mathematical value is equal to the range of a Number, but greater precision is allowed. [#128]
const nf = new Intl.NumberFormat("en-US");
const string = "987654321987654321";
nf.format(string);
// Current: "987,654,321,987,654,300"
// Proposed: "987,654,321,987,654,321"
Rounding Modes
Main issue: #419
We will adopt the following 9 rounding modes.
This set encompasses ICU, CSS, and ECMA-262 Math.
Sign Display Negative
Main Issue: #17
We will add a new option signDisplay: "negative". The new option will behave like "auto" except that the sign will not be shown on negative zero.
var nf = new Intl.NumberFormat("en", {� signDisplay: "negative"�});�nf.format(-1.0); // -1�nf.format(-0.0); // 0 (note: "auto" produces "-0" here)�nf.format(0.0); // 0�nf.format(1.0); // 1 (note: "exceptZero" produces "+1" here)
Stage 4
Stage 4?
Entrance Criteria: