summaryrefslogtreecommitdiff
path: root/exp.c
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2004-05-06 09:56:48 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2004-05-06 09:56:48 +0000
commit8882724bc6d821bea35a606da3a06c2141d87b11 (patch)
tree52476cdc296a0f11c6fa5138828cb87380b9a341 /exp.c
parent0da1a828505078b5321be43088f48b759761605d (diff)
downloadmpfr-8882724bc6d821bea35a606da3a06c2141d87b11.tar.gz
Fix overflow problems.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2905 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'exp.c')
-rw-r--r--exp.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/exp.c b/exp.c
index f4f323ccd..4682896b8 100644
--- a/exp.c
+++ b/exp.c
@@ -31,7 +31,7 @@ MA 02111-1307, USA. */
int
mpfr_exp (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
{
- int expx, precy;
+ int expx, precy, inexact;
double d;
if (MPFR_UNLIKELY( MPFR_IS_SINGULAR(x) ))
@@ -102,8 +102,11 @@ mpfr_exp (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
return -MPFR_FROM_SIGN_TO_INT(signx);
}
- if (precy > MPFR_EXP_THRESHOLD)
- return mpfr_exp_3 (y, x, rnd_mode); /* O(M(n) log(n)^2) */
+ mpfr_save_emin_emax ();
+ if (MPFR_UNLIKELY(precy > MPFR_EXP_THRESHOLD))
+ inexact = mpfr_exp_3 (y, x, rnd_mode); /* O(M(n) log(n)^2) */
else
- return mpfr_exp_2 (y, x, rnd_mode); /* O(n^(1/3) M(n)) */
+ inexact = mpfr_exp_2 (y, x, rnd_mode); /* O(n^(1/3) M(n)) */
+ mpfr_restore_emin_emax ();
+ return mpfr_check_range (y, inexact, rnd_mode);
}