From 1fa2277c10582baa8b8402b8cf1702116ccbc560 Mon Sep 17 00:00:00 2001 From: zimmerma Date: Tue, 14 Oct 2003 11:49:06 +0000 Subject: replaced mpfr_can_round (approx, err, rnd1, GMP_RNDN, prec) by mpfr_can_round (approx, err, rnd1, GMP_RNDZ, prec + 1) which in addition guarantees a correct inexact flag git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2492 280ebfd0-de03-0410-8827-d642c229c3f4 --- const_euler.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'const_euler.c') diff --git a/const_euler.c b/const_euler.c index 0334f328b..97930751c 100644 --- a/const_euler.c +++ b/const_euler.c @@ -36,6 +36,7 @@ mpfr_const_euler (mpfr_t x, mp_rnd_t rnd) mp_prec_t prec = MPFR_PREC(x), m, log2m; mpfr_t y, z; unsigned long n; + int inexact; log2m = __gmpfr_ceil_log2 ((double) prec); m = prec + log2m; @@ -60,14 +61,15 @@ mpfr_const_euler (mpfr_t x, mp_rnd_t rnd) mpfr_const_euler_R (z, n); mpfr_sub (y, y, z, GMP_RNDN); } - while (!mpfr_can_round (y, m - 3, GMP_RNDN, rnd, prec)); + while (!mpfr_can_round (y, m - 3, GMP_RNDN, GMP_RNDZ, + prec + (rnd == GMP_RNDN))); - mpfr_set (x, y, rnd); + inexact = mpfr_set (x, y, rnd); mpfr_clear (y); mpfr_clear (z); - return 1; /* always inexact */ + return inexact; /* always inexact */ } /* computes S(n) = sum(n^k*(-1)^(k-1)/k!/k, k=1..ceil(4.319136566 * n)) -- cgit v1.2.1