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

Add +0 to Array.prototype.indexOf to convert negative zero to positive zero #316

Closed
wants to merge 1 commit into from
Closed
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
15 changes: 9 additions & 6 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -25275,10 +25275,12 @@ <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. Return ToInteger(_time_) + (*+0*). (Adding a positive zero converts *-0* to *+0*.)
1. Let _clippedTime_ be ToInteger(_time_).
1. If _clippedTime_ is -0, let _clippedTime_ be +0.
1. Return _clippedTime_.
</emu-alg>
<emu-note>
<p>The point of step 3 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>
<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>
</emu-note>
</emu-clause>

Expand Down Expand Up @@ -29372,7 +29374,7 @@ <h1>Array.from ( _items_ [ , _mapfn_ [ , _thisArg_ ] ] )</h1>
1. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_).
1. If _defineStatus_ is an abrupt completion, return ? IteratorClose(_iterator_, _defineStatus_).
1. Increase _k_ by 1.
1. Note: _items_ is not an Iterable so assume it is an array-like object.
1. NOTE: _items_ is not an Iterable so assume it is an array-like object.
1. Let _arrayLike_ be ! ToObject(_items_).
1. Let _len_ be ? ToLength(? Get(_arrayLike_, `"length"`)).
1. If IsConstructor(_C_) is *true*, then
Expand Down Expand Up @@ -29813,7 +29815,7 @@ <h1>Array.prototype.indexOf ( _searchElement_ [ , _fromIndex_ ] )</h1>
1. Let _n_ be ? ToInteger(_fromIndex_). (If _fromIndex_ is *undefined*, this step produces the value 0.)
1. If _n_ &ge; _len_, return -1.
1. If _n_ &ge; 0, then
1. Let _k_ be _n_.
1. If _n_ is -0, let _k_ be +0; else let _k_ be _n_.
1. Else _n_ &lt; 0,
1. Let _k_ be _len_ + _n_.
1. If _k_ &lt; 0, let _k_ be 0.
Expand Down Expand Up @@ -29883,7 +29885,8 @@ <h1>Array.prototype.lastIndexOf ( _searchElement_ [ , _fromIndex_ ] )</h1>
1. Let _len_ be ? ToLength(? Get(_O_, `"length"`)).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar question here - perhaps an explicit step to handle -0 rather than a note?

1. If _len_ is 0, return -1.
1. If argument _fromIndex_ was passed, let _n_ be ? ToInteger(_fromIndex_); else let _n_ be _len_-1.
1. If _n_ &ge; 0, let _k_ be min(_n_, _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. Else _n_ &lt; 0,
1. Let _k_ be _len_ + _n_.
1. Repeat, while _k_ &ge; 0
Expand Down Expand Up @@ -30975,7 +30978,7 @@ <h1>Runtime Semantics: IterableToArrayLike( _items_ )</h1>
1. Let _nextValue_ be ? IteratorValue(_next_).
1. Append _nextValue_ to the end of the List _values_.
1. Return CreateArrayFromList(_values_).
1. Note: _items_ is not an Iterable so assume it is already an array-like object.
1. NOTE: _items_ is not an Iterable so assume it is already an array-like object.
1. Return ! ToObject(_items_).
</emu-alg>
</emu-clause>
Expand Down