aboutsummaryrefslogtreecommitdiff
path: root/common/algorithm.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/algorithm.h')
-rw-r--r--common/algorithm.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/common/algorithm.h b/common/algorithm.h
index 06f2a279af..d3f518b225 100644
--- a/common/algorithm.h
+++ b/common/algorithm.h
@@ -227,6 +227,8 @@ 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;
while (a > 0) {
T tmp = a;
a = b % a;