Intl currency formatting and minimum significant digits

# Zach Lym (7 years ago)

I recently ran into a discrepancy between Chrome and Firefox's implementation of Intl's currency formatting mechanism and the official spec. I didn't want the output to have any significant digits so I used the following:

new Intl.NumberFormat('en-US', {maximumSignificantDigits: 0,

currency: 'USD', style: 'currency', currencyDisplay: "symbol"});

This works fine on Chrome and Firefox but the polyfill threw an error and the standard appears to require at least one significant digit.

I strongly believe the spec should be changed to remove the requirement that the output contain any significant digits.

Thank you, -Zach Lym

# Boris Zbarsky (7 years ago)

On 10/22/16 12:52 AM, Zach Lym wrote:

I recently ran into a discrepancy between Chrome and Firefox's implementation of Intl's currency formatting mechanism and the official spec. I didn't want the output to have any significant digits so I used the following:

new Intl.NumberFormat('en-US', {maximumSignificantDigits: 0,

currency: 'USD', style: 'currency', currencyDisplay: "symbol"});

This works fine on Chrome and Firefox

It does? When I do that in Firefox I get an exception:

RangeError: invalid digits value: 0

What would it even mean to have 0 significant digits? Mathematically that makes no sense; if you have a digit at all, it's presumably significant so the smallest number of significant digits that makes sense is 1. Which is what the spec and the polyfill and Firefox (and Safari; I just checked) do. Sounds like V8 just has a bug.

I filed bugs.chromium.org/p/v8/issues/detail?id=5554 on V8.