Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorial: Complete standard preambles for numeric methods #1974

Merged
merged 1 commit into from
May 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 47 additions & 12 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,7 @@ <h1>The Number Type</h1>

<emu-clause id="sec-numeric-types-number-unaryMinus">
<h1>Number::unaryMinus ( _x_ )</h1>
<p>The abstract operation Number::unaryMinus takes argument _x_ (a Number). It performs the following steps when called:</p>
<emu-alg>
1. If _x_ is *NaN*, return *NaN*.
1. Return the result of negating _x_; that is, compute a Number with the same magnitude but opposite sign.
Expand All @@ -1499,6 +1500,7 @@ <h1>Number::unaryMinus ( _x_ )</h1>

<emu-clause id="sec-numeric-types-number-bitwiseNOT">
<h1>Number::bitwiseNOT ( _x_ )</h1>
<p>The abstract operation Number::bitwiseNOT takes argument _x_ (a Number). It performs the following steps when called:</p>
<emu-alg>
1. Let _oldValue_ be ! ToInt32(_x_).
1. Return the result of applying bitwise complement to _oldValue_. The result is a signed 32-bit integer.
Expand All @@ -1507,9 +1509,7 @@ <h1>Number::bitwiseNOT ( _x_ )</h1>

<emu-clause id="sec-numeric-types-number-exponentiate" oldids="sec-applying-the-exp-operator">
<h1>Number::exponentiate ( _base_, _exponent_ )</h1>
<p>
Returns an implementation-dependent approximation of the result of raising _base_ to the power _exponent_.
</p>
<p>The abstract operation Number::exponentiate takes arguments _base_ (a Number) and _exponent_ (a Number). It returns an implementation-dependent approximation of the result of raising _base_ to the power _exponent_, subject to the following requirements:</p>
jmdyck marked this conversation as resolved.
Show resolved Hide resolved
<ul>
<li>If _exponent_ is *NaN*, the result is *NaN*.</li>
<li>If _exponent_ is *+0*, the result is 1, even if _base_ is *NaN*.</li>
Expand Down Expand Up @@ -1542,8 +1542,7 @@ <h1>Number::exponentiate ( _base_, _exponent_ )</h1>

<emu-clause id="sec-numeric-types-number-multiply" oldids="sec-applying-the-mul-operator">
<h1>Number::multiply ( _x_, _y_ )</h1>
<p>The `*` |MultiplicativeOperator| performs multiplication, producing the product of _x_ and _y_. Multiplication is commutative. Multiplication is not always associative in ECMAScript, because of finite precision.</p>
<p>The result of a floating-point multiplication is governed by the rules of IEEE 754-2019 binary double-precision arithmetic:</p>
<p>The abstract operation Number::multiply takes arguments _x_ (a Number) and _y_ (a Number). It performs multiplication, producing the product of _x_ and _y_, as determined by the rules of IEEE 754-2019 binary double-precision arithmetic:</p>
<ul>
<li>
If either operand is *NaN*, the result is *NaN*.
Expand All @@ -1564,11 +1563,14 @@ <h1>Number::multiply ( _x_, _y_ )</h1>
In the remaining cases, where neither an infinity nor *NaN* is involved, the product is computed and rounded to the nearest representable value using IEEE 754-2019 roundTiesToEven mode. If the magnitude is too large to represent, the result is then an infinity of appropriate sign. If the magnitude is too small to represent, the result is then a zero of appropriate sign. The ECMAScript language requires support of gradual underflow as defined by IEEE 754-2019.
</li>
</ul>
<emu-note>
<p>Finite-precision multiplication is commutative, but not always associative.</p>
</emu-note>
</emu-clause>

<emu-clause id="sec-numeric-types-number-divide" oldids="sec-applying-the-div-operator">
<h1>Number::divide ( _x_, _y_ )</h1>
<p>The `/` |MultiplicativeOperator| performs division, producing the quotient of _x_ and _y_. _x_ is the dividend and _y_ is the divisor. ECMAScript does not perform integer division. The operands and result of all division operations are double-precision floating-point numbers. The result of division is determined by the specification of IEEE 754-2019 arithmetic:</p>
<p>The abstract operation Number::divide takes arguments _x_ (a Number) and _y_ (a Number). It performs division, producing the quotient of _x_ and _y_; _x_ is the dividend and _y_ is the divisor. The result is determined by the specification of IEEE 754-2019 arithmetic:</p>
michaelficarra marked this conversation as resolved.
Show resolved Hide resolved
<ul>
<li>
If either operand is *NaN*, the result is *NaN*.
Expand Down Expand Up @@ -1602,7 +1604,7 @@ <h1>Number::divide ( _x_, _y_ )</h1>

