From 86fc1945d545055b16f9773d644de47a6760f9d8 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 --- .../source/minimal-printf/mbed_printf_implementation.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/platform/source/minimal-printf/mbed_printf_implementation.c b/platform/source/minimal-printf/mbed_printf_implementation.c index 455ec55890d0..1e9d9548c91a 100644 --- a/platform/source/minimal-printf/mbed_printf_implementation.c +++ b/platform/source/minimal-printf/mbed_printf_implementation.c @@ -264,6 +264,13 @@ 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);