aboutsummaryrefslogtreecommitdiff
path: root/py/binary.c
diff options
context:
space:
mode:
authorstijn <stijn@ignitron.net>2020-03-31 14:48:08 +0200
committerDamien George <damien.p.george@gmail.com>2020-04-18 22:42:24 +1000
commitbcf01d1686a8fa6d257daea25ce0d7df6e4ad839 (patch)
tree2513c71e685ead21c6ca44a0432500ca75c424f8 /py/binary.c
parentdc4d119d3d96799bf848c6488b2ac49b933ab7cb (diff)
all: Fix implicit conversion from double to float.
These are found when building with -Wfloat-conversion.
Diffstat (limited to 'py/binary.c')
-rw-r--r--py/binary.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/py/binary.c b/py/binary.c
index 33515e880..a53b8847c 100644
--- a/py/binary.c
+++ b/py/binary.c
@@ -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);