diff options
author | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2005-01-28 13:10:04 +0000 |
---|---|---|
committer | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2005-01-28 13:10:04 +0000 |
commit | 9d4f9c68087fa59863e55d732628e64ad6cda0b7 (patch) | |
tree | 2fd5d1da62021768445bd1ce8a8c6c5f88152569 /sin.c | |
parent | 4c1dfbe12f23a67022313cd735f8743c848c060b (diff) | |
download | mpfr-9d4f9c68087fa59863e55d732628e64ad6cda0b7.tar.gz |
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
Diffstat (limited to 'sin.c')
-rw-r--r-- | sin.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -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 <stdio.h> + #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); } } |