From 92cc7a96e696895aeb92618675c478123a73d7b4 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 26 Sep 2014 05:49:50 -0600 Subject: [PATCH] Change to lib_dtoa() to fix prescision error from trailing zeroes --- libc/stdio/lib_libdtoa.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libc/stdio/lib_libdtoa.c b/libc/stdio/lib_libdtoa.c index a2edecf6b5..0120bafd2d 100644 --- a/libc/stdio/lib_libdtoa.c +++ b/libc/stdio/lib_libdtoa.c @@ -189,6 +189,10 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec, digits = __dtoa(value, 3, prec, &expt, &dsgn, &rve); numlen = rve - digits; + /* Avoid precision error from missing trailing zeroes */ + + numlen = MAX(expt, numlen); + if (IS_NEGATE(flags)) { obj->put(obj, '-');