summaryrefslogtreecommitdiff
path: root/mpz/gcd_ui.c
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2003-04-07 00:43:01 +0200
committerKevin Ryde <user42@zip.com.au>2003-04-07 00:43:01 +0200
commit94d5acbdf3df7bbe935e0c515dec0bba80747e1d (patch)
tree1578b1ade1c31f8c9a7bd450f7ea039805543fa8 /mpz/gcd_ui.c
parent921cfa5a182b66ba21171563e91ca9c39e038d16 (diff)
downloadgmp-94d5acbdf3df7bbe935e0c515dec0bba80747e1d.tar.gz
* mpz/gcd_ui.c: Correction to return value on longlong limb systems,
limb might not fit a ulong.
Diffstat (limited to 'mpz/gcd_ui.c')
-rw-r--r--mpz/gcd_ui.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/mpz/gcd_ui.c b/mpz/gcd_ui.c
index 77927b160..ac7170f4a 100644
--- a/mpz/gcd_ui.c
+++ b/mpz/gcd_ui.c
@@ -1,6 +1,7 @@
/* mpz_gcd_ui -- Calculate the greatest common divisior of two integers.
-Copyright 1994, 1996, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+Copyright 1994, 1996, 1999, 2000, 2001, 2002, 2003 Free Software Foundation,
+Inc.
This file is part of the GNU MP Library.
@@ -58,8 +59,9 @@ mpz_gcd_ui (mpz_ptr w, mpz_srcptr u, unsigned long int v)
}
SIZ(w) = un;
}
- /* We can't return any useful result for gcd(big,0). */
- return un > 1 ? 0 : PTR(u)[0];
+ /* Return u if it fits a ulong, otherwise 0. */
+ res = PTR(u)[0];
+ return (un == 1 && res <= ULONG_MAX ? res : 0);
}
else
res = mpn_gcd_1 (PTR(u), un, (mp_limb_t) v);