@@ -20,7 +20,7 @@ location: https://github.com/tc39/proposal-decimal/
2020 </ul>
2121</emu-intro>
2222
23- <emu-clause id="sec-the-decimal -object">
23+ <emu-clause id="sec-the-decimal128 -object">
2424 <h1>The Decimal128 Object</h1>
2525
2626 <emu-intro id="sec-decimal128-intro">
@@ -123,6 +123,7 @@ location: https://github.com/tc39/proposal-decimal/
123123 <p>The scaled significand of a finite Decimal128 value is always an integer whose absolute value is less than 10<sup>34</sup>.</p>
124124 </emu-note>
125125 </emu-intro>
126+
126127 <emu-clause id="sec-decimal128-abstract-ops">
127128 <h1>Abstract Operations</h1>
128129
@@ -159,31 +160,31 @@ location: https://github.com/tc39/proposal-decimal/
159160 1. If _rounded_ = 0, return *+0*<sub>𝔻</sub>.
160161 1. Return _rounded_ × 10<sup>_te_</sup>.
161162 </emu-alg>
163+ </emu-clause>
162164
163- <emu-clause id="sec-decimal128-applyroundingmodetopositive" type="abstract operation">
164- <h1>ApplyRoundingModeToPositive(
165- _m_: a positive mathematical value,
166- _roundingMode_: a Decimal128 rounding mode
167- ): an integer
168- </h1>
169- <dl class="header">
170- <dt>description</dt>
171- <dd>It computes the closest integer approximation to a given positive mathematical value, rounded according to the given rounding mode.</dd>
172- </dl>
173- <emu-alg>
174- 1. Let _mLow_ be floor(_m_).
175- 1. Let _fraction_ be _m_ – _mLow_.
176- 1. If _fraction_ = 0, return _mLow_.
177- 1. Let _mHigh_ be _mLow_ + 1.
178- 1. If _roundingMode_ is *"floor"* or *"trunc"*, return _mLow_.
179- 1. If _roundingMode_ is *"ceil"*, return _mHigh_.
180- 1. If _fraction_ < 0.5, return _mLow_.
181- 1. If _fraction_ > 0.5, return _mHigh_.
182- 1. If _roundingMode_ is *"halfExpand"*, return _mHigh_.
183- 1. If _mLow_ is an even integer, return _mLow_.
184- 1. Return _mHigh_.
185- </emu-alg>
186- </emu-clause>
165+ <emu-clause id="sec-decimal128-applyroundingmodetopositive" type="abstract operation">
166+ <h1>ApplyRoundingModeToPositive(
167+ _m_: a positive mathematical value,
168+ _roundingMode_: a Decimal128 rounding mode
169+ ): an integer
170+ </h1>
171+ <dl class="header">
172+ <dt>description</dt>
173+ <dd>It computes the closest integer approximation to a given positive mathematical value, rounded according to the given rounding mode.</dd>
174+ </dl>
175+ <emu-alg>
176+ 1. Let _mLow_ be floor(_m_).
177+ 1. Let _fraction_ be _m_ – _mLow_.
178+ 1. If _fraction_ = 0, return _mLow_.
179+ 1. Let _mHigh_ be _mLow_ + 1.
180+ 1. If _roundingMode_ is *"floor"* or *"trunc"*, return _mLow_.
181+ 1. If _roundingMode_ is *"ceil"*, return _mHigh_.
182+ 1. If _fraction_ < 0.5, return _mLow_.
183+ 1. If _fraction_ > 0.5, return _mHigh_.
184+ 1. If _roundingMode_ is *"halfExpand"*, return _mHigh_.
185+ 1. If _mLow_ is an even integer, return _mLow_.
186+ 1. Return _mHigh_.
187+ </emu-alg>
187188 </emu-clause>
188189
189190 <emu-clause id="sec-decimal128-abs" type="abstract operation">
@@ -403,6 +404,76 @@ location: https://github.com/tc39/proposal-decimal/
403404 </emu-clause>
404405 </emu-clause>
405406 </emu-clause>
407+
408+ <emu-clause id="sec-the-decimal128-amount-object">
409+ <h1>The Decimal128.Amount Object</h1>
410+
411+ <emu-intro id="sec-decimal128-amount-intro">
412+ <h1>Introduction</h1>
413+ <p>Decimal128.Amount values are intended to contain a Decimal128 value together with a precision, as well as information about how the precision that number should be understood. The two ways precision can be understood are in terms of fractional digits and significant digits.</p>
414+ </emu-intro>
415+
416+ <emu-clause id="sec-decimal128-amount-abstract-ops">
417+ <h1>Abstract Operations</h1>
418+ <emu-clause id="sec-decimal128-amount-aresameprecision" type="abstract operation">
419+ <h1>AreSamePrecision(
420+ _v_: a mathematical value,
421+ _significantDigits_: a non-negative integer,
422+ _fractionalDigits_: a non-negative integer
423+ ): a Boolean value
424+ </h1>
425+ <dl class="header">
426+ <dt>description</dt>
427+ <dd>It computes whether the decimal string rendering of the given mathematical value is the same if expressed in terms of the given number of significant digits and the given number of fractional digits. Rounding may be necessary to make this determination; if so, the round-half-to-even method will be applied.</dd>
428+ </dl>
429+ <emu-alg>
430+ 1. If _v_ < 0, set _v_ to -_v_.
431+ 1. If _v_ = 0, then
432+ 1. If _significantDigits_ = _fractionalDigits_, return *true*.
433+ 1. Otherwise, return *false*.
434+ 1. Let _whole_ be floor(_v_).
435+ 1. Let _scaledByFractionalDigits_ be _v_ × 10<sup>_fractionalDigits_</sup>.
436+ 1. Let _log10_ be the log-base-10 of _whole_.
437+ 1. Let _numWholeDigits_ be floor(_log10_) + 1.
438+ 1. If _numWholeDigits_ ≤ _significantDigits_, let _scaledBySignificantDigits_ be _v_ × 10<sup>_significantDigits_</sup>, else let _scaledBySignificantDigits_ be _v_ - _v_ × 10<sup>-_significantDigits_</sup>.
439+ 1. Set _scaledBySignificantDigits_ to ApplyRoundingModeToPositive(_scaledBySignificantDigits_, *"halfEven"*).
440+ 1. Set _scaledByFractionalDigits_ to ApplyRoundingModeToPositive(_scaledByFractionalDigits_, *"halfEven"*).
441+ 1. If _scaledBySignificantDigits_ = _scaledByFractionalDigits_, return *true*.
442+ 1. Otherwise, return *false*.
443+ </emu-alg>
444+ </emu-clause>
445+ </emu-clause>
446+
447+ <emu-clause id="sec-the-decimal128-amount-constructor">
448+ <h1>The Decimal128.Amount Constructor</h1>
449+ <p>The Decimal128.Amount constructor:</p>
450+ <ul>
451+ <li>is <dfn>%Decimal128Amount%</dfn>.</li>
452+ <li>is the initial value of the the *"Decimal128Amount"* property of the global object.</li>
453+ <li>creates and initializes a new Decimal128.Amount object when called as a constructor</li>
454+ <li>may be used as the value of an *extends* clause of a class definition. Subclass constructors that intend to inherit the specified Decimal128.Amount behaviour must include a *super* call to the Decimal128.Amount constructor to create and initialize the subclass instance with the [[Decimal128AmountData]], [[Decimal128AmountPrecision]], and [[Decimal128AmountPrecisionMode]] internal slots.</li>
455+ </ul>
456+ <emu-clause id="sec-the-decimal128-amount-constructor-value">
457+ <h1>Decimal128.Amount ( _s_, _precision_, _mode_ )</h1>
458+ <emu-alg>
459+ 1. If NewTarget is *undefined*, throw a *TypeError* exception.
460+ 1. If _s_ is not a String, throw a *TypeError* exception.
461+ 1. If _precision_ is not a Number, throw a *TypeError* exception.
462+ 1. If _precision_ is *NaN*<sub>𝔽</sub>, *+∞*<sub>𝔽</sub> or *+∞*<sub>𝔽</sub>, throw a *RangeError* exception.
463+ 1. If ℝ(_precision_) < 0, throw a *RangeError* exception.
464+ 1. If ℝ(_precision_) is not an integer, throw a *RangeError* exception.
465+ 1. If _mode_ is not a String, throw a *TypeError* exception.
466+ 1. If _mode_ is not one of « *"fractionalDigits"*, *"significantDigits"* », throw a *RangeError* exception.
467+ 1. Let _decimal_ be ? Construct(%Decimal128%, _s_).
468+ 1. Let _O_ be ? OrdinaryCreateFromConstructor(NewTarget, *"%Decimal128Amount.prototype%"*, « [[Decimal128AmountData]], [[Decimal128AmountPrecision]], [[Decimal128AmountPrecisionMode]] »).
469+ 1. Set _O_.[[Decimal128AmountData]] to _decimal_.[[Decimal128Data]].
470+ 1. Set _O_.[[Decimal128AmountPrecision]] to _precision_.
471+ 1. Set _O_.[[Decimal128AmountPrecisionMode]] to _mode_.
472+ 1. Return _O_.
473+ </emu-alg>
474+ </emu-clause>
475+ </emu-clause>
476+ </emu-clause>
406477</emu-clause>
407478
408479<emu-clause id="sec-decimal128-prototype-properties">
@@ -1069,6 +1140,32 @@ location: https://github.com/tc39/proposal-decimal/
10691140 </emu-note>
10701141 </emu-clause>
10711142
1143+ <emu-clause id="sec-decimal128.prototype.withfractionaldigits">
1144+ <h1>Decimal128.prototype.withFractionalDigits ( _n_ )</h1>
1145+ <p>This method converts the current Decimal128 object into a Decimal128.Amount value with a specified number of fractional digits.</p>
1146+ <p>It performs the following steps when called:</p>
1147+ <emu-alg>
1148+ 1. Let _O_ be the *this* value.
1149+ 1. Perform ? RequireInternalSlot(_O_, [[Decimal128Data]]).
1150+ 1. Let _d_ be _O_.[[Decimal128Data]].
1151+ 1. Let _s_ be Decimal128ToDecimalString(_d_).
1152+ 1. Return ? Construct(%Decimal128Amount%, « _s_, _n_, *"fractionalDigits"* »).
1153+ </emu-alg>
1154+ </emu-clause>
1155+
1156+ <emu-clause id="sec-decimal128.prototype.withsignificantdigits">
1157+ <h1>Decimal128.prototype.withSignificantDigits ( _n_ )</h1>
1158+ <p>This method converts the current Decimal128 object into a Decimal128.Amount value with a specified number of significant digits.</p>
1159+ <p>It performs the following steps when called:</p>
1160+ <emu-alg>
1161+ 1. Let _O_ be the *this* value.
1162+ 1. Perform ? RequireInternalSlot(_O_, [[Decimal128Data]]).
1163+ 1. Let _d_ be _O_.[[Decimal128Data]].
1164+ 1. Let _s_ be Decimal128ToDecimalString(_d_).
1165+ 1. Return ? Construct(%Decimal128Amount%, « _s_, _n_, *"significantDigits"* »).
1166+ </emu-alg>
1167+ </emu-clause>
1168+
10721169 <emu-clause id="sec-decimal128.prototype.valueof">
10731170 <h1>Decimal128.prototype.valueOf ( _x_ )</h1>
10741171 <p>This method performs the following steps when called:</p>
@@ -1078,6 +1175,50 @@ location: https://github.com/tc39/proposal-decimal/
10781175 </emu-clause>
10791176</emu-clause>
10801177
1178+ <emu-clause id="sec-decimal128-amount-prototype">
1179+ <h1>Properties of the Decimal128.Amount Prototype</h1>
1180+
1181+ <emu-clause id="sec-decimal128.amount.prototype.equals">
1182+ <h1>Decimal128.Amount.prototype.equals ( _x_ )</h1>
1183+ <p>This method returns a Boolean value indicating whether a Decimal128.Amount object is equal to another Decimal128.Amount object.</p>
1184+ <p>It performs the following steps when called:</p>
1185+ <emu-alg>
1186+ 1. Let _O_ be the *this* value.
1187+ 1. Perform ? RequireInternalSlot(_O_, [[Decimal128AmountData]]).
1188+ 1. Perform ? RequireInternalSlot(_O_, [[Decimal128AmountPrecision]]).
1189+ 1. Perform ? RequireInternalSlot(_O_, [[Decimal128AmountPrecisionMode]]).
1190+ 1. Perform ? RequireInternalSlot(_x_, [[Decimal128AmountData]]).
1191+ 1. Perform ? RequireInternalSlot(_x_, [[Decimal128AmountPrecision]]).
1192+ 1. Perform ? RequireInternalSlot(_x_, [[Decimal128AmountPrecisionMode]]).
1193+ 1. Let _d1_ be _O_.[[Decimal128AmountData]].
1194+ 1. Let _d2_ be _x_.[[Decimal128AmountData]].
1195+ 1. Assert: _d1_ is a finite Decimal128 value.
1196+ 1. Assert: _d2_ is a finite Decimal128 value.
1197+ 1. If _d1_ is either *+0*<sub>𝔻</sub> or *-0*<sub>𝔻</sub>, set _d1_ to 0.
1198+ 1. If _d2_ is either *+0*<sub>𝔻</sub> or *-0*<sub>𝔻</sub>, set _d2_ to 0.
1199+ 1. If _d1_ ≠ _d2_, return *false*.
1200+ 1. Let _mode1_ be _O_.[[Decimal128AmountPrecisionMode]].
1201+ 1. Let _mode2_ be _x_.[[Decimal128AmountPrecisionMode]].
1202+ 1. Assert: _mode1_ is one of « *"fractionalDigits"*, *"significantDigits"* ».
1203+ 1. Assert: _mode2_ is one of « *"fractionalDigits"*, *"significantDigits"* ».
1204+ 1. Let _precision1_ be _O_.[[Decimal128AmountPrecision]].
1205+ 1. Let _precision2_ be _x_.[[Decimal128AmountPrecision]].
1206+ 1. Assert: _precision1_ is a non-negative integer.
1207+ 1. Assert: _precision2_ is a non-negative integer.
1208+ 1. If _mode1_ is *"fractionalDigits"*, then
1209+ 1. If _mode2_ is *"fractionalDigits"*, then
1210+ 1. If _precision1_ = _precision2_, return *true*.
1211+ 1. Otherwise, return *false*.
1212+ 1. Otherwise:
1213+ 1. Return AreSamePrecision(_d1_, _precision2_, _precision1_).
1214+ 1. Otherwise:
1215+ 1. If _mode2_ is *"fractionalDigits"*, return AreSamePrecision(_d1_, _precision1_, _precision2_).
1216+ 1. Else if _precision1_ = _precision2_, return *true*.
1217+ 1. Otherwise, return *false*.
1218+ </emu-alg>
1219+ </emu-clause>
1220+ </emu-clause>
1221+
10811222<emu-clause id="sec-numbers-and-dates">
10821223 <h1>Numbers and Dates</h1>
10831224 <emu-clause id="sec-number-objects">
0 commit comments