From 2613a24674a08b8e4eb7fa722ac8ab6c432145c4 Mon Sep 17 00:00:00 2001 From: vlefevre Date: Mon, 24 Aug 2015 01:37:59 +0000 Subject: [src/{fits_intmax.c,fits_s.h,fits_u.h}] Fixed mpfr_fits_* functions: the flags could be modified, which made the new mpfr_get_{si,ui} tests fail (tests/tset_si.c r9649). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@9650 280ebfd0-de03-0410-8827-d642c229c3f4 --- src/fits_intmax.c | 3 +++ src/fits_s.h | 3 +++ src/fits_u.h | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/fits_intmax.c b/src/fits_intmax.c index fa4cdf039..e3c6d6d56 100644 --- a/src/fits_intmax.c +++ b/src/fits_intmax.c @@ -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) { + mpfr_flags_t 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); @@ -101,6 +103,7 @@ mpfr_fits_intmax_p (mpfr_srcptr f, mpfr_rnd_t rnd) } mpfr_clear (x); + __gmpfr_flags = saved_flags; return res; } diff --git a/src/fits_s.h b/src/fits_s.h index 0dd77fb45..b93d7a0db 100644 --- a/src/fits_s.h +++ b/src/fits_s.h @@ -29,6 +29,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., int FUNCTION (mpfr_srcptr f, mpfr_rnd_t rnd) { + mpfr_flags_t saved_flags; mpfr_exp_t e; int prec; mpfr_t x; @@ -81,9 +82,11 @@ 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 = neg ? (mpfr_cmp_si (x, MINIMUM) >= 0) : (MPFR_GET_EXP (x) == e); mpfr_clear (x); + __gmpfr_flags = saved_flags; return res; } diff --git a/src/fits_u.h b/src/fits_u.h index ed837a29b..3446b21a6 100644 --- a/src/fits_u.h +++ b/src/fits_u.h @@ -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) { + mpfr_flags_t saved_flags; mpfr_exp_t e; int prec; TYPE s; @@ -62,9 +63,11 @@ 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; mpfr_clear (x); + __gmpfr_flags = saved_flags; return res; } -- cgit v1.2.1