Skip to content

Commit

Permalink
Normative: handle awkward rounding behavior (#471)
Browse files Browse the repository at this point in the history
Handle awkward rounding behavior when dealing with currencies and the
value of "maximumFractionDigits" is less than 2.

Fixes #239
  • Loading branch information
ryzokuken authored Jan 5, 2021
1 parent a57ae15 commit 15bfdbf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions spec/annexes.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,8 @@ <h1>Additions and Changes That Introduce Incompatibilities with Prior Editions</
<li>
<emu-xref href="#sec-Intl-toStringTag"></emu-xref> In ECMA-402, 7th Edition, the @@toStringTag property of `Intl` was not defined. In 8th Edition, @@toStringTag is set to *"Intl"*.
</li>
<li>
<emu-xref href="#sec-intl-numberformat-constructor"></emu-xref> In ECMA-402, 8th Edition, the NumberFormat constructor used to throw an error when style="currency" and maximumFractionDigits was set to a value lower than the default fractional digits for that currency. This behavior was corrected in the 9th edition, and it no longer throws an error.
</li>
</ul>
</emu-annex>
9 changes: 6 additions & 3 deletions spec/numberformat.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ <h1>SetNumberFormatDigitOptions ( _intlObj_, _options_, _mnfdDefault_, _mxfdDefa
1. Set _intlObj_.[[MaximumSignificantDigits]] to _mxsd_.
1. Else if _mnfd_ is not *undefined* or _mxfd_ is not *undefined*, then
1. Set _intlObj_.[[RoundingType]] to ~fractionDigits~.
1. Let _mnfd_ be ? DefaultNumberOption(_mnfd_, 0, 20, _mnfdDefault_).
1. Let _mxfdActualDefault_ be max( _mnfd_, _mxfdDefault_ ).
1. Let _mxfd_ be ? DefaultNumberOption(_mxfd_, _mnfd_, 20, _mxfdActualDefault_).
1. Let _specifiedMnfd_ be ? DefaultNumberOption(_mnfd_, 0, 20, *undefined*).
1. Let _specifiedMxfd_ be ? DefaultNumberOption(_mxfd_, 0, 20, *undefined*).
1. If _specifiedMxfd_ is not *undefined*, set _mnfdDefault_ to min(_mnfdDefault_, _specifiedMxfd_).
1. Set _mnfd_ to ! DefaultNumberOption(_specifiedMnfd_, 0, 20, _mnfdDefault_).
1. Set _mxfd_ to ! DefaultNumberOption(_specifiedMxfd_, 0, 20, max(_mxfdDefault_, _mnfd_)).
1. If _mnfd_ is greater than _mxfd_, throw a *RangeError* exception.
1. Set _intlObj_.[[MinimumFractionDigits]] to _mnfd_.
1. Set _intlObj_.[[MaximumFractionDigits]] to _mxfd_.
1. Else if _notation_ is *"compact"*, then
Expand Down

0 comments on commit 15bfdbf

Please sign in to comment.