Skip to content

Commit

Permalink
Opt 7
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Aug 23, 2021
1 parent cc72658 commit 8f8e7fb
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions include/intx/intx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,10 +1024,8 @@ inline uint256 addmod(const uint256& x, const uint256& y, const uint256& mod) no
const auto ym = y >= mod ? y % mod : y;

const auto s = add_with_carry(xm, ym);
auto sum = s.value;
if (s.carry || s.value >= mod)
sum -= mod;
return sum;
const auto t = sub_with_carry(s.value, mod);
return s.carry || !t.carry ? t.value : s.value;
}

inline uint256 mulmod(const uint256& x, const uint256& y, const uint256& mod) noexcept
Expand Down

0 comments on commit 8f8e7fb

Please sign in to comment.