Skip to content

Commit

Permalink
Correct type of math operations
Browse files Browse the repository at this point in the history
This is to be done comprehensively in #1413, but may as well fix these
cases that were identified in review.
(Comma separators are currently not used in the spec text, so prefer
scientific notation if the numbers are large.)
  • Loading branch information
ptomato committed May 21, 2021
1 parent c28fb4e commit 09c157e
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions spec/instant.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h1>Temporal.Instant.fromEpochSeconds ( _epochSeconds_ )</h1>
<emu-alg>
1. Set _epochSeconds_ to ? ToNumber(_epochSeconds_).
1. Set _epochSeconds_ to ? NumberToBigInt(_epochSeconds_).
1. Let _epochNanoseconds_ be _epochSeconds_ × 1,000,000,000.
1. Let _epochNanoseconds_ be _epochSeconds_ × *10<sup>9</sup>*<sub>ℤ</sub>.
1. If ! IsValidEpochNanoseconds(_epochNanoseconds_) is *false*, throw a *RangeError* exception.
1. Return ? CreateTemporalInstant(_epochNanoseconds_).
</emu-alg>
Expand All @@ -79,7 +79,7 @@ <h1>Temporal.Instant.fromEpochMilliseconds ( _epochMilliseconds_ )</h1>
<emu-alg>
1. Set _epochMilliseconds_ to ? ToNumber(_epochMilliseconds_).
1. Set _epochMilliseconds_ to ? NumberToBigInt(_epochMilliseconds_).
1. Let _epochNanoseconds_ be _epochMilliseconds_ × 1,000,000.
1. Let _epochNanoseconds_ be _epochMilliseconds_ × *10<sup>6</sup>*<sub>ℤ</sub>.
1. If ! IsValidEpochNanoseconds(_epochNanoseconds_) is *false*, throw a *RangeError* exception.
1. Return ? CreateTemporalInstant(_epochNanoseconds_).
</emu-alg>
Expand All @@ -93,7 +93,7 @@ <h1>Temporal.Instant.fromEpochMicroseconds ( _epochMicroseconds_ )</h1>
</p>
<emu-alg>
1. Set _epochMicroseconds_ to ? ToBigInt(_epochMicroseconds_).
1. Let _epochNanoseconds_ be _epochMicroseconds_ × 1,000.
1. Let _epochNanoseconds_ be _epochMicroseconds_ × *1000*<sub>ℤ</sub>.
1. If ! IsValidEpochNanoseconds(_epochNanoseconds_) is *false*, throw a *RangeError* exception.
1. Return ? CreateTemporalInstant(_epochNanoseconds_).
</emu-alg>
Expand Down Expand Up @@ -487,7 +487,7 @@ <h1>IsValidEpochNanoseconds ( _epochNanoseconds_ )</h1>
</p>
<emu-alg>
1. Assert: Type(_epochNanoseconds_) is BigInt.
1. If _epochNanoseconds_ &lt; −8.64 × 10<sup>21</sup><sub></sub> or _epochNanoseconds_ &gt; 8.64 × 10<sup>21</sup><sub></sub>, then
1. If _epochNanoseconds_ &lt; *−86400*<sub>ℤ</sub> × *10<sup>17</sup>*<sub></sub> or _epochNanoseconds_ &gt; *86400*<sub>ℤ</sub> × *10<sup>17</sup>*<sub></sub>, then
1. Return *false*.
1. Return *true*.
</emu-alg>
Expand Down Expand Up @@ -553,12 +553,13 @@ <h1>AddInstant ( _epochNanoseconds_, _hours_, _minutes_, _seconds_, _millisecond
The abstract operation AddInstant adds a duration in various time units to a number of nanoseconds since the Unix epoch.
</p>
<emu-alg>
1. Let _result_ be _epochNanoseconds_ + _nanoseconds_ +
_microseconds_ × 1000 +
_milliseconds_ × 1,000,000 +
_seconds_ × 1,000,000,000 +
_minutes_ × 60,000,000,000 +
_hours_ × 3,600,000,000,000.
1. Assert: _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, and _nanoseconds_ are integer Number values.
1. Let _result_ be _epochNanoseconds_ + ℤ(_nanoseconds_) +
ℤ(_microseconds_) × *1000*<sub>ℤ</sub> +
ℤ(_milliseconds_) × *10<sup>6</sup>*<sub>ℤ</sub> +
ℤ(_seconds_) × *10<sup>9</sup>*<sub>ℤ</sub> +
ℤ(_minutes_) × *60*<sub>ℤ</sub> × *10<sup>9</sup>*<sub>ℤ</sub> +
ℤ(_hours_) × *3600*<sub>ℤ</sub> × *10<sup>9</sup>*<sub>ℤ</sub>.
1. If ! IsValidEpochNanoseconds(_result_) is *false*, throw a *RangeError* exception.
1. Return _result_.
</emu-alg>
Expand Down

0 comments on commit 09c157e

Please sign in to comment.