<emu-clause id="sec-numeric-types-number-remainder" oldids="sec-applying-the-mod-operator">
<h1>Number::remainder ( _n_, _d_ )</h1>
<p>The `%` |MultiplicativeOperator| yields the remainder of its operands from an implied division; _n_ is the dividend and _d_ is the divisor.</p>
<p>The abstract operation Number::remainder takes arguments _n_ (a Number) and _d_ (a Number). It yields the remainder of its operands from an implied division; _n_ is the dividend and _d_ is the divisor.</p>
<emu-note>
<p>In C and C++, the remainder operator accepts only integral operands; in ECMAScript, it also accepts floating-point operands.</p>
</emu-note>
Expand Down Expand Up @@ -1632,9 +1634,7 @@ <h1>Number::remainder ( _n_, _d_ )</h1>

<emu-clause id="sec-numeric-types-number-add" oldids="sec-applying-the-additive-operators-to-numbers">
<h1>Number::add ( _x_, _y_ )</h1>
<p>The `+` operator performs addition when applied to _x_ and _y_, producing the sum of the operands.</p>
<p>Addition is a commutative operation, but not always associative.</p>
<p>The result of an addition is determined using the rules of IEEE 754-2019 binary double-precision arithmetic:</p>
<p>The abstract operation Number::add takes arguments _x_ (a Number) and _y_ (a Number). It performs addition, producing the sum of _x_ and _y_ as determined using the rules of IEEE 754-2019 binary double-precision arithmetic:</p>
<ul>
<li>
If either operand is *NaN*, the result is *NaN*.
Expand All @@ -1661,16 +1661,25 @@ <h1>Number::add ( _x_, _y_ )</h1>
In the remaining cases, where neither an infinity, nor a zero, nor *NaN* is involved, and the operands have the same sign or have different magnitudes, the sum is computed and rounded to the nearest representable value using IEEE 754-2019 roundTiesToEven mode. If the magnitude is too large to represent, the operation overflows and the result is then an infinity of appropriate sign. The ECMAScript language requires support of gradual underflow as defined by IEEE 754-2019.
</li>
</ul>
<emu-note>
<p>Finite-precision addition is commutative, but not always associative.</p>
</emu-note>
</emu-clause>

<emu-clause id="sec-numeric-types-number-subtract">
<h1>Number::subtract ( _x_, _y_ )</h1>
<p>The `-` operator performs subtraction when applied to two operands of numeric type, producing the difference of its operands; _x_ is the minuend and _y_ is the subtrahend. It is always the case that `x - y` produces the same result as `x + (-y)`.</p>
<p>The result of `-` operator is then _x_ + (-_y_).</p>
<p>The abstract operation Number::subtract takes arguments _x_ (a Number) and _y_ (a Number). It performs subtraction, producing the difference of its operands; _x_ is the minuend and _y_ is the subtrahend. It performs the following steps when called:</p>
<emu-alg>
1. Return Number::add(_x_, Number::unaryMinus(_y_)).
</emu-alg>
<emu-note>
<p>It is always the case that `x - y` produces the same result as `x + (-y)`.</p>
</emu-note>
</emu-clause>

<emu-clause id="sec-numeric-types-number-leftShift">
<h1>Number::leftShift ( _x_, _y_ )</h1>
<p>The abstract operation Number::leftShift takes arguments _x_ (a Number) and _y_ (a Number). It performs the following steps when called:</p>
<emu-alg>
1. Let _lnum_ be ! ToInt32(_x_).
1. Let _rnum_ be ! ToUint32(_y_).
Expand All @@ -1681,6 +1690,7 @@ <h1>Number::leftShift ( _x_, _y_ )</h1>

<emu-clause id="sec-numeric-types-number-signedRightShift">
<h1>Number::signedRightShift ( _x_, _y_ )</h1>
<p>The abstract operation Number::signedRightShift takes arguments _x_ (a Number) and _y_ (a Number). It performs the following steps when called:</p>
<emu-alg>
1. Let _lnum_ be ! ToInt32(_x_).
1. Let _rnum_ be ! ToUint32(_y_).
Expand All @@ -1691,6 +1701,7 @@ <h1>Number::signedRightShift ( _x_, _y_ )</h1>

