Skip to content

Commit

Permalink
Use the Intl.NumberFormat names
Browse files Browse the repository at this point in the history
Also, add a note for implementors mapping the rounding mode
names, which are taken from Intl.NumberFormat, to the
official IEEE 754 names.

Refer to the default rounding mode by reference rather than
directly naming it.
  • Loading branch information
jessealama committed May 17, 2024
1 parent aa24923 commit 7c94bde
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,47 @@ location: https://github.com/tc39/proposal-decimal/
<p>The _v_ component of a finite non-zero Decimal128 value « _v_, _q_ »<sub>𝔻</sub> is a rational number.</p>
</emu-note>
<p>Decimal128 values defined in this section are ECMAScript analogues of <emu-xref href="#sec-bibliography">IEEE-754 Decimal128 values</emu-xref>. The full spectrum of values defined by Decimal128 are available here, though there is only one Decimal128 value, NaN<sub>𝔻</sub>, representing all possible IEEE 754 Decimal128 NaN values.</p>
<p>A <dfn id="dfn-decimal128-rounding-mode">rounding mode</dfn> is one of the String values *"roundTowardPositive"*, *"roundTowardNegative"*, *"roundTowardZero"*, *"roundTiesToAway"*, and *"roundTiesToEven"*. The <dfn id="dfn-decimal128-default-rounding-mode">default rounding mode</dfn> is the String value *"roundTiesToEven"*.</p>
<p>A <dfn id="dfn-decimal128-rounding-mode">rounding mode</dfn> is one of the String values *"ceil"*, *"floor"*, *"trunc"*, *"halfExpand"*, and *"halfEven"*. The <dfn id="dfn-decimal128-default-rounding-mode">default rounding mode</dfn> is the String value *"halfEven"*.</p>
<emu-table id="table-decimal128-rounding-modes">
<emu-caption>Rounding modes in Decimal128 compared to IEEE 754 rounding modes</emu-caption>
<table class="real-table">
<thead>
<tr>
<th>Decimal128 rounding mode</th>
<th>Description</th>
<th>IEEE 754 rounding mode</th>
</tr>
</thead>
<tbody>
<tr>
<td>*"ceil"*</td>
<td>Toward positive infinity</td>
<td>*"roundTowardPositive"*</td>
</tr>
<tr>
<td>*"floor"*</td>
<td>Toward negative infinity</td>
<td>*"roundTowardNegative"*</td>
</tr>
<tr>
<td>*"trunc"*</td>
<td>Toward zero</td>
<td>*"roundTowardZero"*</td>
</tr>
<tr>
<td>*"halfExpand"*</td>
<td>Ties away from zero</td>
<td>*"roundTiesToAway"*</td>
</tr>
<tr>
<td>*"halfEven"*</td>
<td>Ties toward an even rounding increment multiple</td>
<td>*"roundTiesToEven"*</td>
</tr>
</tbody>
</table>
<emu-note>The above five rounding modes are defined in IEEE 754. This table is offered for implementors who may need to convert the Decimal128 rounding modes defined here into a library that may use the official IEEE 754 rounding mode names. Additional rounding modes are used elsewhere in this specification, such as in <emu-xref href="https://402.ecma-international.org/#table-intl-rounding-modes">Intl.NumberFormat</emu-xref>.</emu-note>
</emu-table>
<p>The <dfn id="dfn-decimal128-cohort">cohort</dfn> of a Decimal128 value is defined as follows:</p>
<ul>
<li>cohort(*NaN*<sub>𝔻</sub>) = *NaN*<sub>𝔻</sub></li>
Expand Down Expand Up @@ -454,7 +494,7 @@ location: https://github.com/tc39/proposal-decimal/
<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 *"roundTiesToEven"*.
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"*.
Expand Down

0 comments on commit 7c94bde

Please sign in to comment.