summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-10-11 13:00:01 +1100
committerDamien George <damien.p.george@gmail.com>2016-10-11 13:00:01 +1100
commit48874942f0e0c948a9cb351b25d9fb04cdb82d56 (patch)
treec43286a1ccea0bcca8b9c16994b0facaf1f03984 /py
parent5e22afce41de8c87071d8fc149a6ba3cd8762819 (diff)
downloadmicropython-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.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/py/mpz.c b/py/mpz.c
index bb76479569..b5ec171dea 100644
--- a/py/mpz.c
+++ b/py/mpz.c
@@ -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));