From 9d4f9c68087fa59863e55d732628e64ad6cda0b7 Mon Sep 17 00:00:00 2001 From: pelissip Date: Fri, 28 Jan 2005 13:10:04 +0000 Subject: Much faster worst case (ie result near 0 or 1). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3237 280ebfd0-de03-0410-8827-d642c229c3f4 --- sin.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'sin.c') diff --git a/sin.c b/sin.c index d4d830e6f..72e31938e 100644 --- a/sin.c +++ b/sin.c @@ -19,6 +19,8 @@ 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 + #define MPFR_NEED_LONGLONG_H #include "mpfr-impl.h" @@ -148,6 +150,13 @@ mpfr_sin (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) if (ok == 0) { m += BITS_PER_MP_LIMB; + /* check for huge cancellation */ + if (e < (mp_exp_t) MPFR_PREC (y)) + m += MPFR_PREC (y) - e; + /* Check if near 1 */ + if (MPFR_GET_EXP (c) == 1 + && MPFR_MANT (c)[MPFR_LIMB_SIZE (c)-1] == MPFR_LIMB_HIGHBIT) + m = 2*m; mpfr_set_prec (c, m); } } -- cgit v1.2.1