diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2012-04-27 12:27:09 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2012-04-27 12:27:09 +0000 |
commit | ba8a7704452e7e9b346a5af2491949357d1dffef (patch) | |
tree | a4636948ba397d875d84faf9bf4309f1da0a590a /tests | |
parent | 8089e0094529397c5c37b74800f0bcc44c423aa3 (diff) | |
download | mpfr-ba8a7704452e7e9b346a5af2491949357d1dffef.tar.gz |
[tests/tgamma.c] Updated testcase test20100709 for 64-bit machines,
as this bug reappeared in r8159.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@8162 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tgamma.c | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/tests/tgamma.c b/tests/tgamma.c index 7dd20bb61..89ca96dd2 100644 --- a/tests/tgamma.c +++ b/tests/tgamma.c @@ -461,18 +461,59 @@ test20071231 (void) mpfr_clear (x); } -/* bug found by Stathis, only occurs on 32-bit machines */ +/* bug found by Stathis in mpfr_gamma, only occurs on 32-bit machines; + the second test is for 64-bit machines. This bug reappeared due to + r8159. */ static void test20100709 (void) { - mpfr_t x; + mpfr_t x, y, z; + int sign; int inex; + mpfr_exp_t emin; mpfr_init2 (x, 100); + mpfr_init2 (y, 32); + mpfr_init2 (z, 32); mpfr_set_str (x, "-4.6308260837372266e+07", 10, MPFR_RNDN); + mpfr_set_ui (y, 0, MPFR_RNDN); + mpfr_nextabove (y); + mpfr_log (y, y, MPFR_RNDD); + mpfr_const_log2 (z, MPFR_RNDU); + mpfr_sub (y, y, z, MPFR_RNDD); /* log(MIN/2) = log(MIN) - log(2) */ + mpfr_lgamma (z, &sign, x, MPFR_RNDU); + MPFR_ASSERTN (sign == -1); + MPFR_ASSERTN (mpfr_less_p (z, y)); /* thus underflow */ inex = mpfr_gamma (x, x, MPFR_RNDN); - MPFR_ASSERTN(MPFR_IS_ZERO(x) && MPFR_IS_NEG(x) && inex > 0); + MPFR_ASSERTN (MPFR_IS_ZERO(x) && MPFR_IS_NEG(x) && inex > 0); + mpfr_clear (x); + mpfr_clear (y); + mpfr_clear (z); + + /* Similar bug for 64-bit machines. */ + emin = mpfr_get_emin (); + mpfr_set_emin (MPFR_EMIN_MIN); + mpfr_init2 (x, 100); + mpfr_init2 (y, 32); + mpfr_init2 (z, 32); + mpfr_set_str (x, "-90.6308260837372266e+15", 10, MPFR_RNDN); + mpfr_set_ui (y, 0, MPFR_RNDN); + mpfr_nextabove (y); + mpfr_log (y, y, MPFR_RNDD); + mpfr_const_log2 (z, MPFR_RNDU); + mpfr_sub (y, y, z, MPFR_RNDD); /* log(MIN/2) = log(MIN) - log(2) */ + mpfr_lgamma (z, &sign, x, MPFR_RNDU); + MPFR_ASSERTN (sign == -1); + if (mpfr_less_p (z, y)) /* true on 64-bit machines */ + { + /* thus underflow */ + inex = mpfr_gamma (x, x, MPFR_RNDN); + MPFR_ASSERTN (MPFR_IS_ZERO(x) && MPFR_IS_NEG(x) && inex > 0); + } mpfr_clear (x); + mpfr_clear (y); + mpfr_clear (z); + mpfr_set_emin (emin); } /* bug found by Giridhar Tammana */ |