tc39/proposal-math-sum

Rewrite 7.b.i and 7.b.ii to not overflow integer range

Opened this issue · 1 comments

sno2 commented

The current steps use a unique way of checking for overflows:

i. Set count to count + 1.
ii. If count ≥ 2**53, then (...)

This compares count to a value outside of the valid integer range. I believe the spec has explicitly avoided defining comparisons with integer outside of the range as shown in the following examples:

I think it would be better to swap these instructions with this:

i. If count >= 2**53 - 1, then (...)
ii. Set count to count + 1.

which would avoid a value of count outside of the integer range. Thanks for the proposal.

sno2 commented

Would this change be better as a PR?