diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-02-03 10:06:53 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-02-03 10:06:53 +0000 |
commit | a3bad9513b29aed9518992a4488556788a4248a6 (patch) | |
tree | e7924f8fc42d75d781487fff204b885dea2387e7 /get_str.c | |
parent | eddbad0b931c43cfbca69f0e1b43396ddbc3ebbb (diff) | |
download | mpfr-a3bad9513b29aed9518992a4488556788a4248a6.tar.gz |
fixed bug in get_str (case pow2, rnd=up or down)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2655 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'get_str.c')
-rw-r--r-- | get_str.c | 22 |
1 files changed, 6 insertions, 16 deletions
@@ -480,20 +480,6 @@ mpfr_get_str (char *s, mp_exp_t *e, int b, size_t m, mpfr_srcptr x, mp_rnd_t rnd return s0; /* strlen(s0) = neg + m */ } - /* si x < 0, on se ram`ene au cas x > 0 */ - if (neg) - { - switch (rnd) - { - case GMP_RNDU : - rnd = GMP_RNDD; break; - case GMP_RNDD : - rnd = GMP_RNDU; break; - default: - break; - } - } - if (s == NULL) s = (char*) (*__gmp_allocate_func) (neg + m + 1); s0 = s; @@ -523,7 +509,7 @@ mpfr_get_str (char *s, mp_exp_t *e, int b, size_t m, mpfr_srcptr x, mp_rnd_t rnd } /* the first digit will contain only r bits */ - prec = (m - 1) * pow2 + r; + prec = (m - 1) * pow2 + r; /* total number of bits */ n = (prec - 1) / BITS_PER_MP_LIMB + 1; TMP_MARK (marker); @@ -568,7 +554,11 @@ mpfr_get_str (char *s, mp_exp_t *e, int b, size_t m, mpfr_srcptr x, mp_rnd_t rnd TMP_FREE(marker); return (s0); - } + } + + /* if x < 0, reduce to x > 0 */ + if (neg) + rnd = MPFR_INVERT_RND(rnd); g = mpfr_get_str_compute_g (b, MPFR_GET_EXP (x) - 1); exact = 1; |