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

Normative: ToInteger normalizes -0 to +0 #1827

Merged
merged 1 commit into from
Feb 13, 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: 6 additions & 8 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -4829,8 +4829,8 @@ <h1>ToInteger ( _argument_ )</h1>
<p>The abstract operation ToInteger converts _argument_ to an integral Number value. This abstract operation functions as follows:</p>
<emu-alg>
1. Let _number_ be ? ToNumber(_argument_).
1. If _number_ is *NaN*, return *+0*.
1. If _number_ is *+0*, *-0*, *+&infin;*, or *-&infin;*, return _number_.
1. If _number_ is *NaN*, *+0*, or *-0*, return *+0*.
1. If _number_ is *+&infin;*, or *-&infin;*, return _number_.
1. Return the Number value that is the same sign as _number_ and whose magnitude is floor(abs(_number_)).
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -5295,7 +5295,7 @@ <h1>ToIndex ( _value_ )</h1>
1. Let _integerIndex_ be ? ToInteger(_value_).
1. If _integerIndex_ &lt; 0, throw a *RangeError* exception.
1. Let _index_ be ! ToLength(_integerIndex_).
1. If SameValueZero(_integerIndex_, _index_) is *false*, throw a *RangeError* exception.
1. If ! SameValue(_integerIndex_, _index_) is *false*, throw a *RangeError* exception.
1. Return _index_.
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -28609,9 +28609,7 @@ <h1>TimeClip ( _time_ )</h1>
<emu-alg>
1. If _time_ is not finite, return *NaN*.
1. If abs(_time_) &gt; 8.64 &times; 10<sup>15</sup>, return *NaN*.
1. Let _clippedTime_ be ! ToInteger(_time_).
1. If _clippedTime_ is *-0*, set _clippedTime_ to *+0*.
1. Return _clippedTime_.
1. Return ! ToInteger(_time_).
</emu-alg>
<emu-note>
<p>The point of step 4 is that an implementation is permitted a choice of internal representations of time values, for example as a 64-bit signed integer or as a 64-bit floating-point value. Depending on the implementation, this internal representation may or may not distinguish *-0* and *+0*.</p>
Expand Down Expand Up @@ -33773,7 +33771,7 @@ <h1>Array.prototype.indexOf ( _searchElement_ [ , _fromIndex_ ] )</h1>
1. Assert: If _fromIndex_ is *undefined*, then _n_ is 0.
1. If _n_ &ge; _len_, return -1.
1. If _n_ &ge; 0, then
1. If _n_ is *-0*, let _k_ be *+0*; else let _k_ be _n_.
1. Let _k_ be _n_.
1. Else,
1. Let _k_ be _len_ + _n_.
1. If _k_ &lt; 0, set _k_ to 0.
Expand Down Expand Up @@ -33840,7 +33838,7 @@ <h1>Array.prototype.lastIndexOf ( _searchElement_ [ , _fromIndex_ ] )</h1>
1. If _len_ is 0, return -1.
1. If _fromIndex_ is present, let _n_ be ? ToInteger(_fromIndex_); else let _n_ be _len_ - 1.
1. If _n_ &ge; 0, then
1. If _n_ is *-0*, let _k_ be *+0*; else let _k_ be min(_n_, _len_ - 1).
1. Let _k_ be min(_n_, _len_ - 1).
1. Else,
1. Let _k_ be _len_ + _n_.
1. Repeat, while _k_ &ge; 0
Expand Down