all: Fix implicit conversion from double to float.

These are found when building with -Wfloat-conversion.
This commit is contained in:
stijn
2020-03-31 14:48:08 +02:00
committed by Damien George
parent dc4d119d3d
commit bcf01d1686
23 changed files with 266 additions and 265 deletions

View File

@@ -178,7 +178,7 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, size_t index) {
case 'f':
return mp_obj_new_float_from_f(((float *)p)[index]);
case 'd':
return mp_obj_new_float(((double *)p)[index]);
return mp_obj_new_float_from_d(((double *)p)[index]);
#endif
// Extension to CPython: array of objects
case 'O':
@@ -249,7 +249,7 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte *p_base, byte *
union { uint64_t i;
double f;
} fpu = {val};
return mp_obj_new_float(fpu.f);
return mp_obj_new_float_from_d(fpu.f);
#endif
} else if (is_signed(val_type)) {
if ((long long)MP_SMALL_INT_MIN <= val && val <= (long long)MP_SMALL_INT_MAX) {
@@ -311,7 +311,7 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte *p
union { uint32_t i;
float f;
} fp_sp;
fp_sp.f = mp_obj_get_float(val_in);
fp_sp.f = mp_obj_get_float_to_f(val_in);
val = fp_sp.i;
break;
}
@@ -359,7 +359,7 @@ void mp_binary_set_val_array(char typecode, void *p, size_t index, mp_obj_t val_
switch (typecode) {
#if MICROPY_PY_BUILTINS_FLOAT
case 'f':
((float *)p)[index] = mp_obj_get_float(val_in);
((float *)p)[index] = mp_obj_get_float_to_f(val_in);
break;
case 'd':
((double *)p)[index] = mp_obj_get_float_to_d(val_in);