Intl currency formatting and minimum significant digits

Boris Zbarsky bzbarsky at mit.edu
Sat Oct 22 18:47:41 UTC 2016


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 https://bugs.chromium.org/p/v8/issues/detail?id=5554 on V8.

-Boris


More information about the es-discuss mailing list