浏览代码

Fix bug in math::biginteger::operator-=
Fix comment in math::detail::divide about number of inner loops... (can that be fixed?)

Sam Jaffe 7 年之前
父节点
当前提交
df50539f37
共有 2 个文件被更改,包括 2 次插入2 次删除
  1. 1 1
      src/biginteger.cpp
  2. 1 1
      src/bignum_helper.cpp

+ 1 - 1
src/biginteger.cpp

@@ -75,7 +75,7 @@ biginteger & math::operator+=(biginteger & rhs, biginteger const & lhs) {
 biginteger & math::operator-=(biginteger & rhs, biginteger const & lhs) {
   if (lhs == biginteger::ZERO) { return rhs; }
   else if (rhs == biginteger::ZERO) { rhs = -lhs; }
-  if (rhs.is_negative != lhs.is_negative) {
+  else if (rhs.is_negative != lhs.is_negative) {
     detail::add(rhs.data, lhs.data);
   } else {
     rhs.subtract_impl(lhs, true);

+ 1 - 1
src/bignum_helper.cpp

@@ -136,7 +136,7 @@ namespace math { namespace detail {
       do {
         subtract_nounderflow(remainder, value, shift);
         add(accum, powers[ipow], shift);
-      } while (compare(remainder, value, shift) >= 0); // Up to 9 times
+      } while (compare(remainder, value, shift) >= 0); // Up to 10 times
     } while (compare(remainder, divisor) >= 0);
     return accum;
   }