Skip to content

Commit 4887494

Browse files
committed
py/mpz: In divmod, replace check for rhs!=0 with assert.
The check for division by zero is made by the caller of this function.
1 parent 5e22afc commit 4887494

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

py/mpz.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,13 +1497,10 @@ mpz_t *mpz_lcm(const mpz_t *z1, const mpz_t *z2) {
14971497
quo * rhs + rem = lhs
14981498
0 <= rem < rhs
14991499
can have lhs, rhs the same
1500+
assumes rhs != 0 (undefined behaviour if it is)
15001501
*/
15011502
void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs) {
1502-
if (rhs->len == 0) {
1503-
mpz_set_from_int(dest_quo, 0);
1504-
mpz_set_from_int(dest_rem, 0);
1505-
return;
1506-
}
1503+
assert(!mpz_is_zero(rhs));
15071504

15081505
mpz_need_dig(dest_quo, lhs->len + 1); // +1 necessary?
15091506
memset(dest_quo->dig, 0, (lhs->len + 1) * sizeof(mpz_dig_t));

0 commit comments

Comments
 (0)