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: Early return & throw in Number.prototype.to* methods #1938

Merged
merged 1 commit into from
May 21, 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
14 changes: 5 additions & 9 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -27210,14 +27210,12 @@ <h1>Number.prototype.toExponential ( _fractionDigits_ )</h1>
1. Let _x_ be ? thisNumberValue(*this* value).
1. Let _f_ be ? ToInteger(_fractionDigits_).
1. Assert: If _fractionDigits_ is *undefined*, then _f_ is 0.
1. If _x_ is *NaN*, return the String *"NaN"*.
1. If _x_ is not finite, return ! Number::toString(_x_).
1. If _f_ &lt; 0 or _f_ &gt; 100, throw a *RangeError* exception.
1. Let _s_ be the empty String.
1. If _x_ &lt; 0, then
1. Set _s_ to *"-"*.
1. Set _x_ to -_x_.
1. If _x_ = *+&infin;*, then
1. Return the string-concatenation of _s_ and *"Infinity"*.
1. If _f_ &lt; 0 or _f_ &gt; 100, throw a *RangeError* exception.
1. If _x_ = 0, then
1. Let _m_ be the String value consisting of _f_ + 1 occurrences of the code unit 0x0030 (DIGIT ZERO).
1. Let _e_ be 0.
Expand Down Expand Up @@ -27262,7 +27260,7 @@ <h1>Number.prototype.toFixed ( _fractionDigits_ )</h1>
1. Let _f_ be ? ToInteger(_fractionDigits_).
1. Assert: If _fractionDigits_ is *undefined*, then _f_ is 0.
1. If _f_ &lt; 0 or _f_ &gt; 100, throw a *RangeError* exception.
1. If _x_ is *NaN*, return the String *"NaN"*.
1. If _x_ is not finite, return ! Number::toString(_x_).
1. Let _s_ be the empty String.
1. If _x_ &lt; 0, then
1. Set _s_ to *"-"*.
Expand Down Expand Up @@ -27304,14 +27302,12 @@ <h1>Number.prototype.toPrecision ( _precision_ )</h1>
1. Let _x_ be ? thisNumberValue(*this* value).
1. If _precision_ is *undefined*, return ! ToString(_x_).
1. Let _p_ be ? ToInteger(_precision_).
1. If _x_ is *NaN*, return the String *"NaN"*.
1. If _x_ is not finite, return ! Number::toString(_x_).
1. If _p_ &lt; 1 or _p_ &gt; 100, throw a *RangeError* exception.
1. Let _s_ be the empty String.
1. If _x_ &lt; 0, then
1. Set _s_ to the code unit 0x002D (HYPHEN-MINUS).
1. Set _x_ to -_x_.
1. If _x_ = *+&infin;*, then
1. Return the string-concatenation of _s_ and *"Infinity"*.
1. If _p_ &lt; 1 or _p_ &gt; 100, throw a *RangeError* exception.
1. If _x_ = 0, then
1. Let _m_ be the String value consisting of _p_ occurrences of the code unit 0x0030 (DIGIT ZERO).
1. Let _e_ be 0.
Expand Down