Hi,
In my program I see a lot of time taken up by add/subtract_unsigned. I have a couple of thoughts on the code:
Carry propagation outside the range of the smallest number can be improved:
for (; i < x && carry; ++i)
carry = ::boost::multiprecision::detail::addcarry_limb(carry, pa[i], 0, pr + i);
Maybe this:
for (; i < x && carry; ++i)
carry = ::boost::multiprecision::detail::addcarry_limb(0, pa[i], 1, pr + i);
This generates just an inc on my machine but unfortunately it doesn't eliminate the loads and stores. I think on average the carry chain must be small though.
You have the same situation on subtract.
add_unsigned and subtract_unsigned are inconsistent at the tail end after carry propagation:
add_unsigned:
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