-
Notifications
You must be signed in to change notification settings - Fork 115
Description
The spec reads:
Let cDigits be CurrencyDigits(currency).
...
Let mnfdDefault be cDigits.
Let mxfdDefault be cDigits.
...
Perform ? SetNumberFormatDigitOptions(numberFormat, options, mnfdDefault, mxfdDefault).
Let mnfd be ? GetNumberOption(options, "minimumFractionDigits", 0, 20, mnfdDefault).
Let mxfdActualDefault be max( mnfd, mxfdDefault ).
Let mxfd be ? GetNumberOption(options, "maximumFractionDigits", mnfd, 20, mxfdActualDefault).
Fine. So say I use a currency that sets mnfdDefault=2 and mxfdDefault=2. However, I want to override the rounding so that I get integer rounding (no fraction digits). I try to set options.maximumFractionDigits to 0.
new Intl.NumberFormat("en", { style: "currency", currency: "EUR", maximumFractionDigits: 0 });RangeError!
VM61:1 Uncaught RangeError: maximumFractionDigits value is out of range.
at new NumberFormat (native)
at :1:1
Although consistent with the spec, this is bad behavior for a number of reasons:
- Currency default fraction digits could change over time (unlikely but possible), meaning different versions of CLDR could trigger the exception but not others.
- It is just bad behavior from a user's perspective.
I would like to fix up the spec so that RangeError is thrown only when the user's minimumFractionDigits and maximumFractionDigits are in conflict with each other, not when they are in conflict with some random CLDR currency rounding data.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status