From 105c39e693e48f6bfe6a0ef8f1a608f4652b59d5 Mon Sep 17 00:00:00 2001 From: helpfulchicken <64881516+helpfulchicken@users.noreply.github.com> Date: Fri, 6 Nov 2020 10:57:21 +1300 Subject: [PATCH] Fix for minimal-printf when printing sign of double between 0.0 and -1.0 --- platform/source/minimal-printf/mbed_printf_implementation.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/platform/source/minimal-printf/mbed_printf_implementation.c b/platform/source/minimal-printf/mbed_printf_implementation.c index 455ec55890d..e473b201b62 100644 --- a/platform/source/minimal-printf/mbed_printf_implementation.c +++ b/platform/source/minimal-printf/mbed_printf_implementation.c @@ -264,6 +264,12 @@ static void mbed_minimal_formatted_string_double(char *buffer, size_t length, in /* get integer part */ MBED_SIGNED_STORAGE integer = value; + /* write sign if integer part is zero and value is negative */ + if ((value < 0.0) && (integer == 0)) { + /* write sign */ + mbed_minimal_putchar(buffer, length, result, '-', stream); + } + /* write integer part */ mbed_minimal_formatted_string_signed(buffer, length, result, integer, stream);