<emu-clause id="sec-numeric-types-number-unsignedRightShift">
<h1>Number::unsignedRightShift ( _x_, _y_ )</h1>
<p>The abstract operation Number::unsignedRightShift takes arguments _x_ (a Number) and _y_ (a Number). It performs the following steps when called:</p>
<emu-alg>
1. Let _lnum_ be ! ToUint32(_x_).
1. Let _rnum_ be ! ToUint32(_y_).
Expand All @@ -1701,6 +1712,7 @@ <h1>Number::unsignedRightShift ( _x_, _y_ )</h1>

<emu-clause id="sec-numeric-types-number-lessThan">
<h1>Number::lessThan ( _x_, _y_ )</h1>
<p>The abstract operation Number::lessThan takes arguments _x_ (a Number) and _y_ (a Number). It performs the following steps when called:</p>
<emu-alg>
1. If _x_ is *NaN*, return *undefined*.
1. If _y_ is *NaN*, return *undefined*.
Expand All @@ -1717,6 +1729,7 @@ <h1>Number::lessThan ( _x_, _y_ )</h1>

<emu-clause id="sec-numeric-types-number-equal">
<h1>Number::equal ( _x_, _y_ )</h1>
<p>The abstract operation Number::equal takes arguments _x_ (a Number) and _y_ (a Number). It performs the following steps when called:</p>
<emu-alg>
1. If _x_ is *NaN*, return *false*.
1. If _y_ is *NaN*, return *false*.
Expand All @@ -1729,6 +1742,7 @@ <h1>Number::equal ( _x_, _y_ )</h1>

<emu-clause id="sec-numeric-types-number-sameValue">
<h1>Number::sameValue ( _x_, _y_ )</h1>
<p>The abstract operation Number::sameValue takes arguments _x_ (a Number) and _y_ (a Number). It performs the following steps when called:</p>
<emu-alg>
1. If _x_ is *NaN* and _y_ is *NaN*, return *true*.
1. If _x_ is *+0* and _y_ is *-0*, return *false*.
Expand All @@ -1740,6 +1754,7 @@ <h1>Number::sameValue ( _x_, _y_ )</h1>

<emu-clause id="sec-numeric-types-number-sameValueZero">
<h1>Number::sameValueZero ( _x_, _y_ )</h1>
<p>The abstract operation Number::sameValueZero takes arguments _x_ (a Number) and _y_ (a Number). It performs the following steps when called:</p>
<emu-alg>
1. If _x_ is *NaN* and _y_ is *NaN*, return *true*.
1. If _x_ is *+0* and _y_ is *-0*, return *true*.
Expand All @@ -1761,20 +1776,23 @@ <h1>NumberBitwiseOp ( _op_, _x_, _y_ )</h1>

