Support floating point.

Add PRINTF_LONG_SUPPORT to %g option.
This commit is contained in:
HuangRui 2015-01-26 17:21:43 +08:00
parent 2e513a967e
commit e11721ebfd
1 changed files with 8 additions and 1 deletions

View File

@ -273,7 +273,11 @@ static int d2a(double num, char *bf)
fpart = absnum - (double)ipart; fpart = absnum - (double)ipart;
// convert integer part to string // convert integer part to string
#ifdef PRINTF_LONG_SUPPORT
len += li2a(ipart, bf);
#else
len += i2a(ipart, bf); len += i2a(ipart, bf);
#endif
#ifndef EPSILON #ifndef EPSILON
#define EPSILON ((double)(0.00000001)) #define EPSILON ((double)(0.00000001))
@ -299,14 +303,17 @@ static int d2a(double num, char *bf)
{ {
fpart = fpart * 10; fpart = fpart * 10;
} }
#ifdef PRINTF_LONG_SUPPORT
len += li2a((int)fpart, bf);
#else
len += i2a((int)fpart, bf); len += i2a((int)fpart, bf);
#endif
} }
#undef EPSILON #undef EPSILON
if (num < 0) if (num < 0)
{ {
len ++; len ++;
} }
return len; return len;
} }