summaryrefslogtreecommitdiff
path: root/get_str.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2004-02-03 10:06:53 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2004-02-03 10:06:53 +0000
commita3bad9513b29aed9518992a4488556788a4248a6 (patch)
treee7924f8fc42d75d781487fff204b885dea2387e7 /get_str.c
parenteddbad0b931c43cfbca69f0e1b43396ddbc3ebbb (diff)
downloadmpfr-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.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/get_str.c b/get_str.c
index 13beb3672..fd9e99ff4 100644
--- a/get_str.c
+++ b/get_str.c
@@ -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;