parent
6e49d91e9f
commit
e812e8fb3d
|
@ -331,7 +331,7 @@ int xvfprintf(pic_state *pic, xFILE *stream, const char *fmt, va_list ap) {
|
||||||
char *sval;
|
char *sval;
|
||||||
int ival;
|
int ival;
|
||||||
#if PIC_ENABLE_FLOAT
|
#if PIC_ENABLE_FLOAT
|
||||||
double dval;
|
double dval, dint;
|
||||||
#endif
|
#endif
|
||||||
void *vp;
|
void *vp;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
@ -350,11 +350,15 @@ int xvfprintf(pic_state *pic, xFILE *stream, const char *fmt, va_list ap) {
|
||||||
break;
|
break;
|
||||||
#if PIC_ENABLE_FLOAT
|
#if PIC_ENABLE_FLOAT
|
||||||
case 'f':
|
case 'f':
|
||||||
dval = va_arg(ap, double);
|
dval = modf(va_arg(ap, double), &dint);
|
||||||
cnt += print_int(pic, stream, dval, 10);
|
if (dint < 0 || dval < 0) { /* either may be zero */
|
||||||
|
xputc(pic, '-', stream);
|
||||||
|
cnt++;
|
||||||
|
}
|
||||||
|
cnt += print_int(pic, stream, (long)fabs(dint), 10);
|
||||||
xputc(pic, '.', stream);
|
xputc(pic, '.', stream);
|
||||||
cnt++;
|
cnt++;
|
||||||
if ((ival = fabs((dval - floor(dval)) * 1e4) + 0.5) == 0) {
|
if ((ival = fabs(fabs(dval) * 1e4) + 0.5) == 0) {
|
||||||
cnt += xfputs(pic, "0000", stream);
|
cnt += xfputs(pic, "0000", stream);
|
||||||
} else {
|
} else {
|
||||||
int i;
|
int i;
|
||||||
|
|
Loading…
Reference in New Issue