Skip to content
Snippets Groups Projects
Commit a9dc9b8f authored by Damien George's avatar Damien George
Browse files

py: Fix comparison of minus-zero long int.

parent e6a118ee
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -12,3 +12,17 @@ print([-c for c in cases])
print([~c for c in cases])
print([c >> 1 for c in cases])
print([c << 1 for c in cases])
# comparison of 0/-0/+0
print(long_zero == 0)
print(long_neg_zero == 0)
print(long_one - 1 == 0)
print(long_neg_one + 1 == 0)
print(long_zero < 1)
print(long_zero < -1)
print(long_zero > 1)
print(long_zero > -1)
print(long_neg_zero < 1)
print(long_neg_zero < -1)
print(long_neg_zero > 1)
print(long_neg_zero > -1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment