Return type of gcd in C++

Marc Glisse marc.glisse at inria.fr
Tue Jun 17 14:45:34 UTC 2014


Hello,

the C++ standard is likely to add a gcd function for builtin integer 
types, and that reminds me that gmpxx still doesn't provide such a 
function. As long as both arguments are mpz_class (or expressions), things 
are relatively clear. But what about gcd(mpz_class,short), what should it 
return? It could return an expression that evaluates to mpz_class, but we 
could also make it return unsigned short (or unsigned long so they all 
return the same thing). On the other hand, that might be a bit confusing. 
Since mpz_class%short returns an mpz expression, I think I will do the 
same for gcd, to be consistent, but if people have opinions on this, I am 
listening.

-- 
Marc Glisse


More information about the gmp-discuss mailing list