synced with scummvm to 2011-Apr-13

This commit is contained in:
Pawel Kolodziejski 2011-04-14 12:41:26 +02:00
parent f0a4299aef
commit 0640dcf2c7
347 changed files with 53648 additions and 8521 deletions

View file

@ -242,13 +242,20 @@ void sort(T first, T last) {
*/
template<class T>
T gcd(T a, T b) {
if (a <= 0) a = -a;
if (b <= 0) b = -b;
// Note: We check for <= instead of < to avoid spurious compiler
// warnings if T is an unsigned type, i.e. warnings like "comparison
// of unsigned expression < 0 is always false".
if (a <= 0)
a = -a;
if (b <= 0)
b = -b;
while (a > 0) {
T tmp = a;
a = b % a;
b = tmp;
}
return b;
}