Skip to content

Unexpected output of Intl.NumberFormat#formatRange with percent style for same values #46028

Description

@mdashlw

Version

v19.3.0

Platform

Microsoft Windows NT 10.0.22621.0 x64

Subsystem

No response

What steps will reproduce the bug?

const percentFormatter = new Intl.NumberFormat("en-US", { style: "percent" });

console.log(percentFormatter.formatRange(0.5, 0.55));
console.log(percentFormatter.formatRange(0.5, 0.5));

How often does it reproduce? Is there a required condition?

all the time for all locales

What is the expected behavior?

50% – 55%
~50%

Similar to:

const numberFormatter = new Intl.NumberFormat("en-US");

console.log(numberFormatter.formatRange(50_000, 55_000)); // 50,000–55,000
console.log(numberFormatter.formatRange(50_000, 50_000)); // ~50,000

What do you see instead?

50% – 55%
~5,000%

Additional information

maximumFractionDigits behavior:

> percentFormatter = new Intl.NumberFormat("en-US", { style: 'percent' });
NumberFormat [Intl.NumberFormat] {}
> percentFormatter.formatRange(0.1234, 0.1234)
~1,200%

> percentFormatter = new Intl.NumberFormat("en-US", { style: 'percent', maximumFractionDigits:10 });
NumberFormat [Intl.NumberFormat] {}
> percentFormatter.formatRange(0.1234, 0.1234)
~1,234%

Metadata

Metadata

Assignees

No one assigned

    Labels

    i18n-apiIssues and PRs related to Node.js internationalization support.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions