From fded832d73678419307c2e87e68e8737276b65c4 Mon Sep 17 00:00:00 2001 From: pelissip Date: Thu, 9 Dec 2004 10:13:55 +0000 Subject: Optimize mpfr_set4. Inline rounding in mpfr_set4 and mpfr_cache mpfr_set4 dosn't return MPFR_EVEN_INEX (It was undocumented before). Fix problems with tests (Avoid mixing MPFR_EVEN_INEX and 1). Add MPFR_RNDRAW_EVEN for rounding with MPFR_EVEN_INEX inexact support git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3121 280ebfd0-de03-0410-8827-d642c229c3f4 --- cache.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'cache.c') diff --git a/cache.c b/cache.c index 0034cb151..768619179 100644 --- a/cache.c +++ b/cache.c @@ -47,7 +47,7 @@ mpfr_cache (mpfr_ptr dest, mpfr_cache_t cache, mp_rnd_t rnd) { mp_prec_t prec = MPFR_PREC (dest); mp_prec_t pold = MPFR_PREC (cache->x); - int inexact; + int inexact, sign; /* Check if the cache has been already filled */ if (MPFR_UNLIKELY(pold == 0)) @@ -71,8 +71,16 @@ mpfr_cache (mpfr_ptr dest, mpfr_cache_t cache, mp_rnd_t rnd) and abs(x-exact) <= ulp(x)/2 */ MPFR_ASSERTD (MPFR_IS_POS(cache->x)); /* TODO...*/ /* We must use nextbelow instead of sub_one_ulp, since we know - that the exact value is < 1/2ulp(x) (We want sub_demi_ulp(x)). */ - inexact = mpfr_set (dest, cache->x, rnd); + that the exact value is < 1/2ulp(x) (We want sub_demi_ulp(x)). + Can't use mpfr_set since we need the even flag. */ + sign = MPFR_SIGN (cache->x); + MPFR_SET_EXP (dest, MPFR_GET_EXP (cache->x)); + MPFR_SET_SIGN (dest, sign); + MPFR_RNDRAW_EVEN (inexact, dest, + MPFR_MANT (cache->x), MPFR_PREC (cache->x), rnd, sign, + if (MPFR_UNLIKELY ( ++MPFR_EXP (dest) > __gmpfr_emax)) + mpfr_set_overflow (dest, rnd, sign) ); + /* inexact = mpfr_set (dest, cache->x, rnd); */ if (MPFR_LIKELY(cache->inexact != 0)) { switch (rnd) -- cgit v1.2.1