summaryrefslogtreecommitdiff
path: root/gamma.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2007-12-18 15:51:00 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2007-12-18 15:51:00 +0000
commita6043f2d22e376360264317d140406d85c1f3649 (patch)
tree196e725c272f5da0a5843506a28f091ae820e65d /gamma.c
parentbf7ddd19d8dd01f52acc4b5cec744b4a3df96771 (diff)
downloadmpfr-a6043f2d22e376360264317d140406d85c1f3649.tar.gz
Merged the feature-block branch to the trunk:
* New MPFR_BLOCK* macros (see mpfr-impl.h) and mpfrlint check to test exception flags in a more reliable way and detect possible problems with mpfrlint. * Improved the generic tests (tests/tgeneric.c): for the second function call, sometimes set all the flags since risk of failures are known when some flags are already set. * Modified code to use these new MPFR_BLOCK* macros. This fixed bugs related to exceptions (where flags are set before the call); in particular, tcot and ty1 failed with the improved generic tests. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@5115 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'gamma.c')
-rw-r--r--gamma.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/gamma.c b/gamma.c
index 6b9b43006..268163c07 100644
--- a/gamma.c
+++ b/gamma.c
@@ -230,12 +230,11 @@ mpfr_gamma (mpfr_ptr gamma, mpfr_srcptr x, mp_rnd_t rnd_mode)
>= 2 * (x/e)^x / x for x >= 1 */
if (compared > 0)
{
- int overflow;
mpfr_t yp;
+ MPFR_BLOCK_DECL (flags);
/* 1/e rounded down to 53 bits */
#define EXPM1_STR "0.010111100010110101011000110110001011001110111100111"
- mpfr_clear_overflow ();
mpfr_init2 (xp, 53);
mpfr_init2 (yp, 53);
mpfr_set_str_binary (xp, EXPM1_STR);
@@ -245,12 +244,11 @@ mpfr_gamma (mpfr_ptr gamma, mpfr_srcptr x, mp_rnd_t rnd_mode)
mpfr_set_str_binary (yp, EXPM1_STR);
mpfr_mul (xp, xp, yp, GMP_RNDZ); /* x^(x-2) / e^(x-1) */
mpfr_mul (xp, xp, yp, GMP_RNDZ); /* x^(x-2) / e^x */
- mpfr_mul (xp, xp, x, GMP_RNDZ); /* x^(x-1) / e^x */
- mpfr_mul_2ui (xp, xp, 1, GMP_RNDZ);
- overflow = mpfr_overflow_p ();
+ mpfr_mul (xp, xp, x, GMP_RNDZ); /* lower bound on x^(x-1) / e^x */
+ MPFR_BLOCK (flags, mpfr_mul_2ui (xp, xp, 1, GMP_RNDZ));
mpfr_clear (xp);
mpfr_clear (yp);
- return (overflow) ? mpfr_overflow (gamma, rnd_mode, 1)
+ return MPFR_OVERFLOW (flags) ? mpfr_overflow (gamma, rnd_mode, 1)
: mpfr_gamma_aux (gamma, x, rnd_mode);
}