all: Fix implicit floating point to integer conversions.

These are found when building with -Wfloat-conversion.
This commit is contained in:
stijn
2020-04-13 20:56:31 +02:00
committed by Damien George
parent bcf01d1686
commit 70affd9ba2
14 changed files with 25 additions and 23 deletions

View File

@@ -473,7 +473,7 @@ mp_obj_t mp_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
case MP_BINARY_OP_INPLACE_POWER:
if (rhs_val < 0) {
#if MICROPY_PY_BUILTINS_FLOAT
return mp_obj_float_binary_op(op, lhs_val, rhs);
return mp_obj_float_binary_op(op, (mp_float_t)lhs_val, rhs);
#else
mp_raise_ValueError(MP_ERROR_TEXT("negative power with no float support"));
#endif
@@ -535,7 +535,7 @@ mp_obj_t mp_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
}
#if MICROPY_PY_BUILTINS_FLOAT
} else if (mp_obj_is_float(rhs)) {
mp_obj_t res = mp_obj_float_binary_op(op, lhs_val, rhs);
mp_obj_t res = mp_obj_float_binary_op(op, (mp_float_t)lhs_val, rhs);
if (res == MP_OBJ_NULL) {
goto unsupported_op;
} else {
@@ -544,7 +544,7 @@ mp_obj_t mp_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
#endif
#if MICROPY_PY_BUILTINS_COMPLEX
} else if (mp_obj_is_type(rhs, &mp_type_complex)) {
mp_obj_t res = mp_obj_complex_binary_op(op, lhs_val, 0, rhs);
mp_obj_t res = mp_obj_complex_binary_op(op, (mp_float_t)lhs_val, 0, rhs);
if (res == MP_OBJ_NULL) {
goto unsupported_op;
} else {