-
Notifications
You must be signed in to change notification settings - Fork 1
Description
This is a follow-up to the discussion under #8 (comment), as it's best tracked separately from the Stage 2.7 review.
The proposal as it currently stands does not only keep trailing zeros in the input value, but also (when formatting string inputs) keeps trailing zeros in the formatted output. Most of the time those are synonymous, but the latter occurs when a number is rounded so that it ends with trailing zeros:
const nf = new Intl.NumberFormat('en', { maximumFractionDigits: 1 });
nf.format('2.00') // now: '2', proposed: '2.0'
nf.format('2.03') // now: '2', proposed: '2.0'
nf.format('1.96') // now: '2', proposed: '2.0'
nf.format(2n) // now: '2', proposed: '2'
nf.format(2.03) // now: '2', proposed: '2'
nf.format(1.96) // now: '2', proposed: '2'This behaviour is probably the right thing, and is internally consistent, but it should be identified as a slightly greater change to existing behaviour than has been previously noted.
The difference in behaviour will occur when an input string value has more fraction digits or significant digits than specified for the output, and the result of rounding is a value with fewer digits than specified for the output. The default value for maximumFractionDigits is 3.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status