From 4f40706b2f26bb8f9b956ec578e8a60c849fae53 Mon Sep 17 00:00:00 2001 From: Shenggao Zhu Date: Mon, 30 May 2016 16:33:05 +0800 Subject: [PATCH] Fixed Print::printf("%f") with correct digits Original printf() function for the float format (%f) outputs wrong number of digits after the decimal point (eg 1.02 is printed as 1.2). --- cores/arduino/Print.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp index f3749fe..eb65413 100644 --- a/cores/arduino/Print.cpp +++ b/cores/arduino/Print.cpp @@ -346,6 +346,9 @@ size_t Print::printf(const char *format, ...) if (l < 1) l = -l; l %= 100; + if(l < 10){ + n += print(0); + } n += print(l); } }