diff options
Diffstat (limited to 'printf/doprntf.c')
-rw-r--r-- | printf/doprntf.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/printf/doprntf.c b/printf/doprntf.c index 6ddb58590..49e701304 100644 --- a/printf/doprntf.c +++ b/printf/doprntf.c @@ -90,8 +90,10 @@ __gmp_doprnt_mpf (const struct doprnt_funs_t *funs, overestimate the integer part, and add prec. If f<1 then underestimate the zeros between the radix point and the first digit and subtract that from prec. In either case add 2 so the - round to nearest can be applied accurately. */ - ndigits = prec + 2 + round to nearest can be applied accurately. Finally, we add 1 to + handle the case of 1-eps where EXP(f) = 0 but mpf_get_str returns + exp as 1. */ + ndigits = prec + 2 + 1 + EXP(f) * (mp_bases[ABS(p->base)].chars_per_limb + (EXP(f)>=0)); ndigits = MAX (ndigits, 1); break; |