From 56ac92e8ce0ba4228b1de03197054320b5147f44 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 12 Feb 2019 11:25:11 +0100 Subject: [PATCH] [dtostrf] Fix missing leading zeros in decimal part Fix #427 Signed-off-by: Frederic Pillon --- cores/arduino/avr/dtostrf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/arduino/avr/dtostrf.c b/cores/arduino/avr/dtostrf.c index 7b0a2fee50..19929b0d94 100644 --- a/cores/arduino/avr/dtostrf.c +++ b/cores/arduino/avr/dtostrf.c @@ -59,7 +59,7 @@ char *dtostrf (double val, signed char width, unsigned char prec, char *sout) { remainder *= decade; dec_part = (int)remainder; - sprintf(sout, "%ld.%ld", int_part, dec_part); + sprintf(sout, "%ld.%0*ld", int_part, prec, dec_part); // Handle minimum field width of the output string // width is signed value, negative for left adjustment.