Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jessealama committed May 23, 2024
1 parent cd11594 commit cbd7dcf
Showing 1 changed file with 39 additions and 29 deletions.
68 changes: 39 additions & 29 deletions spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ location: https://github.com/tc39/proposal-decimal/
1. If _argument_ is a Number, set _toParse_ to Number::toString(_argument_, 10).
1. If _argument_ is a String, set _toParse_ to _argument_.
1. If _toParse_ is not a String, throw a *TypeError* exception.
1. StringToNumber
1. Return <mark>« 42, 42 »</mark>.
</emu-alg>
</emu-clause>
Expand All @@ -183,7 +184,10 @@ location: https://github.com/tc39/proposal-decimal/
<dd>It renders _argument_ as a decimal (non-exponential) string.</dd>
</dl>
<emu-alg>
1. Return <mark>*"42"*</mark>.
1. If _argument_ is NaN, ...
1. If _argument_ is +/-infinity, ...
1. If _argument_ is -0, ...
1. Adapt Number::toString to our case.
</emu-alg>
</emu-clause>
<emu-clause id="sec-decimal128toexponentialstring" type="abstract operation">
Expand All @@ -197,20 +201,24 @@ location: https://github.com/tc39/proposal-decimal/
<dd>It renders _argument_ in exponential notation.</dd>
</dl>
<emu-alg>
1. Return <mark>*"42E42"*</mark>.
1. If _argument_ is NaN, ...
1. If _argument_ is +/-infinity, ...
1. If _argument_ is -0, ...
1. Adapt Number::toString to our case.
</emu-alg>
</emu-clause>
<emu-clause id="sec-decimal128-isintegraldecimal128value" type="abstract operation">
<h1>
IsIntegralDecimal128 (
_argument_: A Decimal128 object
_argument_: A Decimal128 value
): a Boolean
</h1>
<dl class="header">
<dt>description</dt>
<dd>It determines if _argument_ is a finite integral Decimal128 value.</dd>
</dl>
<emu-alg>
1. <mark>todo</mark>
1. Let _d_ be _argument_.[[Decimal128Data]].
1. If _d_ is *NaN*<sub>𝔻</sub>, return *false*.
1. If _d_ is *+∞*<sub>𝔻</sub> or *+∞*<sub>𝔻</sub>, return *false*.
Expand All @@ -236,6 +244,19 @@ location: https://github.com/tc39/proposal-decimal/
1. Return _O_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-numbertobigint" type="abstract operation">
<h1>
<ins>Decimal128ToBigInt (
_number_: a Decimal128 value,
): either a normal completion containing a BigInt or a throw completion</ins>
</h1>
<dl class="header">
</dl>
<emu-alg>
1. If IsIntegralDecimal128(_number_) is *false*, throw a *RangeError* exception.
1. Return ℤ(ℝ(_number_)).
</emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-the-decimal-constructor">
<h1>The Decimal128 Constructor</h1>
Expand Down Expand Up @@ -322,7 +343,7 @@ location: https://github.com/tc39/proposal-decimal/
1. If _d2_ is *+∞*<sub>𝔻</sub>, return Decimal128ValueToObject(*NaN*<sub>𝔻</sub>).
1. If _d2_ is *-∞*<sub>𝔻</sub>, return Decimal128ValueToObject(*-∞*<sub>𝔻</sub>).
1. Return Decimal128ValueToObject(*-∞*<sub>𝔻</sub>).
1. Return <mark>Decimal128ValueToObject(« _d1_[0] + _d2_[0], min(_d1_[1], _d2_[1]) »)</mark>.
1. Return 𝔻(_d1_[0] + _d2_[0], min(_d1_[1], _d2_[1])).
</emu-alg>
</emu-clause>
<emu-clause id="sec-decimal.prototype.subtract">
Expand Down Expand Up @@ -490,26 +511,29 @@ location: https://github.com/tc39/proposal-decimal/
</emu-note>
</emu-clause>
<emu-clause id="sec-decimal.prototype.tostring">
<h1>Decimal128.prototype.toString ( [ _options_ ] )</h1>
<h1>Decimal128.prototype.toString ( )</h1>
<p>This method performs the following steps when called:</p>
<emu-alg>
1. Let _roundingMode_ be ? Get(_options_, *"roundingMode"*).
1. If _roundingMode_ is *undefined*, set _roundingMode_ to the <emu-xref href="#dfn-decimal128-default-rounding-mode">default rounding mode</emu-xref>.
1. If _roundingMode_ is not a <emu-xref href="#dfn-decimal128-rounding-mode">rounding mode</emu-xref>, throw a *RangeError* exception.
1. Let _format_ be ? Get(_options_, *"format*").
1. If _format_ is *undefined*, set _format_ to *"decimal"*.
1. If _format_ is not in « *"decimal"*, *"exponential"* », then throw a *RangeError* exception.
1. If _format_ is *"decimal*", then
1. Return Decimal128ToDecimalString(*this*).
1. Return Decimal128ToExponentialString(*this*).
1. Return Decimal128ToDecimalString(*this*).
</emu-alg>
</emu-clause>
<emu-clause id="sec-decimal.prototype.toexponentialstring">
<h1>Decimal128.prototype.toExponentialString ( )</h1>
<p>This method performs the following steps when called:</p>
<emu-alg>
1. Return Decimal128ToExponentialDecimalString(*this*).
</emu-alg>
</emu-clause>
<emu-clause id="sec-decimal.prototype.tobigint">
<h1>Decimal128.prototype.toBigInt ( )</h1>
<p>This method performs the following steps when called:</p>
<emu-alg>
1. If IsIntegralDecimal128(*this*) is *false*, throw a *RangeError* exception.
1. Return ! ToBigInt(Call (*this*.[[toString]], *this*)).
1. Let _O_ be the *this* value.
1. Perform ? RequireInternalSlot(_O_, [[Decimal128Data]]).
1. Let _v_ be _O_.[[Decimal128Data]].
1. If IsIntegralDecimal128(_number_) is *false*, throw a *RangeError* exception.
1. Return ℤ(ℝ(_number_)).
</emu-alg>
</emu-clause>
<emu-clause id="sec-decimal.prototype.tonumber">
Expand Down Expand Up @@ -573,20 +597,6 @@ location: https://github.com/tc39/proposal-decimal/
1. If _prim_ is a Number, return ? NumberToBigInt(_prim_).
1. Otherwise, return ? <emu-meta suppress-effects="user-code">ToBigInt(_prim_)</emu-meta>.
</emu-alg>

<emu-clause id="sec-numbertobigint" type="abstract operation">
<h1>
<ins>Decimal128ToBigInt (
_number_: a Decimal128 object,
): either a normal completion containing a BigInt or a throw completion</ins>
</h1>
<dl class="header">
</dl>
<emu-alg>
1. If IsIntegralDecimal128(_number_) is *false*, throw a *RangeError* exception.
1. Return ℤ(ℝ(_number_)).
</emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
</emu-clause>
Expand Down

0 comments on commit cbd7dcf

Please sign in to comment.