Skip to content

Commit e3f7260

Browse files
authored
Editorial: Clean up NumberFormat (#983)
2 parents 6827e6e + bd96e2d commit e3f7260

File tree

2 files changed

+19
-30
lines changed

2 files changed

+19
-30
lines changed

spec/numberformat.html

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ <h1>
8383
</emu-normative-optional>
8484
</emu-clause>
8585

86-
<emu-clause id="sec-setnfdigitoptions" type="abstract operation">
86+
<emu-clause id="sec-setnumberformatdigitoptions" oldids="sec-setnfdigitoptions" type="abstract operation">
8787
<h1>
8888
SetNumberFormatDigitOptions (
8989
_intlObj_: an Object,
@@ -95,7 +95,7 @@ <h1>
9595
</h1>
9696
<dl class="header">
9797
<dt>description</dt>
98-
<dd>It populates the internal slots of _intlObj_ that affect locale-independent number rounding (see <emu-xref href="#sec-formatnumberstring"></emu-xref>).</dd>
98+
<dd>It populates the internal slots of _intlObj_ that affect locale-independent number rounding (see <emu-xref href="#sec-formatnumerictostring"></emu-xref>).</dd>
9999
</dl>
100100
<emu-alg>
101101
1. Let _mnid_ be ? GetNumberOption(_options_, *"minimumIntegerDigits,"*, 1, 21, 1).
@@ -527,7 +527,7 @@ <h1>Properties of Intl.NumberFormat Instances</h1>
527527
In scientific notation, this slot affects the sign display of the mantissa but not the exponent.
528528
</li>
529529
<li>[[RoundingIncrement]] is an integer that evenly divides 10, 100, 1000, or 10000 into tenths, fifths, quarters, or halves. It indicates the increment at which rounding should take place relative to the calculated rounding magnitude. For example, if [[MaximumFractionDigits]] is 2 and [[RoundingIncrement]] is 5, then formatted numbers are rounded to the nearest 0.05 ("nickel rounding").</li>
530-
<li>[[RoundingMode]] is one of the String values in the Identifier column of <emu-xref href="#table-intl-rounding-modes"></emu-xref>, specifying which rounding mode to use.</li>
530+
<li>[[RoundingMode]] is a <dfn id="rounding-mode">rounding mode</dfn>, one of the String values in the Identifier column of <emu-xref href="#table-intl-rounding-modes"></emu-xref>.</li>
531531
<li>[[TrailingZeroDisplay]] is one of the String values *"auto"* or *"stripIfInteger"*, indicating whether to strip trailing zeros if the formatted number is an integer (i.e., has no non-zero fraction digit).</li>
532532
</ul>
533533

@@ -673,7 +673,7 @@ <h1>Number Format Functions</h1>
673673
<p>The *"length"* property of a Number format function is *1*<sub>𝔽</sub>.</p>
674674
</emu-clause>
675675

676-
<emu-clause id="sec-formatnumberstring" type="abstract operation">
676+
<emu-clause id="sec-formatnumerictostring" oldids="sec-formatnumberstring" type="abstract operation">
677677
<h1>
678678
FormatNumericToString (
679679
_intlObject_: an Object,
@@ -702,17 +702,13 @@ <h1>
702702
1. Else,
703703
1. Let _sResult_ be ToRawPrecision(_x_, _intlObject_.[[MinimumSignificantDigits]], _intlObject_.[[MaximumSignificantDigits]], _unsignedRoundingMode_).
704704
1. Let _fResult_ be ToRawFixed(_x_, _intlObject_.[[MinimumFractionDigits]], _intlObject_.[[MaximumFractionDigits]], _intlObject_.[[RoundingIncrement]], _unsignedRoundingMode_).
705-
1. If _intlObject_.[[RoundingType]] is ~more-precision~, then
706-
1. If _sResult_.[[RoundingMagnitude]] _fResult_.[[RoundingMagnitude]], then
707-
1. Let _result_ be _sResult_.
708-
1. Else,
709-
1. Let _result_ be _fResult_.
705+
1. If _fResult_.[[RoundingMagnitude]] &lt; _sResult_.[[RoundingMagnitude]], let _fixedIsMorePrecise_ be *true*; else let _fixedIsMorePrecise_ be *false*.
706+
1. If _intlObject_.[[RoundingType]] is ~more-precision~ and _fixedIsMorePrecise_ is *true*, then
707+
1. Let _result_ be _fResult_.
708+
1. Else if _intlObject_.[[RoundingType]] is ~less-precision~ and _fixedIsMorePrecise_ is *false*, then
709+
1. Let _result_ be _fResult_.
710710
1. Else,
711-
1. Assert: _intlObject_.[[RoundingType]] is ~less-precision~.
712-
1. If _sResult_.[[RoundingMagnitude]] ≤ _fResult_.[[RoundingMagnitude]], then
713-
1. Let _result_ be _fResult_.
714-
1. Else,
715-
1. Let _result_ be _sResult_.
711+
1. Let _result_ be _sResult_.
716712
1. Set _x_ to _result_.[[RoundedNumber]].
717713
1. Let _string_ be _result_.[[FormattedString]].
718714
1. If _intlObject_.[[TrailingZeroDisplay]] is *"stripIfInteger"* and <emu-eqn>_x_ modulo 1 = 0</emu-eqn>, then
@@ -1272,7 +1268,7 @@ <h1>
12721268
<emu-clause id="sec-torawprecision" type="abstract operation">
12731269
<h1>
12741270
ToRawPrecision (
1275-
_x_: non-negative mathematical value,
1271+
_x_: a non-negative mathematical value,
12761272
_minPrecision_: an integer in the inclusive interval from 1 to 21,
12771273
_maxPrecision_: an integer in the inclusive interval from 1 to 21,
12781274
_unsignedRoundingMode_: a specification type from the Unsigned Rounding Mode column of <emu-xref href="#table-intl-unsigned-rounding-modes"></emu-xref>, or *undefined*,
@@ -1297,15 +1293,13 @@ <h1>
12971293
1. Else,
12981294
1. [declared="n1,e1,r1"] Let _n1_ and _e1_ each be an integer and _r1_ a mathematical value, with <emu-eqn>_r1_ = ToRawPrecisionFn(_n1_, _e1_, _p_)</emu-eqn>, such that <emu-eqn>_r1__x_</emu-eqn> and _r1_ is maximized.
12991295
1. [declared="n2,e2,r2"] Let _n2_ and _e2_ each be an integer and _r2_ a mathematical value, with <emu-eqn>_r2_ = ToRawPrecisionFn(_n2_, _e2_, _p_)</emu-eqn>, such that <emu-eqn>_r2__x_</emu-eqn> and _r2_ is minimized.
1300-
1. Let _r_ be ApplyUnsignedRoundingMode(_x_, _r1_, _r2_, _unsignedRoundingMode_).
1301-
1. If _r_ is _r1_, then
1296+
1. Let _xFinal_ be ApplyUnsignedRoundingMode(_x_, _r1_, _r2_, _unsignedRoundingMode_).
1297+
1. If _xFinal_ is _r1_, then
13021298
1. Let _n_ be _n1_.
13031299
1. Let _e_ be _e1_.
1304-
1. Let _xFinal_ be _r1_.
13051300
1. Else,
13061301
1. Let _n_ be _n2_.
13071302
1. Let _e_ be _e2_.
1308-
1. Let _xFinal_ be _r2_.
13091303
1. Let _m_ be the String consisting of the digits of the decimal representation of _n_ (in order, with no leading zeroes).
13101304
1. If _e_ ≥ (_p_ - 1), then
13111305
1. Set _m_ to the string-concatenation of _m_ and _e_ - _p_ + 1 occurrences of the code unit 0x0030 (DIGIT ZERO).
@@ -1331,7 +1325,7 @@ <h1>
13311325
<emu-clause id="sec-torawfixed" type="abstract operation">
13321326
<h1>
13331327
ToRawFixed (
1334-
_x_: non-negative mathematical value,
1328+
_x_: a non-negative mathematical value,
13351329
_minFraction_: an integer in the inclusive interval from 0 to 100,
13361330
_maxFraction_: an integer in the inclusive interval from 0 to 100,
13371331
_roundingIncrement_: an integer,
@@ -1351,13 +1345,8 @@ <h1>
13511345
1. Let _f_ be _maxFraction_.
13521346
1. [declared="n1,r1"] Let _n1_ be an integer and _r1_ a mathematical value, with <emu-eqn>_r1_ = ToRawFixedFn(_n1_, _f_)</emu-eqn>, such that <emu-eqn>_n1_ modulo _roundingIncrement_ = 0</emu-eqn>, <emu-eqn>_r1__x_</emu-eqn>, and _r1_ is maximized.
13531347
1. [declared="n2,r2"] Let _n2_ be an integer and _r2_ a mathematical value, with <emu-eqn>_r2_ = ToRawFixedFn(_n2_, _f_)</emu-eqn>, such that <emu-eqn>_n2_ modulo _roundingIncrement_ = 0</emu-eqn>, <emu-eqn>_r2__x_</emu-eqn>, and _r2_ is minimized.
1354-
1. Let _r_ be ApplyUnsignedRoundingMode(_x_, _r1_, _r2_, _unsignedRoundingMode_).
1355-
1. If _r_ is _r1_, then
1356-
1. Let _n_ be _n1_.
1357-
1. Let _xFinal_ be _r1_.
1358-
1. Else,
1359-
1. Let _n_ be _n2_.
1360-
1. Let _xFinal_ be _r2_.
1348+
1. Let _xFinal_ be ApplyUnsignedRoundingMode(_x_, _r1_, _r2_, _unsignedRoundingMode_).
1349+
1. If _xFinal_ is _r1_, let _n_ be _n1_. Otherwise, let _n_ be _n2_.
13611350
1. If _n_ = 0, let _m_ be *"0"*. Otherwise, let _m_ be the String consisting of the digits of the decimal representation of _n_ (in order, with no leading zeroes).
13621351
1. If _f_ ≠ 0, then
13631352
1. Let _k_ be the length of _m_.
@@ -1677,13 +1666,13 @@ <h1>
16771666
<emu-clause id="sec-getunsignedroundingmode" type="abstract operation">
16781667
<h1>
16791668
GetUnsignedRoundingMode (
1680-
_roundingMode_: a String,
1669+
_roundingMode_: a rounding mode,
16811670
_sign_: ~negative~ or ~positive~,
16821671
): a specification type from the Unsigned Rounding Mode column of <emu-xref href="#table-intl-unsigned-rounding-modes"></emu-xref>
16831672
</h1>
16841673
<dl class="header">
16851674
<dt>description</dt>
1686-
<dd>It returns the rounding mode that should be applied to the absolute value of a number to produce the same result as if _roundingMode_, one of the String values in the Identifier column of <emu-xref href="#table-intl-rounding-modes"></emu-xref>, were applied to the signed value of the number (negative if _sign_ is ~negative~, or positive otherwise).</dd>
1675+
<dd>It returns the <emu-not-ref>rounding mode</emu-not-ref> that should be applied to the absolute value of a number to produce the same result as if _roundingMode_ were applied to the signed value of the number (negative if _sign_ is ~negative~, or positive otherwise).</dd>
16871676
</dl>
16881677
<emu-alg>
16891678
1. Return the specification type in the Unsigned Rounding Mode column of <emu-xref href="#table-intl-unsigned-rounding-modes"></emu-xref> for the row where the value in the Identifier column is _roundingMode_ and the value in the Sign column is _sign_.

spec/pluralrules.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ <h1>Properties of Intl.PluralRules Instances</h1>
235235
<li>[[RoundingType]] is one of the values ~fraction-digits~, ~significant-digits~, ~more-precision~, or ~less-precision~, indicating which rounding strategy to use, as discussed in <emu-xref href="#sec-properties-of-intl-numberformat-instances"></emu-xref>.</li>
236236
<li>[[ComputedRoundingPriority]] is one of the String values *"auto"*, *"morePrecision"*, or *"lessPrecision"*. It is only used in <emu-xref href="#sec-intl.pluralrules.prototype.resolvedoptions"></emu-xref> to convert [[RoundingType]] back to a valid *"roundingPriority"* option.</li>
237237
<li>[[RoundingIncrement]] is an integer that evenly divides 10, 100, 1000, or 10000 into tenths, fifths, quarters, or halves. It indicates the increment at which rounding should take place relative to the calculated rounding magnitude. For example, if [[MaximumFractionDigits]] is 2 and [[RoundingIncrement]] is 5, then formatted numbers are rounded to the nearest 0.05 ("nickel rounding").</li>
238-
<li>[[RoundingMode]] is one of the String values in the Identifier column of <emu-xref href="#table-intl-rounding-modes"></emu-xref>, specifying which rounding mode to use.</li>
238+
<li>[[RoundingMode]] identifies the rounding mode to use.</li>
239239
<li>[[TrailingZeroDisplay]] is one of the String values *"auto"* or *"stripIfInteger"*, indicating whether to strip trailing zeros if the formatted number is an integer (i.e., has no non-zero fraction digit).</li>
240240
</ul>
241241
</emu-clause>

0 commit comments

Comments
 (0)