Skip to content

Commit

Permalink
Normative: require Number::exponentiate to return a Number value (#2523)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelficarra authored and ljharb committed Oct 15, 2021
1 parent 7564234 commit 01a6d27
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,7 @@ <h1>
1. If abs(ℝ(_base_)) &lt; 1, return *+&infin;*<sub>𝔽</sub>.
1. Assert: _exponent_ is finite and is neither *+0*<sub>𝔽</sub> nor *-0*<sub>𝔽</sub>.
1. If _base_ &lt; *+0*<sub>𝔽</sub> and _exponent_ is not an integral Number, return *NaN*.
1. Return an implementation-approximated value representing the result of raising ℝ(_base_) to the ℝ(_exponent_) power.
1. Return an implementation-approximated Number value representing the result of raising ℝ(_base_) to the ℝ(_exponent_) power.
</emu-alg>
<emu-note>
<p>The result of _base_ `**` _exponent_ when _base_ is *1*<sub>𝔽</sub> or *-1*<sub>𝔽</sub> and _exponent_ is *+&infin;*<sub>𝔽</sub> or *-&infin;*<sub>𝔽</sub>, or when _base_ is *1*<sub>𝔽</sub> and _exponent_ is *NaN*, differs from IEEE 754-2019. The first edition of ECMAScript specified a result of *NaN* for this operation, whereas later versions of IEEE 754-2019 specified *1*<sub>𝔽</sub>. The historical ECMAScript behaviour is preserved for compatibility reasons.</p>
Expand Down Expand Up @@ -28662,7 +28662,7 @@ <h1>parseInt ( _string_, _radix_ )</h1>
1. If _S_ contains a code unit that is not a radix-_R_ digit, let _end_ be the index within _S_ of the first such code unit; otherwise, let _end_ be the length of _S_.
1. Let _Z_ be the substring of _S_ from 0 to _end_.
1. If _Z_ is empty, return *NaN*.
1. Let _mathInt_ be the integer value that is represented by _Z_ in radix-_R_ notation, using the letters <b>A</b>-<b>Z</b> and <b>a</b>-<b>z</b> for digits with values 10 through 35. (However, if _R_ is 10 and _Z_ contains more than 20 significant digits, every significant digit after the 20th may be replaced by a 0 digit, at the option of the implementation; and if _R_ is not 2, 4, 8, 10, 16, or 32, then _mathInt_ may be an implementation-approximated value representing the integer value that is represented by _Z_ in radix-_R_ notation.)
1. Let _mathInt_ be the integer value that is represented by _Z_ in radix-_R_ notation, using the letters <b>A</b>-<b>Z</b> and <b>a</b>-<b>z</b> for digits with values 10 through 35. (However, if _R_ is 10 and _Z_ contains more than 20 significant digits, every significant digit after the 20th may be replaced by a 0 digit, at the option of the implementation; and if _R_ is not 2, 4, 8, 10, 16, or 32, then _mathInt_ may be an implementation-approximated integer representing the integer value denoted by _Z_ in radix-_R_ notation.)
1. If _mathInt_ = 0, then
1. If _sign_ = -1, return *-0*<sub>𝔽</sub>.
1. Return *+0*<sub>𝔽</sub>.
Expand Down Expand Up @@ -31237,7 +31237,7 @@ <h1>Math.acos ( _x_ )</h1>
1. Let _n_ be ? ToNumber(_x_).
1. If _n_ is *NaN*, _n_ &gt; *1*<sub>𝔽</sub>, or _n_ &lt; *-1*<sub>𝔽</sub>, return *NaN*.
1. If _n_ is *1*<sub>𝔽</sub>, return *+0*<sub>𝔽</sub>.
1. Return an implementation-approximated value representing the result of the inverse cosine of ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of the inverse cosine of ℝ(_n_).
</emu-alg>
</emu-clause>

Expand All @@ -31250,7 +31250,7 @@ <h1>Math.acosh ( _x_ )</h1>
1. If _n_ is *NaN* or _n_ is *+&infin;*<sub>𝔽</sub>, return _n_.
1. If _n_ is *1*<sub>𝔽</sub>, return *+0*<sub>𝔽</sub>.
1. If _n_ &lt; *1*<sub>𝔽</sub>, return *NaN*.
1. Return an implementation-approximated value representing the result of the inverse hyperbolic cosine of ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of the inverse hyperbolic cosine of ℝ(_n_).
</emu-alg>
</emu-clause>

Expand All @@ -31262,7 +31262,7 @@ <h1>Math.asin ( _x_ )</h1>
1. Let _n_ be ? ToNumber(_x_).
1. If _n_ is *NaN*, _n_ is *+0*<sub>𝔽</sub>, or _n_ is *-0*<sub>𝔽</sub>, return _n_.
1. If _n_ &gt; *1*<sub>𝔽</sub> or _n_ &lt; *-1*<sub>𝔽</sub>, return *NaN*.
1. Return an implementation-approximated value representing the result of the inverse sine of ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of the inverse sine of ℝ(_n_).
</emu-alg>
</emu-clause>

Expand All @@ -31273,7 +31273,7 @@ <h1>Math.asinh ( _x_ )</h1>
<emu-alg>
1. Let _n_ be ? ToNumber(_x_).
1. If _n_ is *NaN*, _n_ is *+0*<sub>𝔽</sub>, _n_ is *-0*<sub>𝔽</sub>, _n_ is *+&infin;*<sub>𝔽</sub>, or _n_ is *-&infin;*<sub>𝔽</sub>, return _n_.
1. Return an implementation-approximated value representing the result of the inverse hyperbolic sine of ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of the inverse hyperbolic sine of ℝ(_n_).
</emu-alg>
</emu-clause>

Expand All @@ -31284,9 +31284,9 @@ <h1>Math.atan ( _x_ )</h1>
<emu-alg>
1. Let _n_ be ? ToNumber(_x_).
1. If _n_ is *NaN*, _n_ is *+0*<sub>𝔽</sub>, or _n_ is *-0*<sub>𝔽</sub>, return _n_.
1. If _n_ is *+&infin;*<sub>𝔽</sub>, return an implementation-approximated value representing &pi; / 2.
1. If _n_ is *-&infin;*<sub>𝔽</sub>, return an implementation-approximated value representing -&pi; / 2.
1. Return an implementation-approximated value representing the result of the inverse tangent of ℝ(_n_).
1. If _n_ is *+&infin;*<sub>𝔽</sub>, return an implementation-approximated Number value representing &pi; / 2.
1. If _n_ is *-&infin;*<sub>𝔽</sub>, return an implementation-approximated Number value representing -&pi; / 2.
1. Return an implementation-approximated Number value representing the result of the inverse tangent of ℝ(_n_).
</emu-alg>
</emu-clause>

Expand All @@ -31300,7 +31300,7 @@ <h1>Math.atanh ( _x_ )</h1>
1. If _n_ &gt; *1*<sub>𝔽</sub> or _n_ &lt; *-1*<sub>𝔽</sub>, return *NaN*.
1. If _n_ is *1*<sub>𝔽</sub>, return *+&infin;*<sub>𝔽</sub>.
1. If _n_ is *-1*<sub>𝔽</sub>, return *-&infin;*<sub>𝔽</sub>.
1. Return an implementation-approximated value representing the result of the inverse hyperbolic tangent of ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of the inverse hyperbolic tangent of ℝ(_n_).
</emu-alg>
</emu-clause>

Expand All @@ -31313,30 +31313,30 @@ <h1>Math.atan2 ( _y_, _x_ )</h1>
1. Let _nx_ be ? ToNumber(_x_).
1. If _ny_ is *NaN* or _nx_ is *NaN*, return *NaN*.
1. If _ny_ is *+&infin;*<sub>𝔽</sub>, then
1. If _nx_ is *+&infin;*<sub>𝔽</sub>, return an implementation-approximated value representing &pi; / 4.
1. If _nx_ is *-&infin;*<sub>𝔽</sub>, return an implementation-approximated value representing 3&pi; / 4.
1. Return an implementation-approximated value representing &pi; / 2.
1. If _nx_ is *+&infin;*<sub>𝔽</sub>, return an implementation-approximated Number value representing &pi; / 4.
1. If _nx_ is *-&infin;*<sub>𝔽</sub>, return an implementation-approximated Number value representing 3&pi; / 4.
1. Return an implementation-approximated Number value representing &pi; / 2.
1. If _ny_ is *-&infin;*<sub>𝔽</sub>, then
1. If _nx_ is *+&infin;*<sub>𝔽</sub>, return an implementation-approximated value representing -&pi; / 4.
1. If _nx_ is *-&infin;*<sub>𝔽</sub>, return an implementation-approximated value representing -3&pi; / 4.
1. Return an implementation-approximated value representing -&pi; / 2.
1. If _nx_ is *+&infin;*<sub>𝔽</sub>, return an implementation-approximated Number value representing -&pi; / 4.
1. If _nx_ is *-&infin;*<sub>𝔽</sub>, return an implementation-approximated Number value representing -3&pi; / 4.
1. Return an implementation-approximated Number value representing -&pi; / 2.
1. If _ny_ is *+0*<sub>𝔽</sub>, then
1. If _nx_ &gt; *+0*<sub>𝔽</sub> or _nx_ is *+0*<sub>𝔽</sub>, return *+0*<sub>𝔽</sub>.
1. Return an implementation-approximated value representing &pi;.
1. Return an implementation-approximated Number value representing &pi;.
1. If _ny_ is *-0*<sub>𝔽</sub>, then
1. If _nx_ &gt; *+0*<sub>𝔽</sub> or _nx_ is *+0*<sub>𝔽</sub>, return *-0*<sub>𝔽</sub>.
1. Return an implementation-approximated value representing -&pi;.
1. Return an implementation-approximated Number value representing -&pi;.
1. Assert: _ny_ is finite and is neither *+0*<sub>𝔽</sub> nor *-0*<sub>𝔽</sub>.
1. If _ny_ &gt; *+0*<sub>𝔽</sub>, then
1. If _nx_ is *+&infin;*<sub>𝔽</sub>, return *+0*<sub>𝔽</sub>.
1. If _nx_ is *-&infin;*<sub>𝔽</sub>, return an implementation-approximated value representing &pi;.
1. If _nx_ is *+0*<sub>𝔽</sub> or _nx_ is *-0*<sub>𝔽</sub>, return an implementation-approximated value representing &pi; / 2.
1. If _nx_ is *-&infin;*<sub>𝔽</sub>, return an implementation-approximated Number value representing &pi;.
1. If _nx_ is *+0*<sub>𝔽</sub> or _nx_ is *-0*<sub>𝔽</sub>, return an implementation-approximated Number value representing &pi; / 2.
1. If _ny_ &lt; *+0*<sub>𝔽</sub>, then
1. If _nx_ is *+&infin;*<sub>𝔽</sub>, return *-0*<sub>𝔽</sub>.
1. If _nx_ is *-&infin;*<sub>𝔽</sub>, return an implementation-approximated value representing -&pi;.
1. If _nx_ is *+0*<sub>𝔽</sub> or _nx_ is *-0*<sub>𝔽</sub>, return an implementation-approximated value representing -&pi; / 2.
1. If _nx_ is *-&infin;*<sub>𝔽</sub>, return an implementation-approximated Number value representing -&pi;.
1. If _nx_ is *+0*<sub>𝔽</sub> or _nx_ is *-0*<sub>𝔽</sub>, return an implementation-approximated Number value representing -&pi; / 2.
1. Assert: _nx_ is finite and is neither *+0*<sub>𝔽</sub> nor *-0*<sub>𝔽</sub>.
1. Return an implementation-approximated value representing the result of the inverse tangent of the quotient ℝ(_ny_) / ℝ(_nx_).
1. Return an implementation-approximated Number value representing the result of the inverse tangent of the quotient ℝ(_ny_) / ℝ(_nx_).
</emu-alg>
</emu-clause>

Expand All @@ -31347,7 +31347,7 @@ <h1>Math.cbrt ( _x_ )</h1>
<emu-alg>
1. Let _n_ be ? ToNumber(_x_).
1. If _n_ is *NaN*, _n_ is *+0*<sub>𝔽</sub>, _n_ is *-0*<sub>𝔽</sub>, _n_ is *+&infin;*<sub>𝔽</sub>, or _n_ is *-&infin;*<sub>𝔽</sub>, return _n_.
1. Return an implementation-approximated value representing the result of the cube root of ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of the cube root of ℝ(_n_).
</emu-alg>
</emu-clause>

Expand Down Expand Up @@ -31388,7 +31388,7 @@ <h1>Math.cos ( _x_ )</h1>
1. Let _n_ be ? ToNumber(_x_).
1. If _n_ is *NaN*, _n_ is *+&infin;*<sub>𝔽</sub>, or _n_ is *-&infin;*<sub>𝔽</sub>, return *NaN*.
1. If _n_ is *+0*<sub>𝔽</sub> or _n_ is *-0*<sub>𝔽</sub>, return *1*<sub>𝔽</sub>.
1. Return an implementation-approximated value representing the result of the cosine of ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of the cosine of ℝ(_n_).
</emu-alg>
</emu-clause>

Expand All @@ -31401,7 +31401,7 @@ <h1>Math.cosh ( _x_ )</h1>
1. If _n_ is *NaN*, return *NaN*.
1. If _n_ is *+&infin;*<sub>𝔽</sub> or _n_ is *-&infin;*<sub>𝔽</sub>, return *+&infin;*<sub>𝔽</sub>.
1. If _n_ is *+0*<sub>𝔽</sub> or _n_ is *-0*<sub>𝔽</sub>, return *1*<sub>𝔽</sub>.
1. Return an implementation-approximated value representing the result of the hyperbolic cosine of ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of the hyperbolic cosine of ℝ(_n_).
</emu-alg>
<emu-note>
<p>The value of `Math.cosh(x)` is the same as the value of `(Math.exp(x) + Math.exp(-x)) / 2`.</p>
Expand All @@ -31417,7 +31417,7 @@ <h1>Math.exp ( _x_ )</h1>
1. If _n_ is *NaN* or _n_ is *+&infin;*<sub>𝔽</sub>, return _n_.
1. If _n_ is *+0*<sub>𝔽</sub> or _n_ is *-0*<sub>𝔽</sub>, return *1*<sub>𝔽</sub>.
1. If _n_ is *-&infin;*<sub>𝔽</sub>, return *+0*<sub>𝔽</sub>.
1. Return an implementation-approximated value representing the result of the exponential function of ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of the exponential function of ℝ(_n_).
</emu-alg>
</emu-clause>

Expand All @@ -31429,7 +31429,7 @@ <h1>Math.expm1 ( _x_ )</h1>
1. Let _n_ be ? ToNumber(_x_).
1. If _n_ is *NaN*, _n_ is *+0*<sub>𝔽</sub>, _n_ is *-0*<sub>𝔽</sub>, or _n_ is *+&infin;*<sub>𝔽</sub>, return _n_.
1. If _n_ is *-&infin;*<sub>𝔽</sub>, return *-1*<sub>𝔽</sub>.
1. Return an implementation-approximated value representing the result of subtracting 1 from the exponential function of ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of subtracting 1 from the exponential function of ℝ(_n_).
</emu-alg>
</emu-clause>

Expand Down Expand Up @@ -31478,7 +31478,7 @@ <h1>Math.hypot ( ..._args_ )</h1>
1. If _number_ is *NaN*, return *NaN*.
1. If _number_ is neither *+0*<sub>𝔽</sub> nor *-0*<sub>𝔽</sub>, set _onlyZero_ to *false*.
1. If _onlyZero_ is *true*, return *+0*<sub>𝔽</sub>.
1. Return an implementation-approximated value representing the square root of the sum of squares of the mathematical values of the elements of _coerced_.
1. Return an implementation-approximated Number value representing the square root of the sum of squares of the mathematical values of the elements of _coerced_.
</emu-alg>
<p>The *"length"* property of the `hypot` method is *2*<sub>𝔽</sub>.</p>
<emu-note>
Expand Down Expand Up @@ -31507,7 +31507,7 @@ <h1>Math.log ( _x_ )</h1>
1. If _n_ is *1*<sub>𝔽</sub>, return *+0*<sub>𝔽</sub>.
1. If _n_ is *+0*<sub>𝔽</sub> or _n_ is *-0*<sub>𝔽</sub>, return *-&infin;*<sub>𝔽</sub>.
1. If _n_ &lt; *+0*<sub>𝔽</sub>, return *NaN*.
1. Return an implementation-approximated value representing the result of the natural logarithm of ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of the natural logarithm of ℝ(_n_).
</emu-alg>
</emu-clause>

Expand All @@ -31520,7 +31520,7 @@ <h1>Math.log1p ( _x_ )</h1>
1. If _n_ is *NaN*, _n_ is *+0*<sub>𝔽</sub>, _n_ is *-0*<sub>𝔽</sub>, or _n_ is *+&infin;*<sub>𝔽</sub>, return _n_.
1. If _n_ is *-1*<sub>𝔽</sub>, return *-&infin;*<sub>𝔽</sub>.
1. If _n_ &lt; *-1*<sub>𝔽</sub>, return *NaN*.
1. Return an implementation-approximated value representing the result of the natural logarithm of 1 + ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of the natural logarithm of 1 + ℝ(_n_).
</emu-alg>
</emu-clause>

Expand All @@ -31534,7 +31534,7 @@ <h1>Math.log10 ( _x_ )</h1>
1. If _n_ is *1*<sub>𝔽</sub>, return *+0*<sub>𝔽</sub>.
1. If _n_ is *+0*<sub>𝔽</sub> or _n_ is *-0*<sub>𝔽</sub>, return *-&infin;*<sub>𝔽</sub>.
1. If _n_ &lt; *+0*<sub>𝔽</sub>, return *NaN*.
1. Return an implementation-approximated value representing the result of the base 10 logarithm of ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of the base 10 logarithm of ℝ(_n_).
</emu-alg>
</emu-clause>

Expand All @@ -31548,7 +31548,7 @@ <h1>Math.log2 ( _x_ )</h1>
1. If _n_ is *1*<sub>𝔽</sub>, return *+0*<sub>𝔽</sub>.
1. If _n_ is *+0*<sub>𝔽</sub> or _n_ is *-0*<sub>𝔽</sub>, return *-&infin;*<sub>𝔽</sub>.
1. If _n_ &lt; *+0*<sub>𝔽</sub>, return *NaN*.
1. Return an implementation-approximated value representing the result of the base 2 logarithm of ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of the base 2 logarithm of ℝ(_n_).
</emu-alg>
</emu-clause>

Expand Down Expand Up @@ -31651,7 +31651,7 @@ <h1>Math.sin ( _x_ )</h1>
1. Let _n_ be ? ToNumber(_x_).
1. If _n_ is *NaN*, _n_ is *+0*<sub>𝔽</sub>, or _n_ is *-0*<sub>𝔽</sub>, return _n_.
1. If _n_ is *+&infin;*<sub>𝔽</sub> or _n_ is *-&infin;*<sub>𝔽</sub>, return *NaN*.
1. Return an implementation-approximated value representing the result of the sine of ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of the sine of ℝ(_n_).
</emu-alg>
</emu-clause>

Expand All @@ -31662,7 +31662,7 @@ <h1>Math.sinh ( _x_ )</h1>
<emu-alg>
1. Let _n_ be ? ToNumber(_x_).
1. If _n_ is *NaN*, _n_ is *+0*<sub>𝔽</sub>, _n_ is *-0*<sub>𝔽</sub>, _n_ is *+&infin;*<sub>𝔽</sub>, or _n_ is *-&infin;*<sub>𝔽</sub>, return _n_.
1. Return an implementation-approximated value representing the result of the hyperbolic sine of ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of the hyperbolic sine of ℝ(_n_).
</emu-alg>
<emu-note>
<p>The value of `Math.sinh(x)` is the same as the value of `(Math.exp(x) - Math.exp(-x)) / 2`.</p>
Expand All @@ -31677,7 +31677,7 @@ <h1>Math.sqrt ( _x_ )</h1>
1. Let _n_ be ? ToNumber(_x_).
1. If _n_ is *NaN*, _n_ is *+0*<sub>𝔽</sub>, _n_ is *-0*<sub>𝔽</sub>, or _n_ is *+&infin;*<sub>𝔽</sub>, return _n_.
1. If _n_ &lt; *+0*<sub>𝔽</sub>, return *NaN*.
1. Return an implementation-approximated value representing the result of the square root of ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of the square root of ℝ(_n_).
</emu-alg>
</emu-clause>

Expand All @@ -31689,7 +31689,7 @@ <h1>Math.tan ( _x_ )</h1>
1. Let _n_ be ? ToNumber(_x_).
1. If _n_ is *NaN*, _n_ is *+0*<sub>𝔽</sub>, or _n_ is *-0*<sub>𝔽</sub>, return _n_.
1. If _n_ is *+&infin;*<sub>𝔽</sub>, or _n_ is *-&infin;*<sub>𝔽</sub>, return *NaN*.
1. Return an implementation-approximated value representing the result of the tangent of ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of the tangent of ℝ(_n_).
</emu-alg>
</emu-clause>

Expand All @@ -31702,7 +31702,7 @@ <h1>Math.tanh ( _x_ )</h1>
1. If _n_ is *NaN*, _n_ is *+0*<sub>𝔽</sub>, or _n_ is *-0*<sub>𝔽</sub>, return _n_.
1. If _n_ is *+&infin;*<sub>𝔽</sub>, return *1*<sub>𝔽</sub>.
1. If _n_ is *-&infin;*<sub>𝔽</sub>, return *-1*<sub>𝔽</sub>.
1. Return an implementation-approximated value representing the result of the hyperbolic tangent of ℝ(_n_).
1. Return an implementation-approximated Number value representing the result of the hyperbolic tangent of ℝ(_n_).
</emu-alg>
<emu-note>
<p>The value of `Math.tanh(x)` is the same as the value of `(Math.exp(x) - Math.exp(-x)) / (Math.exp(x) + Math.exp(-x))`.</p>
Expand Down

0 comments on commit 01a6d27

Please sign in to comment.