diff options
Diffstat (limited to 'stdio-common')
-rw-r--r-- | stdio-common/printf_fp.c | 17 | ||||
-rw-r--r-- | stdio-common/tfformat.c | 10 |
2 files changed, 21 insertions, 6 deletions
diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c index 9240355..85286be 100644 --- a/stdio-common/printf_fp.c +++ b/stdio-common/printf_fp.c @@ -812,13 +812,24 @@ __printf_fp (FILE *fp, { char *tp = cp; - if (digit == '5') + if (digit == '5' && (*(cp - 1) & 1) == 0) /* This is the critical case. */ if (fracsize == 1 && frac[0] == 0) /* Rest of the number is zero -> round to even. (IEEE 754-1985 4.1 says this is the default rounding.) */ - if ((*(cp - 1) & 1) == 0) - goto do_expo; + goto do_expo; + else if (scalesize == 0) + { + /* Here we have to see whether all limbs are zero since no + normalization happened. */ + size_t lcnt = fracsize; + while (lcnt >= 1 && frac[lcnt - 1] == 0) + --lcnt; + if (lcnt == 0) + /* Rest of the number is zero -> round to even. + (IEEE 754-1985 4.1 says this is the default rounding.) */ + goto do_expo; + } if (fracdig_no > 0) { diff --git a/stdio-common/tfformat.c b/stdio-common/tfformat.c index cc9a384..f00d0de 100644 --- a/stdio-common/tfformat.c +++ b/stdio-common/tfformat.c @@ -14,7 +14,7 @@ sprint_double_type sprint_doubles[] = { {__LINE__, 30.3, "< +30.3>", "<%+15.10g>"}, {__LINE__, 10.0, "<10.00>", "<%5.2f>"}, - + {__LINE__, 1.002121970718271e+05, "100212.19707 ", "%0-15.5f"}, {__LINE__, -1.002121970718271e+05, "-100212.19707 ", "%0-15.5f"}, {__LINE__, 1.002121970718271e+05, "000100212.19707", "%015.5f"}, @@ -25,7 +25,7 @@ sprint_double_type sprint_doubles[] = {__LINE__, -1.002121970718271e+05, "-00100212.19707", "% 015.5f"}, {__LINE__, 1.002121970718271e+05, "+100212.19707 ", "%+-15.5f"}, {__LINE__, -1.002121970718271e+05, "-100212.19707 ", "%+-15.5f"}, - + {__LINE__, -1.002121970718271e+29, "-1.0E+29", "%.1E"}, {__LINE__, -1.002126048612756e-02, "-1.002126E-02", "%+#E"}, {__LINE__, -1.002653755271637e+00, "-1.00265", "%G"}, @@ -4005,7 +4005,11 @@ sprint_double_type sprint_doubles[] = #endif {__LINE__, 9.978034352999867e+15, "9.978034e+15", "%2.6e"}, {__LINE__, 9.998315286730175e-30, "9.998315e-30", "%6e"}, - + {__LINE__, 1.25, "1.2", "%.1f"}, + {__LINE__, 11.25, "11.2", "%.1f"}, + {__LINE__, 1.75, "1.8", "%.1f"}, + {__LINE__, 11.75, "11.8", "%.1f"}, + {0 } }; |