Skip to content

Trailing zeros should never be added #14

@michaelkeeling

Description

@michaelkeeling

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions