summaryrefslogtreecommitdiff
path: root/asin.c
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2004-05-06 12:37:21 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2004-05-06 12:37:21 +0000
commit192543932ca7ce494da0f1956475996bdd09e107 (patch)
treef18814d29b14a45058def73e1f97a2dcba103d9f /asin.c
parent4a3ec96bc477f258f2fab8bac31a7ec5059b09ce (diff)
downloadmpfr-192543932ca7ce494da0f1956475996bdd09e107.tar.gz
Fix overflow and add corresponding tests.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2908 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'asin.c')
-rw-r--r--asin.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/asin.c b/asin.c
index 05d3d10c5..88208e7bf 100644
--- a/asin.c
+++ b/asin.c
@@ -84,6 +84,8 @@ mpfr_asin (mpfr_ptr asin, mpfr_srcptr x, mp_rnd_t rnd_mode)
return inexact;
}
+ mpfr_save_emin_emax ();
+
prec_asin = MPFR_PREC(asin);
mpfr_ui_sub (xp, 1, xp, GMP_RNDD);
@@ -94,7 +96,7 @@ mpfr_asin (mpfr_ptr asin, mpfr_srcptr x, mp_rnd_t rnd_mode)
mpfr_init (arcs);
/* use asin(x) = atan(x/sqrt(1-x^2)) */
- while (1)
+ for (;;)
{
estimated_delta = 1 + supplement;
Prec = realprec+estimated_delta;
@@ -107,19 +109,19 @@ mpfr_asin (mpfr_ptr asin, mpfr_srcptr x, mp_rnd_t rnd_mode)
mpfr_sqrt (tmp, tmp, GMP_RNDN);
mpfr_div (tmp, x, tmp, GMP_RNDN);
mpfr_atan (arcs, tmp, GMP_RNDN);
- if (!mpfr_can_round (arcs, realprec, GMP_RNDN, GMP_RNDZ,
+ if (mpfr_can_round (arcs, realprec, GMP_RNDN, GMP_RNDZ,
MPFR_PREC(asin) + (rnd_mode == GMP_RNDN)))
- realprec += __gmpfr_ceil_log2 ((double) realprec);
- else
break;
+ realprec += __gmpfr_ceil_log2 ((double) realprec);
}
inexact = mpfr_set (asin, arcs, rnd_mode);
mpfr_clear (tmp);
mpfr_clear (arcs);
-
mpfr_clear (xp);
- return inexact;
+ mpfr_restore_emin_emax ();
+
+ return mpfr_check_range (asin, inexact, rnd_mode);
}