summaryrefslogtreecommitdiff
path: root/Build/source/libs/mpfr/mpfr-src/src/fits_u.h
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/mpfr/mpfr-src/src/fits_u.h')
-rw-r--r--Build/source/libs/mpfr/mpfr-src/src/fits_u.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/Build/source/libs/mpfr/mpfr-src/src/fits_u.h b/Build/source/libs/mpfr/mpfr-src/src/fits_u.h
index ed837a29bc9..9f97c30c6aa 100644
--- a/Build/source/libs/mpfr/mpfr-src/src/fits_u.h
+++ b/Build/source/libs/mpfr/mpfr-src/src/fits_u.h
@@ -1,7 +1,7 @@
/* mpfr_fits_*_p -- test whether an mpfr fits a C unsigned type.
-Copyright 2003-2015 Free Software Foundation, Inc.
-Contributed by the AriC and Caramel projects, INRIA.
+Copyright 2003-2016 Free Software Foundation, Inc.
+Contributed by the AriC and Caramba projects, INRIA.
This file is part of the GNU MPFR Library.
@@ -25,6 +25,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
int
FUNCTION (mpfr_srcptr f, mpfr_rnd_t rnd)
{
+ unsigned int saved_flags;
mpfr_exp_t e;
int prec;
TYPE s;
@@ -62,9 +63,16 @@ FUNCTION (mpfr_srcptr f, mpfr_rnd_t rnd)
MPFR_ASSERTD (e == prec);
/* hard case: first round to prec bits, then check */
+ saved_flags = __gmpfr_flags;
mpfr_init2 (x, prec);
mpfr_set (x, f, rnd);
- res = MPFR_GET_EXP (x) == e;
+ /* Warning! Due to the rounding, x can be an infinity. Here we use
+ the fact that singular numbers have a special exponent field,
+ thus well-defined and different from e, in which case this means
+ that the number does not fit. That's why we use MPFR_EXP, not
+ MPFR_GET_EXP. */
+ res = MPFR_EXP (x) == e;
mpfr_clear (x);
+ __gmpfr_flags = saved_flags;
return res;
}