diff options
author | Damien George <damien.p.george@gmail.com> | 2016-10-11 13:00:01 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-10-11 13:00:01 +1100 |
commit | 48874942f0e0c948a9cb351b25d9fb04cdb82d56 (patch) | |
tree | c43286a1ccea0bcca8b9c16994b0facaf1f03984 /py | |
parent | 5e22afce41de8c87071d8fc149a6ba3cd8762819 (diff) | |
download | micropython-48874942f0e0c948a9cb351b25d9fb04cdb82d56.tar.gz micropython-48874942f0e0c948a9cb351b25d9fb04cdb82d56.zip |
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.
Diffstat (limited to 'py')
-rw-r--r-- | py/mpz.c | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -1497,13 +1497,10 @@ mpz_t *mpz_lcm(const mpz_t *z1, const mpz_t *z2) { quo * rhs + rem = lhs 0 <= rem < rhs can have lhs, rhs the same + assumes rhs != 0 (undefined behaviour if it is) */ void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs) { - if (rhs->len == 0) { - mpz_set_from_int(dest_quo, 0); - mpz_set_from_int(dest_rem, 0); - return; - } + assert(!mpz_is_zero(rhs)); mpz_need_dig(dest_quo, lhs->len + 1); // +1 necessary? memset(dest_quo->dig, 0, (lhs->len + 1) * sizeof(mpz_dig_t)); |