aboutsummaryrefslogtreecommitdiff
path: root/py/mpz.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-01-27 17:47:38 +0000
committerDamien George <damien.p.george@gmail.com>2015-01-27 17:47:38 +0000
commita9dc9b8f6dc29d842f0a7427cc3cf068ae1cfbea (patch)
treec64b19fa0256234a19a937ac3a057af470f5324b /py/mpz.c
parente6a118ee85b35eb443057a2b6dbc87059deff6dc (diff)
py: Fix comparison of minus-zero long int.
Diffstat (limited to 'py/mpz.c')
-rw-r--r--py/mpz.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/py/mpz.c b/py/mpz.c
index c0a3d4b0b..a056a6e8a 100644
--- a/py/mpz.c
+++ b/py/mpz.c
@@ -820,6 +820,10 @@ bool mpz_is_even(const mpz_t *z) {
}
int mpz_cmp(const mpz_t *z1, const mpz_t *z2) {
+ // to catch comparison of -0 with +0
+ if (z1->len == 0 && z2->len == 0) {
+ return 0;
+ }
int cmp = (int)z2->neg - (int)z1->neg;
if (cmp != 0) {
return cmp;