summaryrefslogtreecommitdiff
path: root/tests/tlngamma.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2014-01-22 10:41:11 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2014-01-22 10:41:11 +0000
commitff04a256e66479b6d66c5c73d433207a473d6692 (patch)
tree25eb9c3afbda6b66b3b70f74fb929d9f5da9392d /tests/tlngamma.c
parent1caacc5971ea0d1cf11f709558b45ed919f239d3 (diff)
downloadmpfr-ff04a256e66479b6d66c5c73d433207a473d6692.tar.gz
[src/lngamma.c] Fixed divide-by-zero flag for negative integers.
[tests/tlngamma.c] Test the flags for some special values. Clean-up. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@8847 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tlngamma.c')
-rw-r--r--tests/tlngamma.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/tests/tlngamma.c b/tests/tlngamma.c
index f28b46709..282ca73e7 100644
--- a/tests/tlngamma.c
+++ b/tests/tlngamma.c
@@ -44,24 +44,28 @@ special (void)
}
mpfr_set_inf (x, 1);
+ mpfr_clear_flags ();
mpfr_lngamma (y, x, MPFR_RNDN);
- if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0)
+ if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 || __gmpfr_flags != 0)
{
printf ("Error for lngamma(+Inf)\n");
exit (1);
}
mpfr_set_inf (x, -1);
+ mpfr_clear_flags ();
mpfr_lngamma (y, x, MPFR_RNDN);
- if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0)
+ if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 || __gmpfr_flags != 0)
{
printf ("Error for lngamma(-Inf)\n");
exit (1);
}
mpfr_set_ui (x, 0, MPFR_RNDN);
+ mpfr_clear_flags ();
mpfr_lngamma (y, x, MPFR_RNDN);
- if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0)
+ if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 ||
+ __gmpfr_flags != MPFR_FLAGS_DIVBY0)
{
printf ("Error for lngamma(+0)\n");
exit (1);
@@ -69,16 +73,19 @@ special (void)
mpfr_set_ui (x, 0, MPFR_RNDN);
mpfr_neg (x, x, MPFR_RNDN);
+ mpfr_clear_flags ();
mpfr_lngamma (y, x, MPFR_RNDN);
- if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0)
+ if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 ||
+ __gmpfr_flags != MPFR_FLAGS_DIVBY0)
{
printf ("Error for lngamma(-0)\n");
exit (1);
}
mpfr_set_ui (x, 1, MPFR_RNDN);
+ mpfr_clear_flags ();
mpfr_lngamma (y, x, MPFR_RNDN);
- if (MPFR_IS_NAN (y) || mpfr_cmp_ui (y, 0) || MPFR_IS_NEG (y))
+ if (mpfr_cmp_ui0 (y, 0) || MPFR_IS_NEG (y))
{
printf ("Error for lngamma(1)\n");
exit (1);
@@ -89,8 +96,10 @@ special (void)
int c;
mpfr_set_si (x, -i, MPFR_RNDN);
+ mpfr_clear_flags ();
mpfr_lngamma (y, x, MPFR_RNDN);
- if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0)
+ if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 ||
+ __gmpfr_flags != MPFR_FLAGS_DIVBY0)
{
printf ("Error for lngamma(-%d)\n", i);
exit (1);
@@ -115,7 +124,7 @@ special (void)
mpfr_set_ui (x, 2, MPFR_RNDN);
mpfr_lngamma (y, x, MPFR_RNDN);
- if (MPFR_IS_NAN (y) || mpfr_cmp_ui (y, 0) || MPFR_IS_NEG (y))
+ if (mpfr_cmp_ui0 (y, 0) || MPFR_IS_NEG (y))
{
printf ("Error for lngamma(2)\n");
exit (1);
@@ -145,7 +154,7 @@ special (void)
mpfr_set_str (x, CHECK_X2, 10, MPFR_RNDN);
mpfr_lngamma (y, x, MPFR_RNDN);
mpfr_set_str (x, CHECK_Y2, 10, MPFR_RNDN);
- if (MPFR_IS_NAN (y) || mpfr_cmp (y, x))
+ if (mpfr_cmp0 (y, x))
{
printf ("mpfr_lngamma("CHECK_X2") is wrong:\n"
"expected ");
@@ -161,7 +170,7 @@ special (void)
mpfr_lngamma (y, x, MPFR_RNDU);
mpfr_set_prec (x, 175);
mpfr_set_str_binary (x, "0.1010001100011101101011001101110010100001000001000001110011000001101100001111001001000101011011100100010101011110100111110101010100010011010010000101010111001100011000101111E7");
- if (MPFR_IS_NAN (y) || mpfr_cmp (x, y))
+ if (mpfr_cmp0 (x, y))
{
printf ("Error in mpfr_lngamma (1)\n");
exit (1);
@@ -173,7 +182,7 @@ special (void)
mpfr_lngamma (x, y, MPFR_RNDZ);
mpfr_set_prec (y, 21);
mpfr_set_str_binary (y, "0.111000101000001100101E9");
- if (MPFR_IS_NAN (x) || mpfr_cmp (x, y))
+ if (mpfr_cmp0 (x, y))
{
printf ("Error in mpfr_lngamma (120)\n");
printf ("Expected "); mpfr_print_binary (y); puts ("");
@@ -187,7 +196,7 @@ special (void)
inex = mpfr_lngamma (y, x, MPFR_RNDN);
mpfr_set_prec (x, 206);
mpfr_set_str_binary (x, "0.10000111011000000011100010101001100110001110000111100011000100100110110010001011011110101001111011110110000001010100111011010000000011100110110101100111000111010011110010000100010111101010001101000110101001E13");
- if (MPFR_IS_NAN (y) || mpfr_cmp (x, y))
+ if (mpfr_cmp0 (x, y))
{
printf ("Error in mpfr_lngamma (768)\n");
exit (1);
@@ -203,7 +212,7 @@ special (void)
mpfr_set_str_binary (x, "0.1100E-66");
mpfr_lngamma (y, x, MPFR_RNDN);
mpfr_set_str_binary (x, "0.1100E6");
- if (MPFR_IS_NAN (y) || mpfr_cmp (x, y))
+ if (mpfr_cmp0 (x, y))
{
printf ("Error for lngamma(0.1100E-66)\n");
exit (1);
@@ -217,7 +226,7 @@ special (void)
mpfr_lngamma (y, x, MPFR_RNDN);
mpfr_set_prec (x, 32);
mpfr_set_str_binary (x, "-0.10001000111011111011000010100010E207");
- if (MPFR_IS_NAN (y) || mpfr_cmp (x, y))
+ if (mpfr_cmp0 (x, y))
{
printf ("Error for lngamma(-2^199+0.5)\n");
printf ("Got ");