From ca92d099efebfab1a3c8bd5ccb44a475b5a1bbda Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 3 Jan 2020 12:45:01 -0800 Subject: [PATCH] Normative: ToInteger normalizes `-0` to `+0` (#1827) Fixes #1637. This only has an observable impact on `Atomics.store`. --- spec.html | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/spec.html b/spec.html index 1beb553b746..c8727e8f807 100644 --- a/spec.html +++ b/spec.html @@ -4815,8 +4815,8 @@

ToInteger ( _argument_ )

The abstract operation ToInteger converts _argument_ to an integral Number value. This abstract operation functions as follows:

1. Let _number_ be ? ToNumber(_argument_). - 1. If _number_ is *NaN*, return *+0*. - 1. If _number_ is *+0*, *-0*, *+∞*, or *-∞*, return _number_. + 1. If _number_ is *NaN*, *+0*, or *-0*, return *+0*. + 1. If _number_ is *+∞*, or *-∞*, return _number_. 1. Return the Number value that is the same sign as _number_ and whose magnitude is floor(abs(_number_)). @@ -5281,7 +5281,7 @@

ToIndex ( _value_ )

1. Let _integerIndex_ be ? ToInteger(_value_). 1. If _integerIndex_ < 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_. @@ -28558,9 +28558,7 @@

TimeClip ( _time_ )

1. If _time_ is not finite, return *NaN*. 1. If abs(_time_) > 8.64 × 1015, return *NaN*. - 1. Let _clippedTime_ be ! ToInteger(_time_). - 1. If _clippedTime_ is *-0*, set _clippedTime_ to *+0*. - 1. Return _clippedTime_. + 1. Return ! ToInteger(_time_).

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*.

@@ -33722,7 +33720,7 @@

Array.prototype.indexOf ( _searchElement_ [ , _fromIndex_ ] )

1. Assert: If _fromIndex_ is *undefined*, then _n_ is 0. 1. If _n_ ≥ _len_, return -1. 1. If _n_ ≥ 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_ < 0, set _k_ to 0. @@ -33789,7 +33787,7 @@

Array.prototype.lastIndexOf ( _searchElement_ [ , _fromIndex_ ] )

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_ ≥ 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_ ≥ 0