<emu-clause id="sec-numeric-types-number-bitwiseAND">
<h1>Number::bitwiseAND ( _x_, _y_ )</h1>
<p>The abstract operation Number::bitwiseAND takes arguments _x_ (a Number) and _y_ (a Number). It performs the following steps when called:</p>
<emu-alg>
1. Return NumberBitwiseOp(`&amp;`, _x_, _y_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-numeric-types-number-bitwiseXOR">
<h1>Number::bitwiseXOR ( _x_, _y_ )</h1>
<p>The abstract operation Number::bitwiseXOR takes arguments _x_ (a Number) and _y_ (a Number). It performs the following steps when called:</p>
<emu-alg>
1. Return NumberBitwiseOp(`^`, _x_, _y_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-numeric-types-number-bitwiseOR">
<h1>Number::bitwiseOR ( _x_, _y_ )</h1>
<p>The abstract operation Number::bitwiseOR takes arguments _x_ (a Number) and _y_ (a Number). It performs the following steps when called:</p>
<emu-alg>
1. Return NumberBitwiseOp(`|`, _x_, _y_).
</emu-alg>
Expand Down Expand Up @@ -1852,6 +1870,7 @@ <h1>The BigInt Type</h1>

<emu-clause id="sec-numeric-types-bigint-unaryMinus">
<h1>BigInt::unaryMinus ( _x_ )</h1>
<p>The abstract operation BigInt::unaryMinus takes argument _x_ (a BigInt). It performs the following steps when called:</p>
<emu-alg>
1. If _x_ is *0n*, return *0n*.
1. Return the BigInt value that represents the mathematical value of negating _x_.
Expand All @@ -1865,6 +1884,7 @@ <h1>BigInt::bitwiseNOT ( _x_ )</h1>

<emu-clause id="sec-numeric-types-bigint-exponentiate">
<h1>BigInt::exponentiate ( _base_, _exponent_ )</h1>
<p>The abstract operation BigInt::exponentiate takes arguments _base_ (a BigInt) and _exponent_ (a BigInt). It performs the following steps when called:</p>
<emu-alg>
1. If _exponent_ &lt; *0n*, throw a *RangeError* exception.
1. If _base_ is *0n* and _exponent_ is *0n*, return *1n*.
Expand All @@ -1880,6 +1900,7 @@ <h1>BigInt::multiply ( _x_, _y_ )</h1>

<emu-clause id="sec-numeric-types-bigint-divide">
<h1>BigInt::divide ( _x_, _y_ )</h1>
<p>The abstract operation BigInt::divide takes arguments _x_ (a BigInt) and _y_ (a BigInt). It performs the following steps when called:</p>
<emu-alg>
1. If _y_ is *0n*, throw a *RangeError* exception.
1. Let _quotient_ be the mathematical value of _x_ divided by _y_.
Expand All @@ -1889,6 +1910,7 @@ <h1>BigInt::divide ( _x_, _y_ )</h1>

<emu-clause id="sec-numeric-types-bigint-remainder">
<h1>BigInt::remainder ( _n_, _d_ )</h1>
<p>The abstract operation BigInt::remainder takes arguments _n_ (a BigInt) and _d_ (a BigInt). It performs the following steps when called:</p>
<emu-alg>
1. If _d_ is *0n*, throw a *RangeError* exception.
1. If _n_ is *0n*, return *0n*.
Expand Down Expand Up @@ -2027,20 +2049,23 @@ <h1>BigIntBitwiseOp ( _op_, _x_, _y_ )</h1>

<emu-clause id="sec-numeric-types-bigint-bitwiseAND">
<h1>BigInt::bitwiseAND ( _x_, _y_ )</h1>
<p>The abstract operation BigInt::bitwiseAND takes arguments _x_ (a BigInt) and _y_ (a BigInt). It performs the following steps when called:</p>
<emu-alg>
1. Return BigIntBitwiseOp(*"&amp;"*, _x_, _y_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-numeric-types-bigint-bitwiseXOR">
<h1>BigInt::bitwiseXOR ( _x_, _y_ )</h1>
<p>The abstract operation BigInt::bitwiseXOR takes arguments _x_ (a BigInt) and _y_ (a BigInt). It performs the following steps when called:</p>
<emu-alg>
1. Return BigIntBitwiseOp(*"^"*, _x_, _y_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-numeric-types-bigint-bitwiseOR">
<h1>BigInt::bitwiseOR ( _x_, _y_ )</h1>
<p>The abstract operation BigInt::bitwiseOR takes arguments _x_ (a BigInt) and _y_ (a BigInt). It performs the following steps when called:</p>
<emu-alg>
1. Return BigIntBitwiseOp(*"|"*, _x_, _y_).
</emu-alg>
Expand Down Expand Up @@ -14566,6 +14591,13 @@ <h2>Syntax</h2>
MultiplicativeOperator : one of
`*` `/` `%`
</emu-grammar>
<emu-note>
<ul>
<li>The `*` operator performs multiplication, producing the product of its operands.</li>
<li>The `/` operator performs division, producing the quotient of its operands.</li>
<li>The `%` operator yields the remainder of its operands from an implied division.</li>
</ul>
</emu-note>

<emu-clause id="sec-multiplicative-operators-static-semantics-isfunctiondefinition">
<h1>Static Semantics: IsFunctionDefinition</h1>
Expand Down Expand Up @@ -14648,6 +14680,9 @@ <h1>Runtime Semantics: Evaluation</h1>

<emu-clause id="sec-subtraction-operator-minus">
<h1>The Subtraction Operator ( `-` )</h1>
<emu-note>
<p>The `-` operator performs subtraction, producing the difference of its operands.</p>
</emu-note>

<emu-clause id="sec-subtraction-operator-minus-runtime-semantics-evaluation">
<h1>Runtime Semantics: Evaluation</h1>
Expand Down