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

@@ -509,7 +509,7 @@ STATIC mp_obj_t mp_builtin_round(size_t n_args, const mp_obj_t *args) {
mp_float_t val = mp_obj_get_float(o_in);
if (n_args > 1) {
mp_int_t num_dig = mp_obj_get_int(args[1]);
mp_float_t mult = MICROPY_FLOAT_C_FUN(pow)(10, num_dig);
mp_float_t mult = MICROPY_FLOAT_C_FUN(pow)(10, (mp_float_t)num_dig);
// TODO may lead to overflow
mp_float_t rounded = MICROPY_FLOAT_C_FUN(nearbyint)(val * mult) / mult;
return mp_obj_new_float(rounded);