diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-09-28 08:13:29 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-09-28 08:13:29 +0000 |
commit | f7b738cb900737646435336e5932c089a4e3c32f (patch) | |
tree | 4ab47d8c518aa6e86216b3451c7f415ed217658a /Build/source/libs/mpfr/mpfr-src/src/sub1.c | |
parent | 460968dd6d10a96729c24a3f37e1f54928c39603 (diff) |
mpfr 3.1.5
git-svn-id: svn://tug.org/texlive/trunk@42168 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/mpfr/mpfr-src/src/sub1.c')
-rw-r--r-- | Build/source/libs/mpfr/mpfr-src/src/sub1.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Build/source/libs/mpfr/mpfr-src/src/sub1.c b/Build/source/libs/mpfr/mpfr-src/src/sub1.c index b00c4cd7cfc..cf361393876 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/sub1.c +++ b/Build/source/libs/mpfr/mpfr-src/src/sub1.c @@ -96,16 +96,15 @@ mpfr_sub1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode) /* A = S*ABS(B) +/- ulp(a) */ MPFR_SET_EXP (a, MPFR_GET_EXP (b)); MPFR_RNDRAW_EVEN (inexact, a, MPFR_MANT (b), MPFR_PREC (b), - rnd_mode, MPFR_SIGN (a), - if (MPFR_UNLIKELY ( ++MPFR_EXP (a) > __gmpfr_emax)) - inexact = mpfr_overflow (a, rnd_mode, MPFR_SIGN (a))); - /* inexact = mpfr_set4 (a, b, rnd_mode, MPFR_SIGN (a)); */ + rnd_mode, MPFR_SIGN (a), ++ MPFR_EXP (a)); if (inexact == 0) { /* a = b (Exact) But we know it isn't (Since we have to remove `c') So if we round to Zero, we have to remove one ulp. Otherwise the result is correctly rounded. */ + /* An overflow is not possible. */ + MPFR_ASSERTD (MPFR_EXP (a) <= __gmpfr_emax); if (MPFR_IS_LIKE_RNDZ (rnd_mode, MPFR_IS_NEG (a))) { mpfr_nexttozero (a); @@ -136,9 +135,14 @@ mpfr_sub1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode) i.e. inexact= MPFR_EVEN_INEX */ if (MPFR_UNLIKELY (inexact == MPFR_EVEN_INEX*MPFR_INT_SIGN (a))) { - mpfr_nexttozero (a); + if (MPFR_UNLIKELY (MPFR_EXP (a) > __gmpfr_emax)) + mpfr_setmax (a, __gmpfr_emax); + else + mpfr_nexttozero (a); inexact = -MPFR_INT_SIGN (a); } + else if (MPFR_UNLIKELY (MPFR_EXP (a) > __gmpfr_emax)) + inexact = mpfr_overflow (a, rnd_mode, MPFR_SIGN (a)); MPFR_RET (inexact); } } |