summaryrefslogtreecommitdiff
path: root/printf
diff options
context:
space:
mode:
authorTorbjorn Granlund <tege@gmplib.org>2011-08-18 13:28:29 +0200
committerTorbjorn Granlund <tege@gmplib.org>2011-08-18 13:28:29 +0200
commit34c7148ba2f90b43ffd625722a29bf1c59edf654 (patch)
tree0e54f15908a22e2bf34750ce561e9a557189cadc /printf
parent50b89913b0c16be4693ac5cf6c8ecedd174cca1d (diff)
downloadgmp-34c7148ba2f90b43ffd625722a29bf1c59edf654.tar.gz
(__gmp_doprnt_mpf): For DOPRNT_CONV_FIXED, ask for one more digit.
Diffstat (limited to 'printf')
-rw-r--r--printf/doprntf.c6
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;