summaryrefslogtreecommitdiff
path: root/cos.c
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2004-05-04 15:46:42 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2004-05-04 15:46:42 +0000
commitc1e8d70fa718233a127753dfe3220ceb547a53df (patch)
tree6d96050240cebab2c1706a4686c65b4da91432e6 /cos.c
parent6188785ed16425e8c3d9474098987af936bd9e8e (diff)
downloadmpfr-c1e8d70fa718233a127753dfe3220ceb547a53df.tar.gz
Fix a critical bug in cos in case you have set the float range for the exponents.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2895 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'cos.c')
-rw-r--r--cos.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/cos.c b/cos.c
index c0177d2ec..dd04f4af2 100644
--- a/cos.c
+++ b/cos.c
@@ -19,6 +19,7 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
+#include <stdio.h>
#include "mpfr-impl.h"
static int mpfr_cos2_aux _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr));
@@ -43,6 +44,8 @@ mpfr_cos (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
}
}
+ mpfr_save_emin_emax ();
+
precy = MPFR_PREC(y);
K0 = __gmpfr_isqrt(precy / 2);
@@ -85,11 +88,12 @@ mpfr_cos (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
mpfr_set_prec (s, m);
}
- inexact = mpfr_set (y, s, rnd_mode);
+ mpfr_restore_emin_emax ();
+ inexact = mpfr_set (y, s, rnd_mode); /* FIXME: Dont' need check range? */
mpfr_clear (r);
mpfr_clear (s);
-
+
return inexact;
}
@@ -105,7 +109,7 @@ mpfr_cos2_aux (mpfr_ptr s, mpfr_srcptr r)
long int prec, m = MPFR_PREC(s);
mpfr_t t;
- MPFR_ASSERTD (MPFR_GET_EXP (r) <= 0);
+ MPFR_ASSERTN (MPFR_GET_EXP (r) <= 0);
mpfr_init2 (t, m);
mpfr_set_ui (t, 1, GMP_RNDN);