From c1c59dd4e44cb35c195a1cd6a71851fcf8c9e1dd Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Tue, 7 Jul 2020 02:11:53 +0530 Subject: [PATCH 1/8] Normative: handle awkward rounding behavior Handle awkward rounding behavior when dealing with currencies and the value of "maximumFractionDigits" is less than 2. Fixes: https://github.com/tc39/ecma402/issues/239 --- spec/numberformat.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/numberformat.html b/spec/numberformat.html index 9d8effc2..9e87c4c2 100644 --- a/spec/numberformat.html +++ b/spec/numberformat.html @@ -30,7 +30,10 @@

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 _mnfdActualDefault_ be _mnfdDefault_. + 1. If Type(_mxfd_) is Number and _mxfd_ is not *NaN*, then + 1. Set _mnfdActualDefault_ to min( _mxfd_, _mnfdDefault_ ). + 1. Let _mnfd_ be ? DefaultNumberOption(_mnfd_, 0, 20, _mnfdActualDefault_). 1. Let _mxfdActualDefault_ be max( _mnfd_, _mxfdDefault_ ). 1. Let _mxfd_ be ? DefaultNumberOption(_mxfd_, _mnfd_, 20, _mxfdActualDefault_). 1. Set _intlObj_.[[MinimumFractionDigits]] to _mnfd_. From 9f0636be3a954ee9bde89ee64f62c32f00bcfcf3 Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Wed, 8 Jul 2020 01:38:52 +0530 Subject: [PATCH 2/8] fixup! Normative: handle awkward rounding behavior --- spec/numberformat.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/numberformat.html b/spec/numberformat.html index 9e87c4c2..da26493c 100644 --- a/spec/numberformat.html +++ b/spec/numberformat.html @@ -31,8 +31,10 @@

SetNumberFormatDigitOptions ( _intlObj_, _options_, _mnfdDefault_, _mxfdDefa 1. Else if _mnfd_ is not *undefined* or _mxfd_ is not *undefined*, then 1. Set _intlObj_.[[RoundingType]] to ~fractionDigits~. 1. Let _mnfdActualDefault_ be _mnfdDefault_. - 1. If Type(_mxfd_) is Number and _mxfd_ is not *NaN*, then - 1. Set _mnfdActualDefault_ to min( _mxfd_, _mnfdDefault_ ). + 1. If _mxfd_ is not *undefined*, then + 1. Let _mxfd_ be ? ToNumber(_mxfd_). + 1. If _mxfd_ is not *NaN*, then + 1. Set _mnfdActualDefault_ to min( max( _mxfd_, 0 ), _mnfdDefault_ ). 1. Let _mnfd_ be ? DefaultNumberOption(_mnfd_, 0, 20, _mnfdActualDefault_). 1. Let _mxfdActualDefault_ be max( _mnfd_, _mxfdDefault_ ). 1. Let _mxfd_ be ? DefaultNumberOption(_mxfd_, _mnfd_, 20, _mxfdActualDefault_). From 46f1e9cb52076693ca9fb4abb326af90c6e6076e Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Wed, 8 Jul 2020 02:05:48 +0530 Subject: [PATCH 3/8] fixup! Normative: handle awkward rounding behavior --- spec/numberformat.html | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/spec/numberformat.html b/spec/numberformat.html index da26493c..be395763 100644 --- a/spec/numberformat.html +++ b/spec/numberformat.html @@ -32,12 +32,18 @@

SetNumberFormatDigitOptions ( _intlObj_, _options_, _mnfdDefault_, _mxfdDefa 1. Set _intlObj_.[[RoundingType]] to ~fractionDigits~. 1. Let _mnfdActualDefault_ be _mnfdDefault_. 1. If _mxfd_ is not *undefined*, then - 1. Let _mxfd_ be ? ToNumber(_mxfd_). - 1. If _mxfd_ is not *NaN*, then - 1. Set _mnfdActualDefault_ to min( max( _mxfd_, 0 ), _mnfdDefault_ ). + 1. Set _mxfd_ to ? ToNumber(_mxfd_). + 1. If _mxfd_ is *NaN*, then + 1. Throw a *RangeError* exception. + 1. Set _mnfdActualDefault_ to min( max( _mxfd_, 0 ), _mnfdDefault_ ). 1. Let _mnfd_ be ? DefaultNumberOption(_mnfd_, 0, 20, _mnfdActualDefault_). 1. Let _mxfdActualDefault_ be max( _mnfd_, _mxfdDefault_ ). - 1. Let _mxfd_ be ? DefaultNumberOption(_mxfd_, _mnfd_, 20, _mxfdActualDefault_). + 1. If _mxfd_ is *undefined*, then + 1. Set _mxfd_ to _mxfdActualDefault_. + 1. Else, + 1. If _mxfd_ is less than _mnfd_ or greater than 20, then + 1. Throw a *RangeError* exception. + 1. Set _mxfd_ to floor( _mxfd_ ). 1. Set _intlObj_.[[MinimumFractionDigits]] to _mnfd_. 1. Set _intlObj_.[[MaximumFractionDigits]] to _mxfd_. 1. Else if _notation_ is *"compact"*, then From d69baa6023713e6bbb5ceb9a7c0de817bdff62ca Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Thu, 9 Jul 2020 18:44:13 +0530 Subject: [PATCH 4/8] fixup! Normative: handle awkward rounding behavior --- spec/numberformat.html | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/spec/numberformat.html b/spec/numberformat.html index be395763..2ba7a0d8 100644 --- a/spec/numberformat.html +++ b/spec/numberformat.html @@ -30,19 +30,18 @@

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 _mnfdActualDefault_ be _mnfdDefault_. - 1. If _mxfd_ is not *undefined*, then + 1. If _mxfd_ is *undefined*, then + 1. Let _mnfdActualDefault_ be _mnfdDefault_. + 1. Else, 1. Set _mxfd_ to ? ToNumber(_mxfd_). - 1. If _mxfd_ is *NaN*, then - 1. Throw a *RangeError* exception. + 1. If _mxfd_ is *NaN*, then throw a *RangeError* exception. 1. Set _mnfdActualDefault_ to min( max( _mxfd_, 0 ), _mnfdDefault_ ). 1. Let _mnfd_ be ? DefaultNumberOption(_mnfd_, 0, 20, _mnfdActualDefault_). 1. Let _mxfdActualDefault_ be max( _mnfd_, _mxfdDefault_ ). 1. If _mxfd_ is *undefined*, then 1. Set _mxfd_ to _mxfdActualDefault_. 1. Else, - 1. If _mxfd_ is less than _mnfd_ or greater than 20, then - 1. Throw a *RangeError* exception. + 1. If _mxfd_ is less than _mnfd_ or greater than 20, then throw a *RangeError* exception. 1. Set _mxfd_ to floor( _mxfd_ ). 1. Set _intlObj_.[[MinimumFractionDigits]] to _mnfd_. 1. Set _intlObj_.[[MaximumFractionDigits]] to _mxfd_. From d90f64e900fc0ef1bd59a259f22d913125b113ca Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Thu, 16 Jul 2020 11:40:59 +0530 Subject: [PATCH 5/8] fixup! Normative: handle awkward rounding behavior --- spec/numberformat.html | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/spec/numberformat.html b/spec/numberformat.html index 2ba7a0d8..f3855fe4 100644 --- a/spec/numberformat.html +++ b/spec/numberformat.html @@ -30,19 +30,10 @@

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. If _mxfd_ is *undefined*, then - 1. Let _mnfdActualDefault_ be _mnfdDefault_. - 1. Else, - 1. Set _mxfd_ to ? ToNumber(_mxfd_). - 1. If _mxfd_ is *NaN*, then throw a *RangeError* exception. - 1. Set _mnfdActualDefault_ to min( max( _mxfd_, 0 ), _mnfdDefault_ ). + 1. Let _mnfdActualDefault_ be ? min( _mnfdDefault_, DefaultNumberOption(_mxfd_, 0, 20, 20) ). 1. Let _mnfd_ be ? DefaultNumberOption(_mnfd_, 0, 20, _mnfdActualDefault_). 1. Let _mxfdActualDefault_ be max( _mnfd_, _mxfdDefault_ ). - 1. If _mxfd_ is *undefined*, then - 1. Set _mxfd_ to _mxfdActualDefault_. - 1. Else, - 1. If _mxfd_ is less than _mnfd_ or greater than 20, then throw a *RangeError* exception. - 1. Set _mxfd_ to floor( _mxfd_ ). + 1. Let _mxfd_ be ? DefaultNumberOption(_mxfd_, _mnfd_, 20, _mxfdActualDefault_). 1. Set _intlObj_.[[MinimumFractionDigits]] to _mnfd_. 1. Set _intlObj_.[[MaximumFractionDigits]] to _mxfd_. 1. Else if _notation_ is *"compact"*, then From c1612584f9d53f24160e42f7622b7f79a17ffc20 Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Wed, 29 Jul 2020 20:10:16 +0530 Subject: [PATCH 6/8] fixup! Normative: handle awkward rounding behavior --- spec/numberformat.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spec/numberformat.html b/spec/numberformat.html index f3855fe4..ac04fce7 100644 --- a/spec/numberformat.html +++ b/spec/numberformat.html @@ -30,10 +30,12 @@

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 _mnfdActualDefault_ be ? min( _mnfdDefault_, DefaultNumberOption(_mxfd_, 0, 20, 20) ). - 1. Let _mnfd_ be ? DefaultNumberOption(_mnfd_, 0, 20, _mnfdActualDefault_). - 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 From c721f3a9247e645159374e9819cae0babb649ff4 Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Fri, 31 Jul 2020 03:19:50 +0530 Subject: [PATCH 7/8] fixup! Normative: handle awkward rounding behavior --- spec/annexes.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/annexes.html b/spec/annexes.html index 01747aee..035ec583 100644 --- a/spec/annexes.html +++ b/spec/annexes.html @@ -170,5 +170,8 @@

Additions and Changes That Introduce Incompatibilities with Prior Editions In ECMA-402, 7th Edition, the @@toStringTag property of `Intl` was not defined. In 8th Edition, @@toStringTag is set to *"Intl"*. +
  • + In ECMA-402, 8th Edition, the NumberFormat constructor used to throw an error when 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. +
  • From 58aeac53801b5cfe6a65a6f735c0946acb5b09b8 Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Thu, 13 Aug 2020 22:37:24 +0530 Subject: [PATCH 8/8] fixup! Normative: handle awkward rounding behavior --- spec/annexes.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/annexes.html b/spec/annexes.html index 035ec583..b370ffa5 100644 --- a/spec/annexes.html +++ b/spec/annexes.html @@ -171,7 +171,7 @@

    Additions and Changes That Introduce Incompatibilities with Prior Editions In ECMA-402, 7th Edition, the @@toStringTag property of `Intl` was not defined. In 8th Edition, @@toStringTag is set to *"Intl"*.
  • - In ECMA-402, 8th Edition, the NumberFormat constructor used to throw an error when 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. + 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.