Skip to content

Commit

Permalink
Revert "Merge pull request #407 from boostorg/issue357"
Browse files Browse the repository at this point in the history
This reverts commit 75b17b9, reversing
changes made to 06a4aae.
  • Loading branch information
ckormanyos committed Dec 22, 2021
1 parent b034196 commit b86debb
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions include/boost/multiprecision/cpp_int/add_unsigned.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,18 +244,16 @@ inline BOOST_MP_CXX14_CONSTEXPR void add_unsigned(CppInt1& result, const CppInt2
for (; i < m; ++i)
carry = ::boost::multiprecision::detail::addcarry_limb(carry, pa[i], pb[i], pr + i);
for (; i < x && carry; ++i)
// We know carry is 1, so we just need to increment pa[i] (ie add a literal 1) and capture the carry:
carry = ::boost::multiprecision::detail::addcarry_limb(0, pa[i], 1, pr + i);
carry = ::boost::multiprecision::detail::addcarry_limb(carry, pa[i], 0, pr + i);
if (i == x && carry)
{
// We overflowed, need to add one more limb:
result.resize(x + 1, x + 1);
if (result.size() > x)
result.limbs()[x] = static_cast<limb_type>(1u);
}
else if ((x != i) && (pa != pr))
// Copy remaining digits only if we need to:
std_constexpr::copy(pa + i, pa + x, pr + i);
else
std::copy(pa + i, pa + x, pr + i);
result.normalize();
result.sign(a.sign());
}
Expand Down

0 comments on commit b86debb

Please sign in to comment.