tc39 / proposal-math-sum

TC39 proposal to add a summation method to JavaScript
https://tc39.github.io/proposal-math-sum
72 stars 1 forks source link

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

Open sno2 opened 2 months ago

sno2 commented 2 months ago

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 2 months ago

Would this change be better as a PR?