py: Add mpz modulo operation.
This commit is contained in:
parent
c412998c49
commit
2d7ff07175
|
@ -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:
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
# 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)
|
Loading…
Reference in New Issue