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

Intl.NumberFormat: maximumFractionDigits is used for exact number of digits instead of maximum for style: "currency" #57137

Open
amitbeck opened this issue Feb 19, 2025 · 1 comment
Labels
i18n-api Issues and PRs related to the i18n implementation.

Comments

@amitbeck
Copy link

amitbeck commented Feb 19, 2025

Version

v22.14.0

Platform

Darwin MacBook-Pro 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6020 arm64

Subsystem

No response

What steps will reproduce the bug?

Run the following:

Intl.NumberFormat('en-US', {
  notation: 'compact',
  maximumFractionDigits: 1,
  style: 'currency',
  currency: 'USD'
}).format(3_000_000)

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

Constantly

What is the expected behavior? Why is that the expected behavior?

The previous code snippet should output "$3M", because the number is round, notation is set to "compact" and maximumFractionDigits is set to 1. For comparison Chrome 133.0.6943.98 (V8 13.3.415.21) correctly outputs "$3M".

What do you see instead?

The previous code outputs "$3.0M" in Node.js v22.14.0 (V8 12.4.254.21-node.22), while Chrome 133.0.6943.98 (V8 13.3.415.21) outputs "$3M".

It seems that when using style: "currency" and specifying maximumFractionDigits, for some reason Node.js uses that number as the exact number of fraction digits instead of a maximum.

Additional information

No response

@targos
Copy link
Member

targos commented Feb 20, 2025

This will be fixed in the next V8 update (#57114), but only in v24.

@targos targos added the i18n-api Issues and PRs related to the i18n implementation. label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i18n-api Issues and PRs related to the i18n implementation.
Projects
None yet
Development

No branches or pull requests

2 participants