Skip to content

Commit

Permalink
Editorial: comparisons in number stringification are of floats, not r…
Browse files Browse the repository at this point in the history
…eals (#2450)
  • Loading branch information
bakkot authored and ljharb committed Jul 10, 2021
1 parent 66ecf7b commit aafbfe4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ <h1>Number::toString ( _x_ )</h1>
1. If _x_ is *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub>, return the String *"0"*.
1. If _x_ &lt; *+0*<sub>𝔽</sub>, return the string-concatenation of *"-"* and ! Number::toString(-_x_).
1. If _x_ is *+&infin;*<sub>𝔽</sub>, return the String *"Infinity"*.
1. [id="step-number-tostring-intermediate-values"] Otherwise, let _n_, _k_, and _s_ be integers such that _k_ &ge; 1, 10<sup>_k_ - 1</sup> &le; _s_ &lt; 10<sup>_k_</sup>, _s_ &times; 10<sup>_n_ - _k_</sup> is ℝ(_x_), and _k_ is as small as possible. Note that _k_ is the number of digits in the decimal representation of _s_, that _s_ is not divisible by 10, and that the least significant digit of _s_ is not necessarily uniquely determined by these criteria.
1. [id="step-number-tostring-intermediate-values"] Otherwise, let _n_, _k_, and _s_ be integers such that _k_ &ge; 1, 10<sup>_k_ - 1</sup> &le; _s_ &lt; 10<sup>_k_</sup>, 𝔽(_s_ &times; 10<sup>_n_ - _k_</sup>) is _x_, and _k_ is as small as possible. Note that _k_ is the number of digits in the decimal representation of _s_, that _s_ is not divisible by 10, and that the least significant digit of _s_ is not necessarily uniquely determined by these criteria.
1. If _k_ &le; _n_ &le; 21, return the string-concatenation of:
* the code units of the _k_ digits of the decimal representation of _s_ (in order, with no leading zeroes)
* _n_ - _k_ occurrences of the code unit 0x0030 (DIGIT ZERO)
Expand Down Expand Up @@ -1852,7 +1852,7 @@ <h1>Number::toString ( _x_ )</h1>
<emu-note>
<p>For implementations that provide more accurate conversions than required by the rules above, it is recommended that the following alternative version of step <emu-xref href="#step-number-tostring-intermediate-values"></emu-xref> be used as a guideline:</p>
<emu-alg replaces-step="step-number-tostring-intermediate-values">
1. Otherwise, let _n_, _k_, and _s_ be integers such that _k_ &ge; 1, 10<sup>_k_ - 1</sup> &le; _s_ &lt; 10<sup>_k_</sup>, _s_ &times; 10<sup>_n_ - _k_</sup> is ℝ(_x_), and _k_ is as small as possible. If there are multiple possibilities for _s_, choose the value of _s_ for which _s_ &times; 10<sup>_n_ - _k_</sup> is closest in value to ℝ(_x_). If there are two such possible values of _s_, choose the one that is even. Note that _k_ is the number of digits in the decimal representation of _s_ and that _s_ is not divisible by 10.
1. Otherwise, let _n_, _k_, and _s_ be integers such that _k_ &ge; 1, 10<sup>_k_ - 1</sup> &le; _s_ &lt; 10<sup>_k_</sup>, 𝔽(_s_ &times; 10<sup>_n_ - _k_</sup>) is _x_, and _k_ is as small as possible. If there are multiple possibilities for _s_, choose the value of _s_ for which _s_ &times; 10<sup>_n_ - _k_</sup> is closest in value to ℝ(_x_). If there are two such possible values of _s_, choose the one that is even. Note that _k_ is the number of digits in the decimal representation of _s_ and that _s_ is not divisible by 10.
</emu-alg>
</emu-note>
<emu-note>
Expand Down Expand Up @@ -26924,7 +26924,7 @@ <h1>Number.prototype.toExponential ( _fractionDigits_ )</h1>
1. If _fractionDigits_ is not *undefined*, then
1. Let _e_ and _n_ be integers such that 10<sup>_f_</sup> &le; _n_ &lt; 10<sup>_f_ + 1</sup> and for which _n_ &times; 10<sup>_e_ - _f_</sup> - _x_ is as close to zero as possible. If there are two such sets of _e_ and _n_, pick the _e_ and _n_ for which _n_ &times; 10<sup>_e_ - _f_</sup> is larger.
1. Else,
1. [id="step-number-proto-toexponential-intermediate-values"] Let _e_, _n_, and _f_ be integers such that _f_ &ge; 0, 10<sup>_f_</sup> &le; _n_ &lt; 10<sup>_f_ + 1</sup>, _n_ &times; 10<sup>_e_ - _f_</sup> is _x_, and _f_ is as small as possible. Note that the decimal representation of _n_ has _f_ + 1 digits, _n_ is not divisible by 10, and the least significant digit of _n_ is not necessarily uniquely determined by these criteria.
1. [id="step-number-proto-toexponential-intermediate-values"] Let _e_, _n_, and _f_ be integers such that _f_ &ge; 0, 10<sup>_f_</sup> &le; _n_ &lt; 10<sup>_f_ + 1</sup>, 𝔽(_n_ &times; 10<sup>_e_ - _f_</sup>) is 𝔽(_x_), and _f_ is as small as possible. Note that the decimal representation of _n_ has _f_ + 1 digits, _n_ is not divisible by 10, and the least significant digit of _n_ is not necessarily uniquely determined by these criteria.
1. Let _m_ be the String value consisting of the digits of the decimal representation of _n_ (in order, with no leading zeroes).
1. If _f_ &ne; 0, then
1. Let _a_ be the first code unit of _m_.
Expand All @@ -26946,7 +26946,7 @@ <h1>Number.prototype.toExponential ( _fractionDigits_ )</h1>
<emu-note>
<p>For implementations that provide more accurate conversions than required by the rules above, it is recommended that the following alternative version of step <emu-xref href="#step-number-proto-toexponential-intermediate-values"></emu-xref> be used as a guideline:</p>
<emu-alg replaces-step="step-number-proto-toexponential-intermediate-values">
1. Let _e_, _n_, and _f_ be integers such that _f_ &ge; 0, 10<sup>_f_</sup> &le; _n_ &lt; 10<sup>_f_ + 1</sup>, _n_ &times; 10<sup>_e_ - _f_</sup> is _x_, and _f_ is as small as possible. If there are multiple possibilities for _n_, choose the value of _n_ for which _n_ &times; 10<sup>_e_ - _f_</sup> is closest in value to _x_. If there are two such possible values of _n_, choose the one that is even.
1. Let _e_, _n_, and _f_ be integers such that _f_ &ge; 0, 10<sup>_f_</sup> &le; _n_ &lt; 10<sup>_f_ + 1</sup>, 𝔽(_n_ &times; 10<sup>_e_ - _f_</sup>) is 𝔽(_x_), and _f_ is as small as possible. If there are multiple possibilities for _n_, choose the value of _n_ for which 𝔽(_n_ &times; 10<sup>_e_ - _f_</sup>) is closest in value to 𝔽(_x_). If there are two such possible values of _n_, choose the one that is even.
</emu-alg>
</emu-note>
</emu-clause>
Expand Down

0 comments on commit aafbfe4

Please sign in to comment.