summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/binary.c8
-rw-r--r--py/formatfloat.c8
-rw-r--r--py/mpprint.c2
3 files changed, 9 insertions, 9 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);
diff --git a/py/formatfloat.c b/py/formatfloat.c
index 50fc0da4b..9d28b2317 100644
--- a/py/formatfloat.c
+++ b/py/formatfloat.c
@@ -100,15 +100,15 @@ static inline int fp_isless1(float x) {
static const FPTYPE g_pos_pow[] = {
#if FPDECEXP > 32
- 1e256, 1e128, 1e64,
+ MICROPY_FLOAT_CONST(1e256), MICROPY_FLOAT_CONST(1e128), MICROPY_FLOAT_CONST(1e64),
#endif
- 1e32, 1e16, 1e8, 1e4, 1e2, 1e1
+ MICROPY_FLOAT_CONST(1e32), MICROPY_FLOAT_CONST(1e16), MICROPY_FLOAT_CONST(1e8), MICROPY_FLOAT_CONST(1e4), MICROPY_FLOAT_CONST(1e2), MICROPY_FLOAT_CONST(1e1)
};
static const FPTYPE g_neg_pow[] = {
#if FPDECEXP > 32
- 1e-256, 1e-128, 1e-64,
+ MICROPY_FLOAT_CONST(1e-256), MICROPY_FLOAT_CONST(1e-128), MICROPY_FLOAT_CONST(1e-64),
#endif
- 1e-32, 1e-16, 1e-8, 1e-4, 1e-2, 1e-1
+ MICROPY_FLOAT_CONST(1e-32), MICROPY_FLOAT_CONST(1e-16), MICROPY_FLOAT_CONST(1e-8), MICROPY_FLOAT_CONST(1e-4), MICROPY_FLOAT_CONST(1e-2), MICROPY_FLOAT_CONST(1e-1)
};
int mp_format_float(FPTYPE f, char *buf, size_t buf_size, char fmt, int prec, char sign) {
diff --git a/py/mpprint.c b/py/mpprint.c
index 49653a05b..c550c1d95 100644
--- a/py/mpprint.c
+++ b/py/mpprint.c
@@ -542,7 +542,7 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) {
case 'g':
case 'G': {
#if ((MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT) || (MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE))
- mp_float_t f = va_arg(args, double);
+ mp_float_t f = (mp_float_t)va_arg(args, double);
chrs += mp_print_float(print, f, *fmt, flags, fill, width, prec);
#else
#error Unknown MICROPY FLOAT IMPL