Skip to content
Snippets Groups Projects
Commit 2d7ff071 authored by Damien George's avatar Damien George
Browse files

py: Add mpz modulo operation.

parent c412998c
No related branches found
No related tags found
No related merge requests found
......@@ -100,9 +100,14 @@ mp_obj_t int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
mpz_deinit(&rem);
break;
}
//case RT_BINARY_OP_MODULO:
//case RT_BINARY_OP_INPLACE_MODULO:
case RT_BINARY_OP_MODULO:
case RT_BINARY_OP_INPLACE_MODULO: {
// TODO check that this operation matches the CPython operation
mpz_t quo; mpz_init_zero(&quo);
mpz_divmod_inpl(&quo, &res->mpz, zlhs, zrhs);
mpz_deinit(&quo);
break;
}
//case RT_BINARY_OP_AND:
//case RT_BINARY_OP_INPLACE_AND:
......
# test % operation on big integers
delta = 100000000000000000000000000000012345
for i in range(11):
for j in range(11):
x = delta * (i)# - 5) # TODO reinstate negative number test when % is working with sign correctly
y = delta * (j)# - 5) # TODO reinstate negative number test when % is working with sign correctly
if y != 0:
print(x % y)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment