summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2016-02-05 12:15:10 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2016-02-05 12:15:10 +0000
commit2967ea066e0f54c05706c372da8cda3f055346d7 (patch)
treed6383b210db48f52e5cb11fd6977da4f8a3510ed
parent4ede914b82da8b3dd721b99cd5087b2910a0f15d (diff)
downloadmpfr-2967ea066e0f54c05706c372da8cda3f055346d7.tar.gz
[src/exceptions.c] Some changes concerning mpfr_check_range:
* Added a note about the case EXP(x) < MPFR_EMIN_MIN. * Do not use the MPFR_IS_PURE_FP() macro as this macro assumes that if the number is not a singular number, then it is really a pure FP number (some assertion checking may be done in debug mode), but this is not necessarily the case here. * Removed an incorrect comment and re-added the MPFR_UNLIKELY for the cases where EXP(x) is outside the exponent range. Indeed, mpfr_check_range is called at the end of most functions, and in most cases, there are no underflows / overflows. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@9963 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--src/exceptions.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/exceptions.c b/src/exceptions.c
index 6ea08668c..ffcf3e0c6 100644
--- a/src/exceptions.c
+++ b/src/exceptions.c
@@ -256,16 +256,18 @@ mpfr_set_erangeflag (void)
#undef mpfr_check_range
+/* Note: It is possible that for pure FP numbers, EXP(x) < MPFR_EMIN_MIN,
+ but the caller must make sure that the difference remains small enough
+ to avoid reaching the special exponent values. */
int
mpfr_check_range (mpfr_ptr x, int t, mpfr_rnd_t rnd_mode)
{
- if (MPFR_LIKELY( MPFR_IS_PURE_FP(x)) )
+ if (MPFR_LIKELY (! MPFR_IS_SINGULAR (x)))
{ /* x is a non-zero FP */
mpfr_exp_t exp = MPFR_EXP (x); /* Do not use MPFR_GET_EXP */
- /* Even if it is unlikely that exp is lower than emin,
- this function is called by MPFR functions only if it is
- already the case (or if exp is greater than emax) */
- if (exp < __gmpfr_emin)
+
+ MPFR_ASSERTD (MPFR_IS_NORMALIZED (x));
+ if (MPFR_UNLIKELY (exp < __gmpfr_emin))
{
/* The following test is necessary because in the rounding to the
* nearest mode, mpfr_underflow always rounds away from 0. In
@@ -279,9 +281,9 @@ mpfr_check_range (mpfr_ptr x, int t, mpfr_rnd_t rnd_mode)
(mpfr_powerof2_raw(x) &&
(MPFR_IS_NEG(x) ? t <= 0 : t >= 0))))
rnd_mode = MPFR_RNDZ;
- return mpfr_underflow(x, rnd_mode, MPFR_SIGN(x));
+ return mpfr_underflow (x, rnd_mode, MPFR_SIGN(x));
}
- if (exp > __gmpfr_emax)
+ if (MPFR_UNLIKELY (exp > __gmpfr_emax))
return mpfr_overflow (x, rnd_mode, MPFR_SIGN(x));
}
else if (MPFR_UNLIKELY (t != 0 && MPFR_IS_INF (x)))