From 8628eff9128d66cc69dbc301341dc55130a9817e Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 11 May 2011 19:58:03 -0400 Subject: fix the last known rounding bug in floating point printing the observed symptom was that the code was incorrectly rounding up 1.0625 to 1.063 despite the rounding mode being round-to-nearest with ties broken by rounding to even last place. however, the code was just not right in many respects, and i'm surprised it worked as well as it did. this time i tested the values that end up in the variables round, small, and the expression round+small, and all look good. --- src/stdio/vfprintf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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