Skip to content

Commit

Permalink
Merge pull request #263 from chfast/submul
Browse files Browse the repository at this point in the history
Optimize submul part of udivrem
  • Loading branch information
chfast authored Mar 14, 2022
2 parents b05e8a1 + 791d1c5 commit ce3f7a1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions include/intx/intx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1690,11 +1690,11 @@ inline uint64_t submul(
uint64_t borrow = 0;
for (int i = 0; i < len; ++i)
{
const auto s = subc(x[i], borrow);
const auto s = x[i] - borrow;
const auto p = umul(y[i], multiplier);
const auto t = subc(s.value, p[0]);
r[i] = t.value;
borrow = p[1] + s.carry + t.carry;
borrow = p[1] + (x[i] < s);
r[i] = s - p[0];
borrow += (s < r[i]);
}
return borrow;
}
Expand Down

0 comments on commit ce3f7a1

Please sign in to comment.