Skip to content

Commit

Permalink
Normative: Add +0 to Array.prototype.indexOf to convert negative zero…
Browse files Browse the repository at this point in the history
… to positive zero

Fixes https://bugs.ecmascript.org/show_bug.cgi?id=4545

Closes #316
  • Loading branch information
anba authored and bterlson committed Feb 4, 2016
1 parent 3159310 commit 15ad138
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -25291,10 +25291,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 @@ -29388,7 +29390,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 @@ -29829,7 +29831,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 @@ -29899,7 +29901,8 @@ <h1>Array.prototype.lastIndexOf ( _searchElement_ [ , _fromIndex_ ] )</h1>
1. Let _len_ be ? ToLength(? Get(_O_, `"length"`)).
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 @@ -30993,7 +30996,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

0 comments on commit 15ad138

Please sign in to comment.