friend SlowMPInt abs(const SlowMPInt &x);
friend SlowMPInt ceilDiv(const SlowMPInt &lhs, const SlowMPInt &rhs);
friend SlowMPInt floorDiv(const SlowMPInt &lhs, const SlowMPInt &rhs);
+ /// The operands must be non-negative for gcd.
friend SlowMPInt gcd(const SlowMPInt &a, const SlowMPInt &b);
/// Overload to compute a hash_code for a SlowMPInt value.
}
SlowMPInt detail::gcd(const SlowMPInt &a, const SlowMPInt &b) {
- return SlowMPInt(
- llvm::APIntOps::GreatestCommonDivisor(a.val.abs(), b.val.abs()));
+ assert(a >= 0 && b >= 0 && "operands must be non-negative!");
+ return SlowMPInt(llvm::APIntOps::GreatestCommonDivisor(a.val, b.val));
}
/// Returns the least common multiple of 'a' and 'b'.