author | Rich Felker <dalias@aerifal.cx> | 2011年05月11日 19:58:03 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011年05月11日 19:58:03 -0400 |
commit | 8628eff9128d66cc69dbc301341dc55130a9817e (patch) | |
tree | f6eaf02a2b338a200303de07054f3a5414326a12 /src/stdio/vfprintf.c | |
parent | 15b77d52c950c375514d2e8152e7112fd018e20e (diff) | |
download | musl-8628eff9128d66cc69dbc301341dc55130a9817e.tar.gz |
-rw-r--r-- | src/stdio/vfprintf.c | 7 |
diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c index f19058d3..f13fbe10 100644 --- a/src/stdio/vfprintf.c +++ b/src/stdio/vfprintf.c @@ -326,9 +326,10 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t) if (x || d+1!=z) { long double round = CONCAT(0x1p,LDBL_MANT_DIG); long double small; - if (x<i/2) small=0x01p-1; - else if (i==i/2 && d+1==z) small=0x10p-1; - else small=0x11p-1; + if (*d/i & 1) round += 2; + if (x<i/2) small=0x0.8p0; + else if (x==i/2 && d+1==z) small=0x1.0p0; + else small=0x1.8p0; if (pl && *prefix=='-') round*=-1, small*=-1; *d -= x; /* Decide whether to round by probing round+small */ |