Commit 2065373f authored by Damien George's avatar Damien George
Browse files

py/mpz: Fix bignum anding of large negative with smaller positive int.

parent a81539db
...@@ -239,13 +239,9 @@ STATIC mp_uint_t mpn_and_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, mp_uint_t j ...@@ -239,13 +239,9 @@ STATIC mp_uint_t mpn_and_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, mp_uint_t j
carry >>= DIG_SIZE; carry >>= DIG_SIZE;
} }
if (carry != 0) {
*idig = carry;
} else {
// remove trailing zeros // remove trailing zeros
for (--idig; idig >= oidig && *idig == 0; --idig) { for (--idig; idig >= oidig && *idig == 0; --idig) {
} }
}
return idig + 1 - oidig; return idig + 1 - oidig;
} }
......
...@@ -24,3 +24,5 @@ print(-2345678901234567890123456789 & a) ...@@ -24,3 +24,5 @@ print(-2345678901234567890123456789 & a)
print((-a) & a) print((-a) & a)
print((-a) & 0xffffffff) print((-a) & 0xffffffff)
print((-a) & 0xffffffffffffffffffffffffffffffff) print((-a) & 0xffffffffffffffffffffffffffffffff)
print((-a) & 2)
print((-(1 << 70)) & 2)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment