Skip to content

Commit

Permalink
Editorial: Add missing checks before calling ApplyUnsignedRoundingMode
Browse files Browse the repository at this point in the history
ApplyUnsignedRoundingMode requires `r1 ≤ t < r2`, see step 2. Add
missing checks to ensure this requirement is fulfilled when called from
NudgeToCalendarUnit.
  • Loading branch information
anba committed Jun 5, 2024
1 parent 26e4ceb commit 9be3190
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions spec/duration.html
Original file line number Diff line number Diff line change
Expand Up @@ -1878,6 +1878,9 @@ <h1>
1. Let _progress_ be (_destEpochNs_ - _startEpochNs_) / (_endEpochNs_ - _startEpochNs_).
1. Let _total_ be _r1_ + _progress_ &times; _increment_ &times; _sign_.
1. NOTE: The above two steps cannot be implemented directly using floating-point arithmetic. This division can be implemented as if constructing Normalized Time Duration Records for the denominator and numerator of _total_ and performing one division operation with a floating-point result.
1. If _progress_ &times; _sign_ &lt; 0, throw a *RangeError* exception.
1. If _progress_ &le; -1 or _progress_ &ge; 1, throw a *RangeError* exception.
1. Assert: _r1_ &le; _total_ &lt; _r2_.
1. Let _roundedUnit_ be ApplyUnsignedRoundingMode(_total_, _r1_, _r2_, _unsignedRoundingMode_).
1. If _roundedUnit_ - _total_ &lt 0, let _roundedSign_ be -1; else let _roundedSign_ be 1.
1. If _roundedSign_ = _sign_, then
Expand Down

0 comments on commit 9be3190

Please sign in to comment.