Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trailing zeros should never be added #14

Open
michaelkeeling opened this issue Oct 17, 2018 · 0 comments
Open

Trailing zeros should never be added #14

michaelkeeling opened this issue Oct 17, 2018 · 0 comments

Comments

@michaelkeeling
Copy link

The addTrailingZeros method in abstract-number-format-input is redundant and overrides default and expected behaviors already provided by the formatter. If a user wanted trailing zeros, then they can set the minimumSignificantDigits option. Intl.NumberFormat will truncate zeros when the number of fractional digits is less than maximumFractionDigits and this component should honor that behavior.

var number = 123.456;

formatter = new Intl.NumberFormat("en-US", { style: 'decimal', minimumSignificantDigits: 20 });
console.log(formatter.format(number))

// "123.45600000000000000"

formatter = new Intl.NumberFormat("en-US", { style: 'decimal', maximumFractionDigits: 20 });
console.log(formatter.format(number))

// "123.456"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant