You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Normative: Updated the following Intl.PluralRules AOs to take Intl (#1026)
mathematical values rather than Numbers:
* `ResolvePlural`
* `ResolvePluralRange`
This brings `Intl.PluralRules`'s behaviour into alignment with
`Intl.NumberFormat`'s. Making this change has the following benefits:
* Allows `Intl.PluralRules` to handle BigInts as well as numbers
* Use of `ToIntlMathematicalValue` AO allows exact decimal values to be
represented
1. If _start_ is *undefined* or _end_ is *undefined*, throw a *TypeError* exception.
236
-
1. Let _x_ be ? ToNumber(_start_).
237
-
1. Let _y_ be ? ToNumber(_end_).
236
+
1. Let _x_ be ? ToIntlMathematicalValue(_start_).
237
+
1. Let _y_ be ? ToIntlMathematicalValue(_end_).
238
238
1. Return ? ResolvePluralRange(_pr_, _x_, _y_).
239
239
</emu-alg>
240
240
</emu-clause>
@@ -295,18 +295,24 @@ <h1>
295
295
<h1>
296
296
ResolvePlural (
297
297
_pluralRules_: an Intl.PluralRules,
298
-
_n_: a Number,
298
+
_n_: an Intl mathematical value,
299
299
): a Record with fields [[PluralCategory]] (*"zero"*, *"one"*, *"two"*, *"few"*, *"many"*, or *"other"*) and [[FormattedString]] (a String)
300
300
</h1>
301
301
<dlclass="header">
302
302
<dt>description</dt>
303
303
<dd>The returned Record contains two string-valued fields describing _n_ according to the effective locale and the options of _pluralRules_: [[PluralCategory]] characterizing its <emu-xrefhref="#sec-pluralruleselect">plural category</emu-xref>, and [[FormattedString]] containing its formatted representation.</dd>
304
304
</dl>
305
305
<emu-alg>
306
-
1. If _n_ is not a finite Number, then
307
-
1. Let _s_ be ! ToString(_n_).
306
+
1. If _n_ is ~not-a-number~, then
307
+
1. Let _s_ be an ILD String value indicating the *NaN* value.
308
308
1. Return the Record { [[PluralCategory]]: *"other"*, [[FormattedString]]: _s_ }.
309
-
1. Let _res_ be FormatNumericToString(_pluralRules_, ℝ(_n_)).
309
+
1. If _n_ is ~positive-infinity~, then
310
+
1. Let _s_ be an ILD String value indicating positive infinity.
311
+
1. Return the Record { [[PluralCategory]]: *"other"*, [[FormattedString]]: _s_ }.
312
+
1. If _n_ is ~negative-infinity~, then
313
+
1. Let _s_ be an ILD String value indicating negative infinity.
314
+
1. Return the Record { [[PluralCategory]]: *"other"*, [[FormattedString]]: _s_ }.
315
+
1. Let _res_ be FormatNumericToString(_pluralRules_, _n_).
310
316
1. Let _s_ be _res_.[[FormattedString]].
311
317
1. Let _locale_ be _pluralRules_.[[Locale]].
312
318
1. Let _type_ be _pluralRules_.[[Type]].
@@ -338,16 +344,16 @@ <h1>
338
344
<h1>
339
345
ResolvePluralRange (
340
346
_pluralRules_: an Intl.PluralRules,
341
-
_x_: a Number,
342
-
_y_: a Number,
347
+
_x_: an Intl mathematical value,
348
+
_y_: an Intl mathematical value,
343
349
): either a normal completion containing either *"zero"*, *"one"*, *"two"*, *"few"*, *"many"*, or *"other"*, or a throw completion
344
350
</h1>
345
351
<dlclass="header">
346
352
<dt>description</dt>
347
353
<dd>The returned String value represents the plural form of the range starting from _x_ and ending at _y_ according to the effective locale and the options of _pluralRules_.</dd>
348
354
</dl>
349
355
<emu-alg>
350
-
1. If _x_ is *NaN* or _y_ is *NaN*, throw a *RangeError* exception.
356
+
1. If _x_ is ~not-a-number~ or _y_ is ~not-a-number~, throw a *RangeError* exception.
351
357
1. Let _xp_ be ResolvePlural(_pluralRules_, _x_).
352
358
1. Let _yp_ be ResolvePlural(_pluralRules_, _y_).
353
359
1. If _xp_.[[FormattedString]] is _yp_.[[FormattedString]], then
0 commit comments