summaryrefslogtreecommitdiff
path: root/cot.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2007-06-28 11:54:41 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2007-06-28 11:54:41 +0000
commit8d5f44e87eff5f213762fa096be2cc3a9b48a050 (patch)
treead3d90ac8c7094f91d40349125beb6ba611c07a1 /cot.c
parenteafe839ea1ae31ba32c6c622713a1f7e081a0814 (diff)
downloadmpfr-8d5f44e87eff5f213762fa096be2cc3a9b48a050.tar.gz
cot.c: use MPFR_SAVE_EXPO_UPDATE_FLAGS, but the case +/- 2^emin could
still be buggy with the current code; added a MPFR_ASSERTN (0) until it is implemented. BUGS: updated item on mpfr_cot. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@4575 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'cot.c')
-rw-r--r--cot.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/cot.c b/cot.c
index fa8971296..f32e68115 100644
--- a/cot.c
+++ b/cot.c
@@ -45,11 +45,20 @@ MA 02110-1301, USA. */
Since |cot(x) - 1/x| <= 0.36, if 2^(-2n) ufp(y) >= 0.72, then
|y - cot(x)| >= 2^(-2n-1) ufp(y), and rounding 1/x gives the correct
result. If x < 2^E, then y > 2^(-E), thus ufp(y) > 2^(-E-1).
- A sufficient condition is thus EXP(x) + 1 <= -2 MAX(PREC(x),PREC(Y)). */
+ A sufficient condition is thus EXP(x) + 1 <= -2 MAX(PREC(x),PREC(Y)).
+ The division can be inexact in case of underflow or overflow; but
+ an underflow is not possible as emin = - emax. The overflow is a
+ real overflow possibly except when |x| = 2^emin. */
#define ACTION_TINY(y,x,r) \
if (MPFR_EXP(x) + 1 <= -2 * (mp_exp_t) MAX(MPFR_PREC(x), MPFR_PREC(y))) \
{ \
int signx = MPFR_SIGN(x); \
+ if (mpfr_get_exp (x) == __gmpfr_emin+1 && \
+ mpfr_powerof2_raw (x)) \
+ { \
+ /* Case |x| = 2^emin. */ \
+ MPFR_ASSERTN (0); /* TODO (and add test) */ \
+ } \
inexact = mpfr_ui_div (y, 1, x, r); \
if (inexact == 0) /* x is a power of two */ \
{ /* result always 1/x, except when rounding to zero */ \
@@ -68,6 +77,10 @@ MA 02110-1301, USA. */
else /* round to nearest */ \
inexact = signx; \
} \
+ MPFR_ASSERTN (MPFR_EMIN_MIN + MPFR_EMAX_MAX == 0); \
+ /* Underflow is not possible with emin = - emax. */ \
+ MPFR_ASSERTN (! mpfr_underflow_p ()); \
+ MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags); \
goto end; \
}