summaryrefslogtreecommitdiff
path: root/Build/source/libs/mpfr/mpfr-src/src/fits_intmax.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/mpfr/mpfr-src/src/fits_intmax.c')
-rw-r--r--Build/source/libs/mpfr/mpfr-src/src/fits_intmax.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/Build/source/libs/mpfr/mpfr-src/src/fits_intmax.c b/Build/source/libs/mpfr/mpfr-src/src/fits_intmax.c
index c3d072a228d..b3ad9f18276 100644
--- a/Build/source/libs/mpfr/mpfr-src/src/fits_intmax.c
+++ b/Build/source/libs/mpfr/mpfr-src/src/fits_intmax.c
@@ -1,7 +1,7 @@
/* mpfr_fits_intmax_p -- test whether an mpfr fits an intmax_t.
-Copyright 2004, 2006-2015 Free Software Foundation, Inc.
-Contributed by the AriC and Caramel projects, INRIA.
+Copyright 2004, 2006-2016 Free Software Foundation, Inc.
+Contributed by the AriC and Caramba projects, INRIA.
This file is part of the GNU MPFR Library.
@@ -33,6 +33,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
int
mpfr_fits_intmax_p (mpfr_srcptr f, mpfr_rnd_t rnd)
{
+ unsigned int saved_flags;
mpfr_exp_t e;
int prec;
mpfr_t x, y;
@@ -85,6 +86,7 @@ mpfr_fits_intmax_p (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);
@@ -97,10 +99,16 @@ mpfr_fits_intmax_p (mpfr_srcptr f, mpfr_rnd_t rnd)
}
else
{
- 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;
}