From 348002c98038cbcc990cd1f76864ea82759fe5f9 Mon Sep 17 00:00:00 2001 From: zimmerma Date: Wed, 26 Aug 2009 20:13:50 +0000 Subject: [csch.c,coth.c,csc.c,cot.c] fixed bug for tiny input and RNDA (result was rounded to zero instead of away) git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@6394 280ebfd0-de03-0410-8827-d642c229c3f4 --- cot.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'cot.c') diff --git a/cot.c b/cot.c index 3c8b605d9..01d6a1196 100644 --- a/cot.c +++ b/cot.c @@ -60,20 +60,22 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., { \ /* Case |x| = 2^emin. 1/x is not representable; so, compute \ 1/(2x) instead (exact), and correct the result later. */ \ - mpfr_set_si_2exp (y, signx, __gmpfr_emax, MPFR_RNDN); \ + mpfr_set_si_2exp (y, signx, __gmpfr_emax, MPFR_RNDN); \ inexact = 0; \ } \ else \ inexact = mpfr_ui_div (y, 1, x, r); \ if (inexact == 0) /* x is a power of two */ \ { /* result always 1/x, except when rounding to zero */ \ + if (rnd_mode == MPFR_RNDA) \ + rnd_mode = (signx > 0) ? MPFR_RNDU : MPFR_RNDD; \ if (rnd_mode == MPFR_RNDU || (rnd_mode == MPFR_RNDZ && signx < 0)) \ { \ if (signx < 0) \ mpfr_nextabove (y); /* -2^k + epsilon */ \ inexact = 1; \ } \ - else if (rnd_mode == MPFR_RNDD || rnd_mode == MPFR_RNDZ) \ + else if (rnd_mode == MPFR_RNDD || rnd_mode == MPFR_RNDZ) \ { \ if (signx > 0) \ mpfr_nextbelow (y); /* 2^k - epsilon */ \ -- cgit v1.2.1