summaryrefslogtreecommitdiff
path: root/tests/tisnan.c
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2004-04-20 09:32:20 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2004-04-20 09:32:20 +0000
commit97724b73df1ca86917d114df64da54152cdfef5e (patch)
treea659ff4f04469673cc9af66b0fe3dbb6fd4e4759 /tests/tisnan.c
parent2b1f5a024237b70c0bde10a682d67ec279479f91 (diff)
downloadmpfr-97724b73df1ca86917d114df64da54152cdfef5e.tar.gz
Add mpfr_zero_p.
Add macros for mpfr_inf_p, mpfr_nan_p and mpfr_zero_p. Add macro for mpfr_sgn. Update doc. Add new tests. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2871 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tisnan.c')
-rw-r--r--tests/tisnan.c61
1 files changed, 52 insertions, 9 deletions
diff --git a/tests/tisnan.c b/tests/tisnan.c
index 7cee98202..edf1e3f02 100644
--- a/tests/tisnan.c
+++ b/tests/tisnan.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_nan_p, mpfr_inf_p and mpfr_number_p.
-Copyright 2001, 2002, 2003 Free Software Foundation.
+Copyright 2001, 2002, 2003, 2004 Free Software Foundation.
This file is part of the MPFR Library.
@@ -36,7 +36,7 @@ main (void)
/* check +infinity gives non-zero for mpfr_inf_p only */
mpfr_set_ui (x, 1L, GMP_RNDZ);
mpfr_div_ui (x, x, 0L, GMP_RNDZ);
- if (mpfr_nan_p (x))
+ if (mpfr_nan_p (x) || (mpfr_nan_p) (x) )
{
printf ("Error: mpfr_nan_p(+Inf) gives non-zero\n");
exit (1);
@@ -46,15 +46,20 @@ main (void)
printf ("Error: mpfr_inf_p(+Inf) gives zero\n");
exit (1);
}
- if (mpfr_number_p (x))
+ if (mpfr_number_p (x) || (mpfr_number_p) (x) )
{
printf ("Error: mpfr_number_p(+Inf) gives non-zero\n");
exit (1);
}
+ if (mpfr_zero_p (x) || (mpfr_zero_p) (x) )
+ {
+ printf ("Error: mpfr_zero_p(+Inf) gives non-zero\n");
+ exit (1);
+ }
/* same for -Inf */
mpfr_neg (x, x, GMP_RNDN);
- if (mpfr_nan_p (x))
+ if (mpfr_nan_p (x) || (mpfr_nan_p(x)))
{
printf ("Error: mpfr_nan_p(-Inf) gives non-zero\n");
exit (1);
@@ -64,11 +69,16 @@ main (void)
printf ("Error: mpfr_inf_p(-Inf) gives zero\n");
exit (1);
}
- if (mpfr_number_p (x))
+ if (mpfr_number_p (x) || (mpfr_number_p)(x) )
{
printf ("Error: mpfr_number_p(-Inf) gives non-zero\n");
exit (1);
}
+ if (mpfr_zero_p (x) || (mpfr_zero_p)(x) )
+ {
+ printf ("Error: mpfr_zero_p(-Inf) gives non-zero\n");
+ exit (1);
+ }
/* same for NaN */
mpfr_sub (x, x, x, GMP_RNDN);
@@ -77,12 +87,17 @@ main (void)
printf ("Error: mpfr_nan_p(NaN) gives zero\n");
exit (1);
}
- if (mpfr_inf_p (x))
+ if (mpfr_inf_p (x) || (mpfr_inf_p)(x) )
{
printf ("Error: mpfr_inf_p(NaN) gives non-zero\n");
exit (1);
}
- if (mpfr_number_p (x))
+ if (mpfr_number_p (x) || (mpfr_number_p) (x) )
+ {
+ printf ("Error: mpfr_number_p(NaN) gives non-zero\n");
+ exit (1);
+ }
+ if (mpfr_zero_p (x) || (mpfr_zero_p)(x) )
{
printf ("Error: mpfr_number_p(NaN) gives non-zero\n");
exit (1);
@@ -90,12 +105,12 @@ main (void)
/* same for an ordinary number */
mpfr_set_ui (x, 1, GMP_RNDN);
- if (mpfr_nan_p (x))
+ if (mpfr_nan_p (x) || (mpfr_nan_p)(x))
{
printf ("Error: mpfr_nan_p(1) gives non-zero\n");
exit (1);
}
- if (mpfr_inf_p (x))
+ if (mpfr_inf_p (x) || (mpfr_inf_p)(x) )
{
printf ("Error: mpfr_inf_p(1) gives non-zero\n");
exit (1);
@@ -105,6 +120,34 @@ main (void)
printf ("Error: mpfr_number_p(1) gives zero\n");
exit (1);
}
+ if (mpfr_zero_p (x) || (mpfr_zero_p) (x) )
+ {
+ printf ("Error: mpfr_zero_p(1) gives non-zero\n");
+ exit (1);
+ }
+
+ /* Same for 0 */
+ mpfr_set_ui (x, 0, GMP_RNDN);
+ if (mpfr_nan_p (x) || (mpfr_nan_p)(x))
+ {
+ printf ("Error: mpfr_nan_p(0) gives non-zero\n");
+ exit (1);
+ }
+ if (mpfr_inf_p (x) || (mpfr_inf_p)(x) )
+ {
+ printf ("Error: mpfr_inf_p(0) gives non-zero\n");
+ exit (1);
+ }
+ if (mpfr_number_p (x) == 0)
+ {
+ printf ("Error: mpfr_number_p(0) gives zero\n");
+ exit (1);
+ }
+ if (mpfr_zero_p (x) == 0 )
+ {
+ printf ("Error: mpfr_zero_p(0) gives zero\n");
+ exit (1);
+ }
mpfr_clear (x);