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,12 +239,8 @@ STATIC mp_uint_t mpn_and_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, mp_uint_t j
carry >>= DIG_SIZE;
}
if (carry != 0) {
*idig = carry;
} else {
// remove trailing zeros
for (--idig; idig >= oidig && *idig == 0; --idig) {
}
// remove trailing zeros
for (--idig; idig >= oidig && *idig == 0; --idig) {
}
return idig + 1 - oidig;
......
......@@ -24,3 +24,5 @@ print(-2345678901234567890123456789 & a)
print((-a) & a)
print((-a) & 0xffffffff)
print((-a) & 0xffffffffffffffffffffffffffffffff)
print((-a) & 2)
print((-(1 << 70)) & 2)
Markdown is supported
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