diff options
Diffstat (limited to 'cot.c')
-rw-r--r-- | cot.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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 */ \ |