From e11721ebfdac35a2b8825fa9b647633ea7c7c4ff Mon Sep 17 00:00:00 2001 From: HuangRui Date: Mon, 26 Jan 2015 17:21:43 +0800 Subject: [PATCH] Support floating point. Add PRINTF_LONG_SUPPORT to %g option. --- app/libc/c_stdio.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/libc/c_stdio.c b/app/libc/c_stdio.c index 41d6b38c..de9954cd 100644 --- a/app/libc/c_stdio.c +++ b/app/libc/c_stdio.c @@ -273,7 +273,11 @@ static int d2a(double num, char *bf) fpart = absnum - (double)ipart; // convert integer part to string +#ifdef PRINTF_LONG_SUPPORT + len += li2a(ipart, bf); +#else len += i2a(ipart, bf); +#endif #ifndef EPSILON #define EPSILON ((double)(0.00000001)) @@ -299,14 +303,17 @@ static int d2a(double num, char *bf) { fpart = fpart * 10; } +#ifdef PRINTF_LONG_SUPPORT + len += li2a((int)fpart, bf); +#else len += i2a((int)fpart, bf); +#endif } #undef EPSILON if (num < 0) { len ++; } - return len; }