mirror of
				https://github.com/boostorg/integer.git
				synced 2025-11-03 17:51:38 +01:00 
			
		
		
		
	Need to take abs of return value in short-circuit gcd code.
This commit is contained in:
		@@ -447,9 +447,9 @@ template <typename Integer>
 | 
			
		||||
inline BOOST_CXX14_CONSTEXPR Integer gcd(Integer const &a, Integer const &b) BOOST_GCD_NOEXCEPT(Integer)
 | 
			
		||||
{
 | 
			
		||||
    if(a == (std::numeric_limits<Integer>::min)())
 | 
			
		||||
       return a == static_cast<Integer>(0) ? b : gcd(static_cast<Integer>(a % b), b);
 | 
			
		||||
       return a == static_cast<Integer>(0) ? gcd_detail::gcd_traits<Integer>::abs(b) : gcd(static_cast<Integer>(a % b), b);
 | 
			
		||||
    else if (b == (std::numeric_limits<Integer>::min)())
 | 
			
		||||
       return b == static_cast<Integer>(0) ? a : gcd(a, static_cast<Integer>(b % a));
 | 
			
		||||
       return b == static_cast<Integer>(0) ? gcd_detail::gcd_traits<Integer>::abs(a) : gcd(a, static_cast<Integer>(b % a));
 | 
			
		||||
    return gcd_detail::optimal_gcd_select(static_cast<Integer>(gcd_detail::gcd_traits<Integer>::abs(a)), static_cast<Integer>(gcd_detail::gcd_traits<Integer>::abs(b)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user