Skip to content

Commit b3be471

Browse files
committed
py/mpz: Normalize (remove leading zeros) xor operation result.
1 parent b56c635 commit b3be471

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

py/mpz.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,11 @@ STATIC mp_uint_t mpn_xor(mpz_dig_t *idig, const mpz_dig_t *jdig, mp_uint_t jlen,
285285
*idig = *jdig;
286286
}
287287

288-
return idig - oidig;
288+
// remove trailing zeros
289+
for (--idig; idig >= oidig && *idig == 0; --idig) {
290+
}
291+
292+
return idig + 1 - oidig;
289293
}
290294

291295
/* computes i = i * d1 + d2

0 commit comments

Comments
 (0)