summaryrefslogtreecommitdiff
path: root/boost/multiprecision/cpp_int/add.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/multiprecision/cpp_int/add.hpp')
-rw-r--r--boost/multiprecision/cpp_int/add.hpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/boost/multiprecision/cpp_int/add.hpp b/boost/multiprecision/cpp_int/add.hpp
index 2fca9b9597..3b769cd8b6 100644
--- a/boost/multiprecision/cpp_int/add.hpp
+++ b/boost/multiprecision/cpp_int/add.hpp
@@ -417,8 +417,12 @@ BOOST_MP_FORCEINLINE typename enable_if_c<!is_trivial_cpp_int<cpp_int_backend<Mi
static const limb_type one = 1;
if(!result.sign() && (result.limbs()[0] < cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::max_limb_value))
++result.limbs()[0];
- else if(result.sign() && result.limbs()[0])
+ else if (result.sign() && result.limbs()[0])
+ {
--result.limbs()[0];
+ if (!result.limbs()[0])
+ result.sign(false);
+ }
else
eval_add(result, one);
}
@@ -429,7 +433,7 @@ BOOST_MP_FORCEINLINE typename enable_if_c<!is_trivial_cpp_int<cpp_int_backend<Mi
static const limb_type one = 1;
if(!result.sign() && result.limbs()[0])
--result.limbs()[0];
- else if(result.sign() && (result.limbs()[0] < cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::max_limb_value))
+ else if (result.sign() && (result.limbs()[0] < cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::max_limb_value))
++result.limbs()[0];
else
eval_subtract(result, one);