Skip to content
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
39 changes: 16 additions & 23 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -1963,17 +1963,11 @@ <h1>The Number Type</h1>
<p>There are two other special values, called *positive Infinity* and *negative Infinity*. For brevity, these values are also referred to for expository purposes by the symbols *+∞*<sub>𝔽</sub> and *-∞*<sub>𝔽</sub>, respectively. (Note that these two infinite Number values are produced by the program expressions `+Infinity` (or simply `Infinity`) and `-Infinity`.)</p>
<p>Each of the other 18,437,736,874,454,810,624 (that is, <emu-eqn>2<sup>64</sup> - 2<sup>53</sup></emu-eqn>) values is a <dfn id="finite-number" variants="finite Numbers" oldids="finite">finite Number</dfn>. Half of these are positive numbers and half are negative numbers; for every positive finite Number, there is a corresponding negative Number having the same magnitude.</p>
<p>Note that there is both a *positive zero* and a *negative zero*. For brevity, these values are also referred to for expository purposes by the symbols *+0*<sub>𝔽</sub> and *-0*<sub>𝔽</sub>, respectively. (Note that these two different zero Number values are produced by the program expressions `+0` (or simply `0`) and `-0`.)</p>
<p>The 18,437,736,874,454,810,622 (that is, <emu-eqn>2<sup>64</sup> - 2<sup>53</sup> - 2</emu-eqn>) finite non-zero values are of two kinds:</p>
<p>18,428,729,675,200,069,632 (that is, <emu-eqn>2<sup>64</sup> - 2<sup>54</sup></emu-eqn>) of them are normalized, having the form</p>
<div class="math-display">
_s_ × _m_ × 2<sup>_e_</sup>
</div>
<p>where _s_ is 1 or -1, _m_ is an integer in the interval from 2<sup>52</sup> (inclusive) to 2<sup>53</sup> (exclusive), and _e_ is an integer in the inclusive interval from -1074 to 971.</p>
<p>The remaining 9,007,199,254,740,990 (that is, <emu-eqn>2<sup>53</sup> - 2</emu-eqn>) values are denormalized, having the form</p>
<div class="math-display">
_s_ × _m_ × 2<sup>_e_</sup>
</div>
<p>where _s_ is 1 or -1, _m_ is an integer in the interval from 0 (exclusive) to 2<sup>52</sup> (exclusive), and _e_ is -1074.</p>
<p>The 18,437,736,874,454,810,622 (that is, <emu-eqn>2<sup>64</sup> - 2<sup>53</sup> - 2</emu-eqn>) <dfn id="non-zero-finite-number" variants="non-zero finite Number,finite non-zero Number,finite non-zero Numbers">non-zero finite Numbers</dfn> are partitioned into two groups, based on integers _m_ and _e_ in their corresponding mathematical value <emu-eqn>_s_ × _m_ × 2<sup>_e_</sup></emu-eqn>, where _s_ is 1 or -1:</p>
<ul>
<li>18,428,729,675,200,069,632 (that is, <emu-eqn>2<sup>64</sup> - 2<sup>54</sup></emu-eqn>) of them are “normalized”: _m_ is an integer in the interval from 2<sup>52</sup> (inclusive) to 2<sup>53</sup> (exclusive), and _e_ is an integer in the inclusive interval from -1074 to 971.</li>
<li>The remaining 9,007,199,254,740,990 (that is, <emu-eqn>2<sup>53</sup> - 2</emu-eqn>) are “denormalized” and more specifically “subnormal”: _m_ is an integer in the interval from 0 (exclusive) to 2<sup>52</sup> (exclusive), and _e_ is -1074.</li>
</ul>
<p>Note that all the positive and negative integers whose magnitude is no greater than 2<sup>53</sup> are representable in the Number type. The integer 0 has two representations in the Number type: *+0*<sub>𝔽</sub> and *-0*<sub>𝔽</sub>.</p>
<p>A finite Number has an <em>odd significand</em> if it is non-zero and the integer _m_ used to express it (in one of the two forms shown above) is odd. Otherwise, it has an <em>even significand</em>.</p>
<p>In this specification, the phrase “the <dfn id="number-value-for" oldids="number-value">Number value for</dfn> _x_” where _x_ represents an exact real mathematical quantity (which might even be an irrational number such as π) means a Number value chosen in the following manner. Consider the set consisting of the union of all finite Numbers except *-0*<sub>𝔽</sub> with two additional values that are not representable in the Number type, namely 2<sup>1024</sup> (which is <emu-eqn>+1 × 2<sup>53</sup> × 2<sup>971</sup></emu-eqn>) and <emu-eqn>-2<sup>1024</sup></emu-eqn> (which is <emu-eqn>-1 × 2<sup>53</sup> × 2<sup>971</sup></emu-eqn>). Choose the member of this set that is closest in value to _x_. If two values of the set are equally close, then the one with an even significand is chosen; for this purpose, the two extra values 2<sup>1024</sup> and <emu-eqn>-2<sup>1024</sup></emu-eqn> are considered to have even significands. Finally, if 2<sup>1024</sup> was chosen, replace it with *+∞*<sub>𝔽</sub>; if <emu-eqn>-2<sup>1024</sup></emu-eqn> was chosen, replace it with *-∞*<sub>𝔽</sub>; if *+0*<sub>𝔽</sub> was chosen, replace it with *-0*<sub>𝔽</sub> if and only if _x_ &lt; 0; any other chosen value is used unchanged. The result is the Number value for _x_. (This procedure corresponds exactly to the behaviour of the IEEE 754-2019 roundTiesToEven mode.)</p>
Expand Down Expand Up @@ -2041,7 +2035,7 @@ <h1>
1. Return *+0*<sub>𝔽</sub>.
1. If _exponent_ is an odd integral Number, return *-∞*<sub>𝔽</sub>.
1. Return *+∞*<sub>𝔽</sub>.
1. Assert: _base_ is a finite Number and is neither *+0*<sub>𝔽</sub> nor *-0*<sub>𝔽</sub>.
1. Assert: _base_ is a non-zero finite Number.
1. If _exponent_ is *+∞*<sub>𝔽</sub>, then
1. If abs(ℝ(_base_)) > 1, return *+∞*<sub>𝔽</sub>.
1. If abs(ℝ(_base_)) = 1, return *NaN*.
Expand All @@ -2050,7 +2044,7 @@ <h1>
1. If abs(ℝ(_base_)) > 1, return *+0*<sub>𝔽</sub>.
1. If abs(ℝ(_base_)) = 1, return *NaN*.
1. Return *+∞*<sub>𝔽</sub>.
1. Assert: _exponent_ is a finite Number and is neither *+0*<sub>𝔽</sub> nor *-0*<sub>𝔽</sub>.
1. Assert: _exponent_ is a non-zero finite Number.
1. If _base_ &lt; *-0*<sub>𝔽</sub> and _exponent_ is not an integral Number, return *NaN*.
1. Return an implementation-approximated Number value representing the result of raising ℝ(_base_) to the ℝ(_exponent_) power.
</emu-alg>
Expand Down Expand Up @@ -2147,8 +2141,7 @@ <h1>
1. If _denominator_ is either *+∞*<sub>𝔽</sub> or *-∞*<sub>𝔽</sub>, return _numerator_.
1. If _denominator_ is either *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub>, return *NaN*.
1. If _numerator_ is either *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub>, return _numerator_.
1. Assert: _numerator_ is a finite Number and is neither *+0*<sub>𝔽</sub> nor *-0*<sub>𝔽</sub>.
1. Assert: _denominator_ is a finite Number and is neither *+0*<sub>𝔽</sub> nor *-0*<sub>𝔽</sub>.
1. Assert: _numerator_ and _denominator_ are non-zero finite Numbers.
1. Let _quotient_ be ℝ(_numerator_) / ℝ(_denominator_).
1. Let _truncatedQuotient_ be truncate(_quotient_).
1. Let _remainder_ be ℝ(_numerator_) - (ℝ(_denominator_) × _truncatedQuotient_).
Expand Down Expand Up @@ -33463,7 +33456,7 @@ <h1>Math.asinh ( _x_ )</h1>
<p>It performs the following steps when called:</p>
<emu-alg>
1. Let _n_ be ? ToNumber(_x_).
1. If _n_ is not a finite Number or _n_ is either *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub>, return _n_.
1. If _n_ is not a non-zero finite Number, return _n_.
1. Return an implementation-approximated Number value representing the inverse hyperbolic sine of ℝ(_n_).
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -33517,7 +33510,7 @@ <h1>Math.atan2 ( _y_, _x_ )</h1>
1. If _ny_ is *-0*<sub>𝔽</sub>, then
1. If _nx_ > *+0*<sub>𝔽</sub> or _nx_ is *+0*<sub>𝔽</sub>, return *-0*<sub>𝔽</sub>.
1. Return an implementation-approximated Number value representing -π.
1. Assert: _ny_ is a finite Number and is neither *+0*<sub>𝔽</sub> nor *-0*<sub>𝔽</sub>.
1. Assert: _ny_ is a non-zero finite Number.
1. If _ny_ > *+0*<sub>𝔽</sub>, then
1. If _nx_ is *+∞*<sub>𝔽</sub>, return *+0*<sub>𝔽</sub>.
1. If _nx_ is *-∞*<sub>𝔽</sub>, return an implementation-approximated Number value representing π.
Expand All @@ -33526,7 +33519,7 @@ <h1>Math.atan2 ( _y_, _x_ )</h1>
1. If _nx_ is *+∞*<sub>𝔽</sub>, return *-0*<sub>𝔽</sub>.
1. If _nx_ is *-∞*<sub>𝔽</sub>, return an implementation-approximated Number value representing -π.
1. If _nx_ is either *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub>, return an implementation-approximated Number value representing -π / 2.
1. Assert: _nx_ is a finite Number and is neither *+0*<sub>𝔽</sub> nor *-0*<sub>𝔽</sub>.
1. Assert: _nx_ is a non-zero finite Number.
1. Let _result_ be the inverse tangent of abs(ℝ(_ny_) / ℝ(_nx_)).
1. If _nx_ &lt; *-0*<sub>𝔽</sub>, then
1. If _ny_ > *+0*<sub>𝔽</sub>, set _result_ to π - _result_.
Expand All @@ -33543,7 +33536,7 @@ <h1>Math.cbrt ( _x_ )</h1>
<p>It performs the following steps when called:</p>
<emu-alg>
1. Let _n_ be ? ToNumber(_x_).
1. If _n_ is not a finite Number or _n_ is either *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub>, return _n_.
1. If _n_ is not a non-zero finite Number, return _n_.
1. Return an implementation-approximated Number value representing the cube root of ℝ(_n_).
</emu-alg>
</emu-clause>
Expand All @@ -33554,7 +33547,7 @@ <h1>Math.ceil ( _x_ )</h1>
<p>It performs the following steps when called:</p>
<emu-alg>
1. Let _n_ be ? ToNumber(_x_).
1. If _n_ is not a finite Number or _n_ is either *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub>, return _n_.
1. If _n_ is not a non-zero finite Number, return _n_.
1. If _n_ &lt; *-0*<sub>𝔽</sub> and _n_ > *-1*<sub>𝔽</sub>, return *-0*<sub>𝔽</sub>.
1. If _n_ is an integral Number, return _n_.
1. Return the smallest (closest to -∞) integral Number value that is not less than _n_.
Expand Down Expand Up @@ -33637,7 +33630,7 @@ <h1>Math.floor ( _x_ )</h1>
<p>It performs the following steps when called:</p>
<emu-alg>
1. Let _n_ be ? ToNumber(_x_).
1. If _n_ is not a finite Number or _n_ is either *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub>, return _n_.
1. If _n_ is not a non-zero finite Number, return _n_.
1. If _n_ &lt; *1*<sub>𝔽</sub> and _n_ > *+0*<sub>𝔽</sub>, return *+0*<sub>𝔽</sub>.
1. If _n_ is an integral Number, return _n_.
1. Return the greatest (closest to +∞) integral Number value that is not greater than _n_.
Expand Down Expand Up @@ -33877,7 +33870,7 @@ <h1>Math.sinh ( _x_ )</h1>
<p>It performs the following steps when called:</p>
<emu-alg>
1. Let _n_ be ? ToNumber(_x_).
1. If _n_ is not a finite Number or _n_ is either *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub>, return _n_.
1. If _n_ is not a non-zero finite Number, return _n_.
1. Return an implementation-approximated Number value representing the hyperbolic sine of ℝ(_n_).
</emu-alg>
<emu-note>
Expand Down Expand Up @@ -33977,7 +33970,7 @@ <h1>Math.trunc ( _x_ )</h1>
<p>It performs the following steps when called:</p>
<emu-alg>
1. Let _n_ be ? ToNumber(_x_).
1. If _n_ is not a finite Number or _n_ is either *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub>, return _n_.
1. If _n_ is not a non-zero finite Number, return _n_.
1. If _n_ &lt; *1*<sub>𝔽</sub> and _n_ > *+0*<sub>𝔽</sub>, return *+0*<sub>𝔽</sub>.
1. If _n_ &lt; *-0*<sub>𝔽</sub> and _n_ > *-1*<sub>𝔽</sub>, return *-0*<sub>𝔽</sub>.
1. Return the integral Number nearest _n_ in the direction of *+0*<sub>𝔽</sub>.
Expand Down
Loading