summaryrefslogtreecommitdiffstatshomepage
path: root/py/objint_mpz.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-03-29 17:28:20 +0000
committerDamien George <damien.p.george@gmail.com>2014-03-29 17:28:20 +0000
commit0aa5d51cf115f2941ca20901d45a044f54792eb4 (patch)
tree812b04b3b753010a72bf17826ac146a641a5810f /py/objint_mpz.c
parentc9fd6645b0a1af73f3854ddc2745596070985a18 (diff)
downloadmicropython-0aa5d51cf115f2941ca20901d45a044f54792eb4.tar.gz
micropython-0aa5d51cf115f2941ca20901d45a044f54792eb4.zip
py: Support mpz -op- float, mpz -op- complex, and complex -op- mpz.
Diffstat (limited to 'py/objint_mpz.c')
-rw-r--r--py/objint_mpz.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/py/objint_mpz.c b/py/objint_mpz.c
index bd82815bcf..75bb1c1100 100644
--- a/py/objint_mpz.c
+++ b/py/objint_mpz.c
@@ -57,6 +57,7 @@ mp_obj_t int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
} else if (MP_OBJ_IS_TYPE(lhs_in, &mp_type_int)) {
zlhs = &((mp_obj_int_t*)lhs_in)->mpz;
} else {
+ // unsupported type
return MP_OBJ_NULL;
}
@@ -66,7 +67,14 @@ mp_obj_t int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
zrhs = &z_int;
} else if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_int)) {
zrhs = &((mp_obj_int_t*)rhs_in)->mpz;
+#if MICROPY_ENABLE_FLOAT
+ } else if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_float)) {
+ return mp_obj_float_binary_op(op, mpz_as_float(zlhs), rhs_in);
+ } else if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_complex)) {
+ return mp_obj_complex_binary_op(op, mpz_as_float(zlhs), 0, rhs_in);
+#endif
} else {
+ // unsupported type
return MP_OBJ_NULL;
}