author | Rich Felker <dalias@aerifal.cx> | 2014年03月09日 03:09:49 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2014年03月09日 03:09:49 -0400 |
commit | 9743a399bf4d6da9a1dbdf7e8df07284c97df16f (patch) | |
tree | c9477850f2abba3b76123e1a2299b379199be9c4 | |
parent | ba231cf9e5923b6216081e9a626465c6643ce4d3 (diff) | |
download | musl-9743a399bf4d6da9a1dbdf7e8df07284c97df16f.tar.gz |
-rw-r--r-- | src/stdio/vfprintf.c | 4 |
diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c index 85701726..31c3d5dd 100644 --- a/src/stdio/vfprintf.c +++ b/src/stdio/vfprintf.c @@ -314,7 +314,7 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t) } while (e2<0) { uint32_t carry=0, *b; - int sh=MIN(9,-e2); + int sh=MIN(9,-e2), need=1+(p+LDBL_MANT_DIG/3+8)/9; for (d=a; d<z; d++) { uint32_t rm = *d & (1<<sh)-1; *d = (*d>>sh) + carry; @@ -324,7 +324,7 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t) if (carry) *z++ = carry; /* Avoid (slow!) computation past requested precision */ b = (t|32)=='f' ? r : a; - if (z-b > 2+p/9) z = b+2+p/9; + if (z-b > need) z = b+need; e2+=sh; } |