diff options
-rw-r--r-- | get_z.c | 4 | ||||
-rw-r--r-- | tests/tget_z.c | 9 |
2 files changed, 10 insertions, 3 deletions
@@ -30,12 +30,10 @@ mpfr_get_z (mpz_ptr z, mpfr_srcptr f, mp_rnd_t rnd) mp_exp_t exp = MPFR_EXP (f); /* if exp <= 0, then |f|<1, thus |o(f)|<=1 */ - MPFR_ASSERTD (MPFR_PREC_MIN == 2); - mpfr_init2 (r, (exp <= 0) ? MPFR_PREC_MIN : exp + 1); + mpfr_init2 (r, (exp < MPFR_PREC_MIN) ? MPFR_PREC_MIN : exp); mpfr_rint (r, f, rnd); MPFR_ASSERTN (MPFR_IS_FP (r) ); exp = mpfr_get_z_exp (z, r); - /* FIXME: It seems that exp < 0 is always true */ if (exp >= 0) mpz_mul_2exp (z, z, exp); else diff --git a/tests/tget_z.c b/tests/tget_z.c index 9f9fd3cb7..d7f8b4cf5 100644 --- a/tests/tget_z.c +++ b/tests/tget_z.c @@ -43,6 +43,15 @@ check_diff (void) exit (1); } + mpfr_set_prec (x, 6); + mpfr_set_str (x, "17.5", 10, MPFR_RNDN); + mpfr_get_z (z, x, MPFR_RNDN); + if (mpz_cmp_ui (z, 18) != 0) + { + printf ("get_z RN 17.5 failed\n"); + exit (1); + } + /* save default emin */ emin = mpfr_get_emin ();; |