From 9d6128acdccb463edfe9a3b7dbf86417643104bb Mon Sep 17 00:00:00 2001 From: Dave Hylands Date: Mon, 31 Aug 2015 15:43:31 -0700 Subject: stmhal: fix single precision float printing error Fixes #1435. --- py/formatfloat.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'py/formatfloat.c') diff --git a/py/formatfloat.c b/py/formatfloat.c index cc06361008..a801055a65 100644 --- a/py/formatfloat.c +++ b/py/formatfloat.c @@ -142,7 +142,10 @@ int mp_format_float(float f, char *buf, size_t buf_size, char fmt, int prec, cha char e_sign_char = '-'; if (num.f < 1.0F && num.f >= 0.9999995F) { num.f = 1.0F; - first_dig = '1'; + if (e > 1) { + // numbers less than 1.0 start with 0.xxx + first_dig = '1'; + } if (e == 0) { e_sign_char = '+'; } -- cgit v1.2.3