Commit e11721eb authored by HuangRui's avatar HuangRui
Browse files

Support floating point.

Add PRINTF_LONG_SUPPORT to %g option.
parent 2e513a96
...@@ -273,7 +273,11 @@ static int d2a(double num, char *bf) ...@@ -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) ...@@ -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;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment