Skip to content

Commit

Permalink
some simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Apr 16, 2024
1 parent 51ce5d0 commit 51cb7c8
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions packages/core-js/modules/esnext.math.sum-precise.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ $({ target: 'Math', stat: true, forced: true }, {
hi = sum.hi;
lo = sum.lo;
}
if (lo !== 0) {
partials[actuallyUsedPartials] = lo;
actuallyUsedPartials += 1;
}
if (lo !== 0) partials[actuallyUsedPartials++] = lo;
x = hi;
}
partials.length = actuallyUsedPartials;
Expand All @@ -110,7 +107,7 @@ $({ target: 'Math', stat: true, forced: true }, {

if (overflow !== 0) {
var next = n >= 0 ? partials[n] : 0;
n -= 1;
n--;
if (abs(overflow) > 1 || (overflow > 0 && next > 0) || (overflow < 0 && next < 0)) {
return overflow > 0 ? $Infinity : -$Infinity;
}
Expand All @@ -129,26 +126,22 @@ $({ target: 'Math', stat: true, forced: true }, {
}

if (lo !== 0) {
partials[n + 1] = lo;
n += 1;
partials[++n] = lo;
lo = 0;
}

hi *= 2;
}

while (n >= 0) {
x = hi;
y = partials[n];
n -= 1;
sum = twosum(x, y);
sum = twosum(hi, partials[n--]);
hi = sum.hi;
lo = sum.lo;
if (lo !== 0) break;
}

if (n >= 0 && ((lo < 0.0 && partials[n] < 0.0) || (lo > 0.0 && partials[n] > 0.0))) {
y = lo * 2.0;
if (n >= 0 && ((lo < 0 && partials[n] < 0) || (lo > 0 && partials[n] > 0))) {
y = lo * 2;
x = hi + y;
if (y === x - hi) hi = x;
}
Expand Down

0 comments on commit 51cb7c8

Please sign in to comment.