diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-09-25 08:15:42 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-09-25 08:15:42 +0000 |
commit | fd5e5221f3d42f1d1e29d99a15ac43a76460bf9b (patch) | |
tree | 332aef339e58cafd2dc32ee33efc6e2cbb66852a /tests/tabs.c | |
parent | 788b255e420f8d4ba0f0b43ce87b00b62d60a896 (diff) | |
download | mpfr-fd5e5221f3d42f1d1e29d99a15ac43a76460bf9b.tar.gz |
Changed the remaining stderr to stdout.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2449 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tabs.c')
-rw-r--r-- | tests/tabs.c | 174 |
1 files changed, 89 insertions, 85 deletions
diff --git a/tests/tabs.c b/tests/tabs.c index f0845f2d1..ab571900f 100644 --- a/tests/tabs.c +++ b/tests/tabs.c @@ -41,7 +41,7 @@ check_inexact (void) mpfr_init (x); mpfr_init (y); mpfr_init (absx); - + for (p=2; p<500; p++) { mpfr_set_prec (x, p); @@ -55,24 +55,25 @@ check_inexact (void) else mpfr_set (absx, x, GMP_RNDN); for (q=2; q<2*p; q++) - { - mpfr_set_prec (y, q); - for (rnd=0; rnd<4; rnd++) - { - inexact = mpfr_abs (y, x, rnd); - cmp = mpfr_cmp (y, absx); - if (((inexact == 0) && (cmp != 0)) || - ((inexact > 0) && (cmp <= 0)) || - ((inexact < 0) && (cmp >= 0))) - { - fprintf (stderr, "Wrong inexact flag: expected %d, got %d\n", cmp, inexact); - printf ("x="); mpfr_print_binary (x); puts (""); - printf ("absx="); mpfr_print_binary (absx); puts (""); - printf ("y="); mpfr_print_binary (y); puts (""); - exit (1); - } - } - } + { + mpfr_set_prec (y, q); + for (rnd=0; rnd<4; rnd++) + { + inexact = mpfr_abs (y, x, rnd); + cmp = mpfr_cmp (y, absx); + if (((inexact == 0) && (cmp != 0)) || + ((inexact > 0) && (cmp <= 0)) || + ((inexact < 0) && (cmp >= 0))) + { + printf ("Wrong inexact flag: expected %d, got %d\n", + cmp, inexact); + printf ("x="); mpfr_print_binary (x); puts (""); + printf ("absx="); mpfr_print_binary (absx); puts (""); + printf ("y="); mpfr_print_binary (y); puts (""); + exit (1); + } + } + } } mpfr_clear (x); @@ -83,73 +84,76 @@ check_inexact (void) int main (int argc, char *argv[]) { - mpfr_t x; - int n, k, rnd; - double d, absd, dd; - - mpfr_test_init (); - - check_inexact (); - - mpfr_init2(x, 53); - - mpfr_set_d(x, 1.0, GMP_RNDN); - mpfr_abs(x, x, GMP_RNDN); - if (mpfr_get_d1 (x) != 1.0) { - fprintf(stderr, "Error in mpfr_abs(1.0)\n"); exit(1); - } - - mpfr_set_d(x, -1.0, GMP_RNDN); - mpfr_abs(x, x, GMP_RNDN); - if (mpfr_get_d1 (x) != 1.0) { - fprintf(stderr, "Error in mpfr_abs(-1.0)\n"); exit(1); - } - - mpfr_set_inf (x, 1); - mpfr_abs (x, x, GMP_RNDN); - if (!mpfr_inf_p(x) || (mpfr_sgn(x) <= 0)) - { - fprintf (stderr, "Error in mpfr_abs(Inf).\n"); - exit (1); - } - - mpfr_set_inf (x, -1); - mpfr_abs (x, x, GMP_RNDN); - if (!mpfr_inf_p(x) || (mpfr_sgn(x) <= 0)) - { - fprintf (stderr, "Error in mpfr_abs(-Inf).\n"); - exit (1); - } - - n = (argc==1) ? 1000000 : atoi(argv[1]); - for (k = 1; k <= n; k++) - { - do - { - d = DBL_RAND (); - absd = ABS(d); - } + mpfr_t x; + int n, k, rnd; + double d, absd, dd; + + mpfr_test_init (); + + check_inexact (); + + mpfr_init2(x, 53); + + mpfr_set_d(x, 1.0, GMP_RNDN); + mpfr_abs(x, x, GMP_RNDN); + if (mpfr_get_d1 (x) != 1.0) + { + printf ("Error in mpfr_abs(1.0)\n"); + exit (1); + } + + mpfr_set_d(x, -1.0, GMP_RNDN); + mpfr_abs(x, x, GMP_RNDN); + if (mpfr_get_d1 (x) != 1.0) + { + printf ("Error in mpfr_abs(-1.0)\n"); + exit (1); + } + + mpfr_set_inf (x, 1); + mpfr_abs (x, x, GMP_RNDN); + if (!mpfr_inf_p(x) || (mpfr_sgn(x) <= 0)) + { + printf ("Error in mpfr_abs(Inf).\n"); + exit (1); + } + + mpfr_set_inf (x, -1); + mpfr_abs (x, x, GMP_RNDN); + if (!mpfr_inf_p(x) || (mpfr_sgn(x) <= 0)) + { + printf ("Error in mpfr_abs(-Inf).\n"); + exit (1); + } + + n = (argc==1) ? 1000000 : atoi(argv[1]); + for (k = 1; k <= n; k++) + { + do + { + d = DBL_RAND (); + absd = ABS(d); + } #ifdef HAVE_DENORMS - while (0); + while (0); #else - while (absd < DBL_MIN); + while (absd < DBL_MIN); #endif - rnd = randlimb () % 4; - mpfr_set_d (x, d, 0); - mpfr_abs (x, x, rnd); - dd = mpfr_get_d1 (x); - if (!Isnan(d) && (dd != absd)) - { - fprintf(stderr, - "Mismatch on d = %.20e\n", d); - fprintf(stderr, "dd=%.20e\n", dd); - mpfr_print_binary(x); puts (""); - exit(1); - } - } - - mpfr_clear(x); - - tests_end_mpfr (); - return 0; + rnd = randlimb () % 4; + mpfr_set_d (x, d, 0); + mpfr_abs (x, x, rnd); + dd = mpfr_get_d1 (x); + if (!Isnan(d) && (dd != absd)) + { + printf ("Mismatch on d = %.20e\n", d); + printf ("dd=%.20e\n", dd); + mpfr_print_binary(x); puts (""); + exit (1); + } + } + + mpfr_clear(x); + + tests_end_mpfr (); + return 0; } |