diff --git a/include/boost/integer/common_factor_rt.hpp b/include/boost/integer/common_factor_rt.hpp index d27f094..2f65d67 100644 --- a/include/boost/integer/common_factor_rt.hpp +++ b/include/boost/integer/common_factor_rt.hpp @@ -447,9 +447,9 @@ template inline BOOST_CXX14_CONSTEXPR Integer gcd(Integer const &a, Integer const &b) BOOST_GCD_NOEXCEPT(Integer) { if(a == (std::numeric_limits::min)()) - return a == static_cast(0) ? b : gcd(static_cast(a % b), b); + return a == static_cast(0) ? gcd_detail::gcd_traits::abs(b) : gcd(static_cast(a % b), b); else if (b == (std::numeric_limits::min)()) - return b == static_cast(0) ? a : gcd(a, static_cast(b % a)); + return b == static_cast(0) ? gcd_detail::gcd_traits::abs(a) : gcd(a, static_cast(b % a)); return gcd_detail::optimal_gcd_select(static_cast(gcd_detail::gcd_traits::abs(a)), static_cast(gcd_detail::gcd_traits::abs(b))); }