diff options
-rw-r--r-- | tests/trint.c | 10 | ||||
-rw-r--r-- | tests/tround_prec.c | 12 | ||||
-rw-r--r-- | tests/tset.c | 35 | ||||
-rw-r--r-- | tests/tset_d.c | 82 | ||||
-rw-r--r-- | tests/tset_f.c | 22 | ||||
-rw-r--r-- | tests/tset_ld.c | 8 | ||||
-rw-r--r-- | tests/tset_q.c | 14 | ||||
-rw-r--r-- | tests/tset_si.c | 44 | ||||
-rw-r--r-- | tests/tset_str.c | 163 | ||||
-rw-r--r-- | tests/tset_z.c | 6 | ||||
-rw-r--r-- | tests/tsin.c | 32 | ||||
-rw-r--r-- | tests/tsin_cos.c | 32 | ||||
-rw-r--r-- | tests/tsqrt.c | 19 | ||||
-rw-r--r-- | tests/tsub.c | 128 | ||||
-rw-r--r-- | tests/tsub_ui.c | 6 | ||||
-rw-r--r-- | tests/tswap.c | 11 | ||||
-rw-r--r-- | tests/ttan.c | 14 | ||||
-rw-r--r-- | tests/ttrunc.c | 213 | ||||
-rw-r--r-- | tests/tui_div.c | 54 | ||||
-rw-r--r-- | tests/tui_pow.c | 5 | ||||
-rw-r--r-- | tests/tui_sub.c | 44 | ||||
-rw-r--r-- | tests/tzeta.c | 30 |
22 files changed, 500 insertions, 484 deletions
diff --git a/tests/trint.c b/tests/trint.c index 172d09490..e8a47cefa 100644 --- a/tests/trint.c +++ b/tests/trint.c @@ -45,7 +45,7 @@ main (void) for (s = 2; s < 100; s++) { /* z has exactly s bits */ - + mpz_mul_2exp (z, z, 1); if (randlimb () % 2) mpz_add_ui (z, z, 1); @@ -53,8 +53,8 @@ main (void) mpfr_set_prec (t, s); if (mpfr_set_z (x, z, GMP_RNDN)) { - fprintf (stderr, "Error: mpfr_set_z should be exact (s = %u)\n", - (unsigned int) s); + printf ("Error: mpfr_set_z should be exact (s = %u)\n", + (unsigned int) s); exit (1); } for (p=2; p<100; p++) @@ -72,7 +72,7 @@ main (void) inexact = mpfr_floor (y, x); if (mpfr_sub (t, y, x, GMP_RNDN)) { - fprintf (stderr, "Error: subtraction should be exact\n"); + printf ("Error: subtraction should be exact\n"); exit (1); } sign_t = mpfr_cmp_ui (t, 0); @@ -80,7 +80,7 @@ main (void) ((inexact < 0) && (sign_t >= 0)) || ((inexact > 0) && (sign_t <= 0))) { - fprintf (stderr, "Wrong inexact flag\n"); + printf ("Wrong inexact flag\n"); exit (1); } } diff --git a/tests/tround_prec.c b/tests/tround_prec.c index 24d433d19..0ecf56e34 100644 --- a/tests/tround_prec.c +++ b/tests/tround_prec.c @@ -38,8 +38,7 @@ main (void) mpfr_prec_round (x, 2, GMP_RNDN); if (mpfr_cmp_ui(x, 4)) { - fprintf (stderr, "Error in tround: got %1.1f instead of 4\n", - mpfr_get_d1 (x)); + printf ("Error in tround: got %1.1f instead of 4\n", mpfr_get_d1 (x)); exit (1); } @@ -49,8 +48,7 @@ main (void) mpfr_prec_round (x, mp_bits_per_limb + 1, GMP_RNDN); if (mpfr_cmp_ui(x, 5)) { - fprintf (stderr, "Error in tround: got %1.1f instead of 5\n", - mpfr_get_d1 (x)); + printf ("Error in tround: got %1.1f instead of 5\n", mpfr_get_d1 (x)); exit (1); } @@ -60,8 +58,7 @@ main (void) mpfr_prec_round (x, mp_bits_per_limb + 1, GMP_RNDN); if (mpfr_cmp_si(x, -5)) { - fprintf (stderr, "Error in tround: got %1.1f instead of -5\n", - mpfr_get_d1 (x)); + printf ("Error in tround: got %1.1f instead of -5\n", mpfr_get_d1 (x)); exit (1); } @@ -71,8 +68,7 @@ main (void) mpfr_prec_round (x, 3, GMP_RNDN); /* exact */ if (mpfr_cmp_ui(x, 5)) { - fprintf (stderr, "Error in tround: got %1.1f instead of 5\n", - mpfr_get_d1 (x)); + printf ("Error in tround: got %1.1f instead of 5\n", mpfr_get_d1 (x)); exit (1); } diff --git a/tests/tset.c b/tests/tset.c index 62690881d..ba7939cef 100644 --- a/tests/tset.c +++ b/tests/tset.c @@ -48,10 +48,10 @@ main (void) mpfr_set_str_raw (y, "1.0E-8"); if (mpfr_cmp (x, y)) { - fprintf (stderr, "Error for y=0.11111111100E-8, prec=2, rnd=GMP_RNDN\n"); + printf ("Error for y=0.11111111100E-8, prec=2, rnd=GMP_RNDN\n"); exit (1); } - + for (p=2; p<500; p++) { mpfr_set_prec (x, p); @@ -59,21 +59,22 @@ main (void) if (randlimb () % 2) mpfr_neg (x, x, GMP_RNDN); for (q=2; q<2*p; q++) - { - mpfr_set_prec (y, q); - for (rnd=0; rnd<4; rnd++) - { - inexact = mpfr_set (y, x, rnd); - cmp = mpfr_cmp (y, x); - if (((inexact == 0) && (cmp != 0)) || - ((inexact > 0) && (cmp <= 0)) || - ((inexact < 0) && (cmp >= 0))) - { - fprintf (stderr, "Wrong inexact flag in mpfr_set: expected %d, got %d\n", cmp, inexact); - exit (1); - } - } - } + { + mpfr_set_prec (y, q); + for (rnd=0; rnd<4; rnd++) + { + inexact = mpfr_set (y, x, rnd); + cmp = mpfr_cmp (y, x); + if (((inexact == 0) && (cmp != 0)) || + ((inexact > 0) && (cmp <= 0)) || + ((inexact < 0) && (cmp >= 0))) + { + printf ("Wrong inexact flag in mpfr_set: expected %d," + " got %d\n", cmp, inexact); + exit (1); + } + } + } } mpfr_clear (x); diff --git a/tests/tset_d.c b/tests/tset_d.c index 1629a76f6..ba5937b40 100644 --- a/tests/tset_d.c +++ b/tests/tset_d.c @@ -34,7 +34,7 @@ main (int argc, char *argv[]) mpfr_t x, y, z; unsigned long k, n; double d, dd; - + tests_start_mpfr (); mpfr_test_init (); @@ -48,11 +48,12 @@ main (int argc, char *argv[]) mpfr_set_d (x, d, GMP_RNDN); if (mpfr_cmp_ui_2exp (x, 1, -1022-n)) { - fprintf (stderr, "Wrong result for d=2^(%ld), ", -1022-n); - fprintf (stderr, "got "); - mpfr_out_str (stderr, 10, 10, x, GMP_RNDN); - fprintf (stderr, "\n"); - mpfr_print_binary (x); puts (""); + printf ("Wrong result for d=2^(%ld), ", -1022-n); + printf ("got "); + mpfr_out_str (stdout, 10, 10, x, GMP_RNDN); + printf ("\n"); + mpfr_print_binary (x); + puts (""); exit (1); } } @@ -62,55 +63,59 @@ main (int argc, char *argv[]) mpfr_set_d (x, 5.0, GMP_RNDN); if (mpfr_get_d1 (x) != 4.0) { - fprintf (stderr, "Error in tset_d: got %g instead of 4.0\n", - mpfr_get_d1 (x)); + printf ("Error in tset_d: got %g instead of 4.0\n", mpfr_get_d1 (x)); exit (1); } mpfr_set_d (x, -5.0, GMP_RNDN); if (mpfr_get_d1 (x) != -4.0) { - fprintf (stderr, "Error in tset_d: got %g instead of -4.0\n", - mpfr_get_d1 (x)); + printf ("Error in tset_d: got %g instead of -4.0\n", mpfr_get_d1 (x)); exit (1); } - mpfr_set_d (x, 9.84891017624509146344e-01, GMP_RNDU); + mpfr_set_d (x, 9.84891017624509146344e-01, GMP_RNDU); if (mpfr_get_d1 (x) != 1.0) { - fprintf (stderr, "Error in tset_d: got %g instead of 1.0\n", - mpfr_get_d1 (x)); + printf ("Error in tset_d: got %g instead of 1.0\n", mpfr_get_d1 (x)); exit (1); } mpfr_init2(z, 32); mpfr_set_d(z, 1.0, 0); - if (mpfr_get_d1 (z) != 1.0) { - mpfr_print_binary(z); puts (""); - printf("Error: 1.0 != 1.0\n"); exit(1); - } + if (mpfr_get_d1 (z) != 1.0) + { + mpfr_print_binary (z); puts (""); + printf ("Error: 1.0 != 1.0\n"); + exit (1); + } mpfr_set_prec(x, 53); mpfr_init2(y, 53); mpfr_set_d(x, d=-1.08007920352320089721e+150, 0); - if (mpfr_get_d1 (x) != d) { - mpfr_print_binary(x); puts (""); - printf("Error: get_d o set_d <> identity for d = %1.20e %1.20e\n",d, - mpfr_get_d1 (x)); exit(1); - } + if (mpfr_get_d1 (x) != d) + { + mpfr_print_binary (x); puts (""); + printf ("Error: get_d o set_d <> identity for d = %1.20e %1.20e\n", + d, mpfr_get_d1 (x)); + exit (1); + } - mpfr_set_d(x, 8.06294740693074521573e-310, 0); + mpfr_set_d(x, 8.06294740693074521573e-310, 0); d = -6.72658901114033715233e-165; mpfr_set_d(x, d, 0); - if (d != mpfr_get_d1 (x)) { - mpfr_print_binary(x); puts (""); - printf("Error: get_d o set_d <> identity for d = %1.20e %1.20e\n",d, - mpfr_get_d1 (x)); exit(1); - } + if (d != mpfr_get_d1 (x)) + { + mpfr_print_binary (x); + puts (""); + printf ("Error: get_d o set_d <> identity for d = %1.20e %1.20e\n", + d, mpfr_get_d1 (x)); + exit (1); + } n = (argc==1) ? 1000000 : atoi(argv[1]); for (k = 1; k <= n; k++) - { + { do - { - d = DBL_RAND (); - } + { + d = DBL_RAND (); + } #ifdef HAVE_DENORMS while (0); #else @@ -119,13 +124,12 @@ main (int argc, char *argv[]) mpfr_set_d (x, d, 0); dd = mpfr_get_d1 (x); if (d != dd && !(Isnan(d) && Isnan(dd))) - { - fprintf (stderr, - "Mismatch on : %1.18g != %1.18g\n", d, mpfr_get_d1 (x)); - mpfr_print_binary (x); + { + printf ("Mismatch on : %1.18g != %1.18g\n", d, mpfr_get_d1 (x)); + mpfr_print_binary (x); puts (""); - exit (1); - } + exit (1); + } } mpfr_clear (x); @@ -133,5 +137,5 @@ main (int argc, char *argv[]) mpfr_clear (z); tests_end_mpfr (); - return 0; + return 0; } diff --git a/tests/tset_f.c b/tests/tset_f.c index 72e407d3d..e3fa5f05c 100644 --- a/tests/tset_f.c +++ b/tests/tset_f.c @@ -32,10 +32,10 @@ main (void) mpfr_t x, u; mpf_t y, z; unsigned long k, pr; - + tests_start_mpfr (); - mpf_init(y); + mpf_init(y); mpf_init(z); mpf_set_d (y, 0.0); @@ -45,7 +45,7 @@ main (void) mpfr_set_prec (x, 100); mpfr_set_f (x, y, GMP_RNDN); - mpf_random2(y, 10, 0); + mpf_random2(y, 10, 0); mpfr_set_f(x, y, randlimb () & 3); /* bug found by Jean-Pierre Merlet */ @@ -57,15 +57,19 @@ main (void) 16, GMP_RNDN); mpf_set_str(y, "2033.033", 10); mpfr_set_f(x, y, GMP_RNDN); - if (mpfr_cmp(x, u)) { - fprintf(stderr, "mpfr_set_f failed for y=2033.033\n"); exit(1); - } + if (mpfr_cmp(x, u)) + { + printf ("mpfr_set_f failed for y=2033.033\n"); + exit (1); + } mpf_set_str(y, "-2033.033", 10); mpfr_set_f(x, y, GMP_RNDN); mpfr_neg(u, u, GMP_RNDN); - if (mpfr_cmp(x, u)) { - fprintf(stderr, "mpfr_set_f failed for y=-2033.033\n"); exit(1); - } + if (mpfr_cmp(x, u)) + { + printf ("mpfr_set_f failed for y=-2033.033\n"); + exit (1); + } mpfr_clear(u); mpfr_clear(x); diff --git a/tests/tset_ld.c b/tests/tset_ld.c index 197c93f60..0aed61892 100644 --- a/tests/tset_ld.c +++ b/tests/tset_ld.c @@ -53,7 +53,7 @@ check_set_get (long double d, mpfr_t x) { if (mpfr_set_ld (x, d, r)) { - fprintf (stderr, "Error: mpfr_set_ld should be exact\n"); + printf ("Error: mpfr_set_ld should be exact\n"); exit (1); } e = mpfr_get_ld (x, r); @@ -94,7 +94,7 @@ main (int argc, char *argv[]) mpfr_set_ld (x, -0.0, GMP_RNDN); if (MPFR_SIGN(x) > 0) { - fprintf (stderr, "Error: sign of -0.0 is not set correctly\n"); + printf ("Error: sign of -0.0 is not set correctly\n"); exit (1); } @@ -146,10 +146,10 @@ main (int argc, char *argv[]) d = mpfr_get_ld (x, GMP_RNDN); check_set_get (d, x); } - + mpfr_clear (x); tests_end_mpfr (); - return 0; + return 0; } diff --git a/tests/tset_q.c b/tests/tset_q.c index 7d6528f7b..e95b658a4 100644 --- a/tests/tset_q.c +++ b/tests/tset_q.c @@ -44,17 +44,17 @@ check (long int n, long int d, mp_rnd_t rnd, double y) /* check values */ if (y != z) { - fprintf (stderr, "Error for q=%ld/%lu and rnd=%s\n", n, d, - mpfr_print_rnd_mode (rnd)); - fprintf (stderr, "correct result is %1.20e, mpfr_set_q gives %1.20e\n", - y, z); + printf ("Error for q=%ld/%lu and rnd=%s\n", n, d, + mpfr_print_rnd_mode (rnd)); + printf ("correct result is %1.20e, mpfr_set_q gives %1.20e\n", + y, z); exit (1); } /* check inexact flag */ if (mpfr_mul_ui (t, x, (d < 0) ? (-d) : d, rnd)) { - fprintf (stderr, "t <- x * d should be exact\n"); + printf ("t <- x * d should be exact\n"); exit (1); } compare = mpfr_cmp_si (t, n); @@ -62,8 +62,8 @@ check (long int n, long int d, mp_rnd_t rnd, double y) ((inexact < 0) && (compare >= 0)) || ((inexact > 0) && (compare <= 0))) { - fprintf (stderr, "wrong inexact flag: expected %d, got %d\n", compare, - inexact); + printf ("wrong inexact flag: expected %d, got %d\n", compare, + inexact); exit (1); } diff --git a/tests/tset_si.c b/tests/tset_si.c index e54c6e668..1f3ac7148 100644 --- a/tests/tset_si.c +++ b/tests/tset_si.c @@ -40,7 +40,7 @@ main (int argc, char *argv[]) long k, z, d; unsigned long zl, dl, N; int inex; - + tests_start_mpfr (); mpfr_init2 (x, 100); @@ -54,15 +54,13 @@ main (int argc, char *argv[]) d = mpfr_get_si (x, GMP_RNDZ); if (d != z) { - fprintf (stderr, "Error in mpfr_set_si: expected %ld got %ld\n", - z, d); + printf ("Error in mpfr_set_si: expected %ld got %ld\n", z, d); exit (1); } if (inex) { - fprintf (stderr, - "Error in mpfr_set_si: inex value incorrect for %ld: %d\n", - z, inex); + printf ("Error in mpfr_set_si: inex value incorrect for %ld: %d\n", + z, inex); exit (1); } } @@ -74,15 +72,13 @@ main (int argc, char *argv[]) dl = mpfr_get_ui (x, GMP_RNDZ); if (dl != zl) { - fprintf (stderr, "Error in mpfr_set_ui: expected %lu got %lu\n", - zl, dl); + printf ("Error in mpfr_set_ui: expected %lu got %lu\n", zl, dl); exit (1); } if (inex) { - fprintf (stderr, - "Error in mpfr_set_ui: inex value incorrect for %lu: %d\n", - zl, inex); + printf ("Error in mpfr_set_ui: inex value incorrect for %lu: %d\n", + zl, inex); exit (1); } } @@ -90,14 +86,14 @@ main (int argc, char *argv[]) mpfr_set_prec (x, 2); if (mpfr_set_si (x, 5, GMP_RNDZ) >= 0) { - fprintf (stderr, "Wrong inexact flag for x=5, rnd=GMP_RNDZ\n"); + printf ("Wrong inexact flag for x=5, rnd=GMP_RNDZ\n"); exit (1); } mpfr_set_prec (x, 2); if (mpfr_set_si (x, -5, GMP_RNDZ) <= 0) { - fprintf (stderr, "Wrong inexact flag for x=-5, rnd=GMP_RNDZ\n"); + printf ("Wrong inexact flag for x=-5, rnd=GMP_RNDZ\n"); exit (1); } @@ -106,7 +102,7 @@ main (int argc, char *argv[]) if (MPFR_MANT(x)[0] != ((mp_limb_t)1 << (mp_bits_per_limb-1)) || inex >= 0) { - fprintf (stderr, "Error in mpfr_set_si(x:3, 77617, GMP_RNDD)\n"); + printf ("Error in mpfr_set_si(x:3, 77617, GMP_RNDD)\n"); mpfr_print_binary (x); puts (""); exit (1); @@ -115,7 +111,7 @@ main (int argc, char *argv[]) if (MPFR_MANT(x)[0] != ((mp_limb_t)1 << (mp_bits_per_limb-1)) || inex >= 0) { - fprintf (stderr, "Error in mpfr_set_ui(x:3, 77617, GMP_RNDD)\n"); + printf ("Error in mpfr_set_ui(x:3, 77617, GMP_RNDD)\n"); mpfr_print_binary (x); puts (""); exit (1); @@ -125,15 +121,15 @@ main (int argc, char *argv[]) inex = mpfr_set_si (x, 33096, GMP_RNDU); if (mpfr_get_si (x, GMP_RNDZ) != 49152 || inex <= 0) { - fprintf (stderr, "Error in mpfr_set_si, exp. 49152, got %ld, inex %d\n", - mpfr_get_si (x, GMP_RNDZ), inex); - exit (1); + printf ("Error in mpfr_set_si, exp. 49152, got %ld, inex %d\n", + mpfr_get_si (x, GMP_RNDZ), inex); + exit (1); } inex = mpfr_set_ui (x, 33096, GMP_RNDU); if (mpfr_get_si (x, GMP_RNDZ) != 49152) { - fprintf (stderr, "Error in mpfr_set_ui, exp. 49152, got %ld, inex %d\n", - mpfr_get_si (x, GMP_RNDZ), inex); + printf ("Error in mpfr_set_ui, exp. 49152, got %ld, inex %d\n", + mpfr_get_si (x, GMP_RNDZ), inex); exit (1); } @@ -141,7 +137,7 @@ main (int argc, char *argv[]) mpfr_set_ui (x, 0, GMP_RNDN); if (MPFR_SIGN (x) < 0) { - fprintf (stderr, "mpfr_set_ui (x, 0) gives -0\n"); + printf ("mpfr_set_ui (x, 0) gives -0\n"); exit (1); } @@ -149,7 +145,7 @@ main (int argc, char *argv[]) mpfr_set_si (x, 0, GMP_RNDN); if (MPFR_SIGN (x) < 0) { - fprintf (stderr, "mpfr_set_si (x, 0) gives -0\n"); + printf ("mpfr_set_si (x, 0) gives -0\n"); exit (1); } @@ -158,7 +154,7 @@ main (int argc, char *argv[]) mpfr_set_si (x, -1, GMP_RNDN); if (mpfr_sgn (x) >= 0) { - fprintf (stderr, "mpfr_set_si (x, -1) fails\n"); + printf ("mpfr_set_si (x, -1) fails\n"); exit (1); } @@ -167,7 +163,7 @@ main (int argc, char *argv[]) mpfr_set_si (x, -31, GMP_RNDN); if (mpfr_sgn (x) >= 0) { - fprintf (stderr, "mpfr_set_si (x, -31) fails\n"); + printf ("mpfr_set_si (x, -31) fails\n"); exit (1); } diff --git a/tests/tset_str.c b/tests/tset_str.c index 4d1b59a9e..bd17b5d12 100644 --- a/tests/tset_str.c +++ b/tests/tset_str.c @@ -59,7 +59,7 @@ main (int argc, char *argv[]) nc = 100; bd = randlimb () & 8; - + str2 = str = (*__gmp_allocate_func) (nc * sizeof(char)); if (bd) @@ -71,15 +71,15 @@ main (int argc, char *argv[]) else *(str2++) = '0'; - *(str2++) = '.'; + *(str2++) = '.'; for (k = 1; k < nc - 17 - bd; k++) *(str2++) = '0' + (randlimb () & 1); - *(str2++) = 'e'; + *(str2++) = 'e'; sprintf (str2, "%d", (int) (randlimb () & INT_MAX) + INT_MIN/2); - mpfr_set_prec (x, nc + 10); + mpfr_set_prec (x, nc + 10); mpfr_set_str_raw (x, str); mpfr_set_prec (x, 54); @@ -88,13 +88,13 @@ main (int argc, char *argv[]) mpfr_set_str (y, "4.936a52bc17254@-133", 16, GMP_RNDN); if (mpfr_cmp (x, y)) { - fprintf (stderr, "Error in mpfr_set_str (1a):\n"); + printf ("Error in mpfr_set_str (1a):\n"); mpfr_print_binary (x); puts (""); mpfr_print_binary (y); puts (""); mpfr_clear (x); - mpfr_clear (y); + mpfr_clear (y); exit (1); } @@ -102,7 +102,7 @@ main (int argc, char *argv[]) mpfr_set_str (y, "0.fedcba98765434P-529", 16, GMP_RNDN); if (mpfr_cmp (x, y)) { - fprintf (stderr, "Error in mpfr_set_str (1b):\n"); + printf ("Error in mpfr_set_str (1b):\n"); mpfr_print_binary (x); puts (""); mpfr_print_binary (y); @@ -120,9 +120,9 @@ main (int argc, char *argv[]) mpfr_set_str_raw (x, "1.0"); if (mpfr_get_d1 (x) != 1.0) { - fprintf (stderr, "Error in mpfr_set_str_raw for s=1.0\n"); + printf ("Error in mpfr_set_str_raw for s=1.0\n"); mpfr_clear(x); - mpfr_clear(y); + mpfr_clear(y); exit(1); } @@ -131,7 +131,7 @@ main (int argc, char *argv[]) mpfr_set_str_raw (x, "0000E0"); if (mpfr_get_d1 (x) != 0.0) { - fprintf (stderr, "Error in mpfr_set_str_raw for s=0.0\n"); + printf ("Error in mpfr_set_str_raw for s=0.0\n"); mpfr_clear (x); mpfr_clear (y); exit (1); @@ -153,7 +153,7 @@ main (int argc, char *argv[]) k = randlimb () % 4; logbase = (randlimb () % 5) + 1; base = 1 << logbase; - /* Warning: the number of bits needed to print exactly a number of + /* Warning: the number of bits needed to print exactly a number of 'prec' bits in base 2^logbase may be greater than ceil(prec/logbase), for example 0.11E-1 in base 2 cannot be written exactly with only one digit in base 4 */ @@ -165,20 +165,20 @@ main (int argc, char *argv[]) mpfr_set_str (y, str, base, k); MPFR_EXP(y) += logbase * (e - strlen (str)); if (mpfr_cmp (x, y)) - { - fprintf (stderr, "mpfr_set_str o mpfr_get_str <> id for rnd_mode=%s\n", - mpfr_print_rnd_mode (k)); - printf ("x="); - mpfr_print_binary (x); - puts (""); - printf ("s=%s, exp=%d, base=%d\n", str, (int) e, base); - printf ("y="); - mpfr_print_binary (y); - puts (""); - mpfr_clear (x); - mpfr_clear (y); - exit (1); - } + { + printf ("mpfr_set_str o mpfr_get_str <> id for rnd_mode=%s\n", + mpfr_print_rnd_mode (k)); + printf ("x="); + mpfr_print_binary (x); + puts (""); + printf ("s=%s, exp=%d, base=%d\n", str, (int) e, base); + printf ("y="); + mpfr_print_binary (y); + puts (""); + mpfr_clear (x); + mpfr_clear (y); + exit (1); + } (*__gmp_free_func) (str, strlen (str) + 1); } @@ -187,28 +187,28 @@ main (int argc, char *argv[]) if (mpfr_set_str (x, "@NaN@garbage", i, GMP_RNDN) != 0 || !mpfr_nan_p(x)) { - fprintf (stderr, "mpfr_set_str failed on @NaN@garbage\n"); + printf ("mpfr_set_str failed on @NaN@garbage\n"); exit (1); } if (mpfr_set_str (x, "@Inf@garbage", i, GMP_RNDN) != 0 || !mpfr_inf_p(x) || MPFR_SIGN(x) < 0) { - fprintf (stderr, "mpfr_set_str failed on @Inf@garbage\n"); + printf ("mpfr_set_str failed on @Inf@garbage\n"); exit (1); } if (mpfr_set_str (x, "-@Inf@garbage", i, GMP_RNDN) != 0 || !mpfr_inf_p(x) || MPFR_SIGN(x) > 0) { - fprintf (stderr, "mpfr_set_str failed on -@Inf@garbage\n"); + printf ("mpfr_set_str failed on -@Inf@garbage\n"); exit (1); } if (mpfr_set_str (x, "+@Inf@garbage", i, GMP_RNDN) != 0 || !mpfr_inf_p(x) || MPFR_SIGN(x) < 0) { - fprintf (stderr, "mpfr_set_str failed on +@Inf@garbage\n"); + printf ("mpfr_set_str failed on +@Inf@garbage\n"); exit (1); } @@ -218,28 +218,28 @@ main (int argc, char *argv[]) if (mpfr_set_str (x, "NaN", i, GMP_RNDN) != 0 || !mpfr_nan_p(x)) { - fprintf (stderr, "mpfr_set_str failed on NaN\n"); + printf ("mpfr_set_str failed on NaN\n"); exit (1); } if (mpfr_set_str (x, "Inf", i, GMP_RNDN) != 0 || !mpfr_inf_p(x) || MPFR_SIGN(x) < 0) { - fprintf (stderr, "mpfr_set_str failed on Inf\n"); + printf ("mpfr_set_str failed on Inf\n"); exit (1); } if (mpfr_set_str (x, "-Inf", i, GMP_RNDN) != 0 || !mpfr_inf_p(x) || MPFR_SIGN(x) > 0) { - fprintf (stderr, "mpfr_set_str failed on -Inf\n"); + printf ("mpfr_set_str failed on -Inf\n"); exit (1); } if (mpfr_set_str (x, "+Inf", i, GMP_RNDN) != 0 || !mpfr_inf_p(x) || MPFR_SIGN(x) < 0) { - fprintf (stderr, "mpfr_set_str failed on +Inf\n"); + printf ("mpfr_set_str failed on +Inf\n"); exit (1); } } @@ -249,7 +249,7 @@ main (int argc, char *argv[]) mpfr_set_str (x, "B", 16, GMP_RNDN); if (mpfr_cmp_ui (x, 11) != 0) { - fprintf (stderr, "mpfr_set_str does not work for uppercase letters\n"); + printf ("mpfr_set_str does not work for uppercase letters\n"); exit (1); } @@ -262,13 +262,13 @@ main (int argc, char *argv[]) mpfr_set_str (y, "0.71128279983522479470@-160", 10, GMP_RNDU); if (mpfr_cmp (x, y)) { - fprintf (stderr, "Error in mpfr_set_str (2):\n"); + printf ("Error in mpfr_set_str (2):\n"); mpfr_print_binary (x); puts (""); mpfr_print_binary (y); puts (""); mpfr_clear (x); - mpfr_clear (y); + mpfr_clear (y); exit (1); } @@ -283,13 +283,13 @@ main (int argc, char *argv[]) /* y = 49027884868983130654865109690613178467841148597221480052 */ if (mpfr_cmp (x, y)) { - fprintf (stderr, "Error in mpfr_set_str (3):\n"); + printf ("Error in mpfr_set_str (3):\n"); mpfr_print_binary (x); puts (""); mpfr_print_binary (y); puts (""); mpfr_clear (x); - mpfr_clear (y); + mpfr_clear (y); exit (1); } @@ -307,13 +307,13 @@ main (int argc, char *argv[]) /* y = 100433627392042473064661483711179345482301462325708736552078 */ if (mpfr_cmp (x, y)) { - fprintf (stderr, "Error in mpfr_set_str (4):\n"); + printf ("Error in mpfr_set_str (4):\n"); mpfr_print_binary (x); puts (""); mpfr_print_binary (y); puts (""); mpfr_clear (x); - mpfr_clear (y); + mpfr_clear (y); exit (1); } @@ -326,13 +326,13 @@ main (int argc, char *argv[]) /* y = 3053110535624388280648330929253842828159081875986159414 */ if (mpfr_cmp (x, y)) { - fprintf (stderr, "Error in mpfr_set_str (5):\n"); + printf ("Error in mpfr_set_str (5):\n"); mpfr_print_binary (x); puts (""); mpfr_print_binary (y); puts (""); mpfr_clear (x); - mpfr_clear (y); + mpfr_clear (y); exit (1); } @@ -343,13 +343,13 @@ main (int argc, char *argv[]) mpfr_set_str_raw (x, "0.1111111111111111111111111111111000000000000011100000001111100001E187"); if (mpfr_cmp (x, y)) { - fprintf (stderr, "Error in mpfr_set_str (6):\n"); + printf ("Error in mpfr_set_str (6):\n"); mpfr_print_binary (x); puts (""); mpfr_print_binary (y); puts (""); mpfr_clear (x); - mpfr_clear (y); + mpfr_clear (y); exit (1); } @@ -360,13 +360,13 @@ main (int argc, char *argv[]) mpfr_set_str_raw (x, "0.1111111111111100000000001000000000000000000011111111111111101111E215"); if (mpfr_cmp (x, y)) { - fprintf (stderr, "Error in mpfr_set_str (7):\n"); + printf ("Error in mpfr_set_str (7):\n"); mpfr_print_binary (x); puts (""); mpfr_print_binary (y); puts (""); mpfr_clear (x); - mpfr_clear (y); + mpfr_clear (y); exit (1); } @@ -391,41 +391,42 @@ main (int argc, char *argv[]) mpfr_set_ui (x, 1, GMP_RNDN); /* ensures that x is not NaN or Inf */ for (; nb_digit < 100000; nb_digit *= 10) for (cbase = 0; cbase < 3; cbase++) - for (climb = 0; climb < 2; climb++) - for (crnd = 0; crnd < 3; crnd++) - { - char *str1; - mp_exp_t exp; - - *(MPFR_MANT(x)) = check_limb[climb]; - MPFR_EXP(x) = 0; - - mpfr_get_str (str + 2, &exp, base[cbase], - nb_digit, x, rnd[crnd]); - str[0] = '-'; - str[(str[2] == '-')] = '0'; - str[(str[2] == '-') + 1] = '.'; - - for (str1 = str; *str1 != 0; str1++); - sprintf (str1, "@%i", (int) exp); - - mpfr_set_str (y, str, base[cbase], rnd[2 - crnd]); - - if (mpfr_cmp (x, y) != 0) - { - fprintf (stderr, "Error in mpfr_set_str for nb_digit=%u, base=%u, rnd=%s:\n", (unsigned int) nb_digit, base[cbase], mpfr_print_rnd_mode (rnd[crnd])); - fprintf (stderr, "instead of: "); - mpfr_print_binary (x); - puts (""); - fprintf (stderr, "return : "); - mpfr_print_binary (y); - puts (""); - } - - } + for (climb = 0; climb < 2; climb++) + for (crnd = 0; crnd < 3; crnd++) + { + char *str1; + mp_exp_t exp; + + *(MPFR_MANT(x)) = check_limb[climb]; + MPFR_EXP(x) = 0; + + mpfr_get_str (str + 2, &exp, base[cbase], + nb_digit, x, rnd[crnd]); + str[0] = '-'; + str[(str[2] == '-')] = '0'; + str[(str[2] == '-') + 1] = '.'; + + for (str1 = str; *str1 != 0; str1++) + ; + sprintf (str1, "@%i", (int) exp); + + mpfr_set_str (y, str, base[cbase], rnd[2 - crnd]); + + if (mpfr_cmp (x, y) != 0) + { + printf ("Error in mpfr_set_str for nb_digit=%u, base=%u, " + "rnd=%s:\n", (unsigned int) nb_digit, base[cbase], + mpfr_print_rnd_mode (rnd[crnd])); + printf ("instead of: "); + mpfr_print_binary (x); + puts (""); + printf ("return : "); + mpfr_print_binary (y); + puts (""); + } + } (*__gmp_free_func) (str, 100000 + 20); - } /* end of tests added by Alain Delplanque */ @@ -435,13 +436,13 @@ main (int argc, char *argv[]) mpfr_set_str (x, "+0.0", 10, GMP_RNDN); if (!mpfr_number_p(x) || mpfr_cmp_ui (x, 0) != 0 || mpfr_sgn (x) < 0) { - fprintf (stderr, "x <- +0.0 failed after x=NaN\n"); + printf ("x <- +0.0 failed after x=NaN\n"); exit (1); } mpfr_set_str (x, "-0.0", 10, GMP_RNDN); if (!mpfr_number_p(x) || mpfr_cmp_ui (x, 0) != 0 || mpfr_sgn (x) > 0) { - fprintf (stderr, "x <- -0.0 failed after x=NaN\n"); + printf ("x <- -0.0 failed after x=NaN\n"); exit (1); } diff --git a/tests/tset_z.c b/tests/tset_z.c index 519f7067b..81ef5ffe0 100644 --- a/tests/tset_z.c +++ b/tests/tset_z.c @@ -45,7 +45,7 @@ check (long i, unsigned char rnd) mpfr_set_z (f, z, rnd); if (mpfr_get_si (f, GMP_RNDZ) != i) { - fprintf (stderr, "Error in mpfr_set_z for i=%ld rnd_mode=%d\n", i, rnd); + printf ("Error in mpfr_set_z for i=%ld rnd_mode=%d\n", i, rnd); exit (1); } mpfr_clear (f); @@ -66,7 +66,7 @@ check_large (void) mpfr_set_str_raw (y, "0.1100100100001111110110101010001000100001011010001100001000110100110001001100011001100010100010111000000011011100000111001101000100101001000000100100111000001001E186"); if (mpfr_cmp (x, y)) { - fprintf (stderr, "Error in mpfr_set_z on large input\n"); + printf ("Error in mpfr_set_z on large input\n"); exit (1); } mpz_clear (z); @@ -77,7 +77,7 @@ check_large (void) int main (int argc, char *argv[]) { - long j; + long j; tests_start_mpfr (); diff --git a/tests/tsin.c b/tests/tsin.c index f420cd138..abf633b72 100644 --- a/tests/tsin.c +++ b/tests/tsin.c @@ -37,10 +37,10 @@ check53 (double x, double sin_x, mp_rnd_t rnd_mode) mpfr_sin (s, xx, rnd_mode); if (mpfr_get_d1 (s) != sin_x && !(Isnan(sin_x) && mpfr_nan_p(s))) { - fprintf (stderr, "mpfr_sin failed for x=%1.20e, rnd=%s\n", x, - mpfr_print_rnd_mode (rnd_mode)); - fprintf (stderr, "mpfr_sin gives sin(x)=%1.20e, expected %1.20e\n", - mpfr_get_d1 (s), sin_x); + printf ("mpfr_sin failed for x=%1.20e, rnd=%s\n", + x, mpfr_print_rnd_mode (rnd_mode)); + printf ("mpfr_sin gives sin(x)=%1.20e, expected %1.20e\n", + mpfr_get_d1 (s), sin_x); exit(1); } mpfr_clear (xx); @@ -67,20 +67,18 @@ test_sign (void) mpfr_sin (y, x, GMP_RNDN); if (MPFR_SIGN(y) > 0) { - fprintf (stderr, - "Error in test_sign for sin(%dpi-epsilon), prec = %d" - " for argument.\nResult should have been negative.\n", - k, p); + printf ("Error in test_sign for sin(%dpi-epsilon), prec = %d" + " for argument.\nResult should have been negative.\n", + k, p); exit (1); } mpfr_mul_ui (x, piu, k, GMP_RNDU); mpfr_sin (y, x, GMP_RNDN); if (MPFR_SIGN(y) < 0) { - fprintf (stderr, - "Error in test_sign for sin(%dpi+epsilon), prec = %d" - " for argument.\nResult should have been positive.\n", - k, p); + printf ("Error in test_sign for sin(%dpi+epsilon), prec = %d" + " for argument.\nResult should have been positive.\n", + k, p); exit (1); } } @@ -102,7 +100,7 @@ check_nans (void) mpfr_sin (y, x, GMP_RNDN); if (! mpfr_nan_p (y)) { - fprintf (stderr, "Error: sin(NaN) != NaN\n"); + printf ("Error: sin(NaN) != NaN\n"); exit (1); } @@ -110,7 +108,7 @@ check_nans (void) mpfr_sin (y, x, GMP_RNDN); if (! mpfr_nan_p (y)) { - fprintf (stderr, "Error: sin(Inf) != NaN\n"); + printf ("Error: sin(Inf) != NaN\n"); exit (1); } @@ -118,7 +116,7 @@ check_nans (void) mpfr_sin (y, x, GMP_RNDN); if (! mpfr_nan_p (y)) { - fprintf (stderr, "Error: sin(-Inf) != NaN\n"); + printf ("Error: sin(-Inf) != NaN\n"); exit (1); } @@ -156,7 +154,7 @@ main (int argc, char *argv[]) mpfr_sin (x, x, GMP_RNDD); if (mpfr_get_d1 (x) != 0.375) { - fprintf (stderr, "mpfr_sin(0.5, GMP_RNDD) failed with precision=2\n"); + printf ("mpfr_sin(0.5, GMP_RNDD) failed with precision=2\n"); exit (1); } @@ -167,7 +165,7 @@ main (int argc, char *argv[]) mpfr_sin (x, x, GMP_RNDN); if (mpfr_cmp_ui (x, 0) >= 0) { - fprintf (stderr, "Error: wrong sign for sin(3*Pi/2)\n"); + printf ("Error: wrong sign for sin(3*Pi/2)\n"); exit (1); } diff --git a/tests/tsin_cos.c b/tests/tsin_cos.c index 8b4d48a4c..c695c98a5 100644 --- a/tests/tsin_cos.c +++ b/tests/tsin_cos.c @@ -57,18 +57,18 @@ check53 (double x, double sin_x, double cos_x, mp_rnd_t rnd_mode) mpfr_sin_cos (s, c, xx, rnd_mode); if (mpfr_get_d1 (s) != sin_x && !(Isnan(sin_x) && mpfr_nan_p(s))) { - fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x, - mpfr_print_rnd_mode (rnd_mode)); - fprintf (stderr, "mpfr_sin_cos gives sin(x)=%1.20e, expected %1.20e\n", - mpfr_get_d1 (s), sin_x); + printf ("mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", + x, mpfr_print_rnd_mode (rnd_mode)); + printf ("mpfr_sin_cos gives sin(x)=%1.20e, expected %1.20e\n", + mpfr_get_d1 (s), sin_x); exit (1); } if (mpfr_get_d1 (c) != cos_x && !(Isnan(cos_x) && mpfr_nan_p(c))) { - fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x, - mpfr_print_rnd_mode (rnd_mode)); - fprintf (stderr, "mpfr_sin_cos gives cos(x)=%1.20e, expected %1.20e\n", - mpfr_get_d1 (c), cos_x); + printf ("mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", + x, mpfr_print_rnd_mode (rnd_mode)); + printf ("mpfr_sin_cos gives cos(x)=%1.20e, expected %1.20e\n", + mpfr_get_d1 (c), cos_x); exit (1); } mpfr_clear (xx); @@ -88,10 +88,10 @@ check53sin (double x, double sin_x, mp_rnd_t rnd_mode) mpfr_sin_cos (s, c, xx, rnd_mode); if (mpfr_get_d1 (s) != sin_x && !(Isnan(sin_x) && mpfr_nan_p(s))) { - fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x, - mpfr_print_rnd_mode (rnd_mode)); - fprintf (stderr, "mpfr_sin_cos gives sin(x)=%1.20e, expected %1.20e\n", - mpfr_get_d1 (s), sin_x); + printf ("mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", + x, mpfr_print_rnd_mode (rnd_mode)); + printf ("mpfr_sin_cos gives sin(x)=%1.20e, expected %1.20e\n", + mpfr_get_d1 (s), sin_x); exit (1); } mpfr_clear (xx); @@ -111,10 +111,10 @@ check53cos (double x, double cos_x, mp_rnd_t rnd_mode) mpfr_sin_cos (s, c, xx, rnd_mode); if (mpfr_get_d1 (c) != cos_x && !(Isnan(cos_x) && mpfr_nan_p(c))) { - fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x, - mpfr_print_rnd_mode (rnd_mode)); - fprintf (stderr, "mpfr_sin_cos gives cos(x)=%1.20e, expected %1.20e\n", - mpfr_get_d1 (c), cos_x); + printf ("mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", + x, mpfr_print_rnd_mode (rnd_mode)); + printf ("mpfr_sin_cos gives cos(x)=%1.20e, expected %1.20e\n", + mpfr_get_d1 (c), cos_x); exit (1); } mpfr_clear (xx); diff --git a/tests/tsqrt.c b/tests/tsqrt.c index 8f8541711..76f067193 100644 --- a/tests/tsqrt.c +++ b/tests/tsqrt.c @@ -161,7 +161,7 @@ special (void) mpfr_set_str_raw (x, "0.110100111010101000010001011"); if ((inexact = mpfr_sqrt (x, x, GMP_RNDZ)) >= 0) { - fprintf (stderr, "Wrong inexact flag: expected -1, got %d\n", inexact); + printf ("Wrong inexact flag: expected -1, got %d\n", inexact); exit (1); } @@ -174,7 +174,8 @@ special (void) mpfr_sqrt (x, z, GMP_RNDU); if (mpfr_get_d1 (x) != 1.5) { - fprintf (stderr, "Error: sqrt(1+ulp(1), up) should give 1.5 (prec=%u)\n", (unsigned) p); + printf ("Error: sqrt(1+ulp(1), up) should give 1.5 (prec=%u)\n", + (unsigned int) p); printf ("got "); mpfr_print_binary (x); puts (""); exit (1); } @@ -185,7 +186,7 @@ special (void) mpfr_set_str_raw (x, "1.1001E-2"); if ((inexact = mpfr_sqrt (x, x, GMP_RNDN))) { - fprintf (stderr, "Wrong inexact flag: expected 0, got %d\n", inexact); + printf ("Wrong inexact flag: expected 0, got %d\n", inexact); exit (1); } @@ -198,8 +199,8 @@ special (void) mpfr_sqrt (z, x, GMP_RNDN); if (mpfr_cmp_ui (z, 0) < 0) { - fprintf (stderr, "Error: square root of %e gives %e\n", - mpfr_get_d1 (x), mpfr_get_d1 (z)); + printf ("Error: square root of %e gives %e\n", + mpfr_get_d1 (x), mpfr_get_d1 (z)); exit (1); } @@ -217,7 +218,7 @@ special (void) mpfr_set_str (z, "1e55596835b5ef@-141", 16, GMP_RNDN); if (mpfr_cmp (x, z)) { - fprintf (stderr, "Error: square root of 8093416094703476*2^(-1075)\n"); + printf ("Error: square root of 8093416094703476*2^(-1075)\n"); exit (1); } @@ -240,7 +241,7 @@ check_inexact (mp_prec_t p) inexact = mpfr_sqrt (y, x, rnd); if (mpfr_mul (z, y, y, rnd)) /* exact since prec(z) = 2*prec(y) */ { - fprintf (stderr, "Error: multiplication should be exact\n"); + printf ("Error: multiplication should be exact\n"); exit (1); } mpfr_sub (z, z, x, rnd); /* exact also */ @@ -249,8 +250,8 @@ check_inexact (mp_prec_t p) ((inexact > 0) && (sign <= 0)) || ((inexact < 0) && (sign >= 0))) { - fprintf (stderr, "Error: wrong inexact flag, expected %d, got %d\n", - sign, inexact); + printf ("Error: wrong inexact flag, expected %d, got %d\n", + sign, inexact); printf ("x="); mpfr_print_binary (x); printf (" rnd=%s\n", mpfr_print_rnd_mode (rnd)); diff --git a/tests/tsub.c b/tests/tsub.c index 702980db6..9e8e9891b 100644 --- a/tests/tsub.c +++ b/tests/tsub.c @@ -46,7 +46,7 @@ check_diverse (void) mpfr_set_str_raw (y, "0.1011011110110111001001001001101100000110110101101100101001011E31"); if (mpfr_cmp (z, y)) { - fprintf (stderr, "Error in mpfr_sub (5)\n"); + printf ("Error in mpfr_sub (5)\n"); printf ("expected "); mpfr_print_binary (y); puts (""); printf ("got "); mpfr_print_binary (z); puts (""); exit (1); @@ -59,7 +59,7 @@ check_diverse (void) mpfr_set_str_raw (y, "-0.11111001001010010011010110101E-1"); if (mpfr_cmp (z, y)) { - fprintf (stderr, "Error in mpfr_sub (7)\n"); + printf ("Error in mpfr_sub (7)\n"); printf ("expected "); mpfr_print_binary (y); puts (""); printf ("got "); mpfr_print_binary (z); puts (""); exit (1); @@ -72,7 +72,7 @@ check_diverse (void) mpfr_set_str_raw (y, "-0.11111001001010010011010110101E-1"); if (mpfr_cmp (z, y)) { - fprintf (stderr, "Error in mpfr_sub (6)\n"); + printf ("Error in mpfr_sub (6)\n"); printf ("expected "); mpfr_print_binary (y); puts (""); printf ("got "); mpfr_print_binary (z); puts (""); exit (1); @@ -84,8 +84,7 @@ check_diverse (void) mpfr_set_str_raw (y, "0.10001100100101000100110111000100E0"); if ((inexact = mpfr_sub (x, x, y, GMP_RNDN))) { - fprintf (stderr, "Wrong inexact flag (2): got %d instead of 0\n", - inexact); + printf ("Wrong inexact flag (2): got %d instead of 0\n", inexact); exit (1); } @@ -95,8 +94,7 @@ check_diverse (void) mpfr_set_str_raw (y, "0.10011111101111000100001000000000E-3"); if ((inexact = mpfr_sub (x, x, y, GMP_RNDN))) { - fprintf (stderr, "Wrong inexact flag (1): got %d instead of 0\n", - inexact); + printf ("Wrong inexact flag (1): got %d instead of 0\n", inexact); exit (1); } @@ -108,7 +106,7 @@ check_diverse (void) mpfr_set_str_raw (y, "0.111111111111111111111111111111111E0"); if (mpfr_cmp (x, y)) { - fprintf (stderr, "Error in mpfr_sub (1 - 1E-33) with prec=33\n"); + printf ("Error in mpfr_sub (1 - 1E-33) with prec=33\n"); printf ("Expected "); mpfr_print_binary (y); puts (""); printf ("got "); mpfr_print_binary (x); puts (""); exit (1); @@ -121,7 +119,7 @@ check_diverse (void) mpfr_add (x, x, y, GMP_RNDN); if (mpfr_cmp_ui (x, 1)) { - fprintf (stderr, "Error in mpfr_sub (1 - 1E-33) with prec=32\n"); + printf ("Error in mpfr_sub (1 - 1E-33) with prec=32\n"); printf ("Expected 1.0, got "); mpfr_print_binary (x); puts (""); exit (1); } @@ -134,21 +132,21 @@ check_diverse (void) mpfr_sub (z, x, y, GMP_RNDZ); if (mpfr_cmp_ui (z, 1)) { - fprintf (stderr, "Error in mpfr_sub (1)\n"); + printf ("Error in mpfr_sub (1)\n"); exit (1); } mpfr_sub (z, x, y, GMP_RNDU); mpfr_set_str_raw (x, "1.000000000000000000000000000000000000000000000000000000000000001"); if (mpfr_cmp (z, x)) { - fprintf (stderr, "Error in mpfr_sub (2)\n"); + printf ("Error in mpfr_sub (2)\n"); exit (1); } mpfr_set_str_raw (x, "1.1110111011110001110111011111111111101000011001011100101100101101"); mpfr_sub (z, x, y, GMP_RNDN); if (mpfr_cmp_ui (z, 1)) { - fprintf (stderr, "Error in mpfr_sub (3)\n"); + printf ("Error in mpfr_sub (3)\n"); exit (1); } mpfr_set_prec (x, 66); @@ -156,16 +154,16 @@ check_diverse (void) mpfr_sub (z, x, y, GMP_RNDN); if (mpfr_cmp_ui (z, 1)) { - fprintf (stderr, "Error in mpfr_sub (4)\n"); + printf ("Error in mpfr_sub (4)\n"); exit (1); } - + /* check in-place operations */ mpfr_set_d (x, 1.0, GMP_RNDN); mpfr_sub (x, x, x, GMP_RNDN); if (mpfr_get_d1 (x) != 0.0) { - fprintf (stderr, "Error for mpfr_add (x, x, x, GMP_RNDN) with x=1.0\n"); + printf ("Error for mpfr_add (x, x, x, GMP_RNDN) with x=1.0\n"); exit (1); } @@ -179,7 +177,7 @@ check_diverse (void) got = mpfr_get_d1 (z); if (got != res) { - fprintf (stderr, "Error in mpfr_sub (1.22e9 - 2.32e5)\n"); + printf ("Error in mpfr_sub (1.22e9 - 2.32e5)\n"); printf ("expected %1.20e, got %1.20e\n", res, got); exit (1); } @@ -191,7 +189,7 @@ check_diverse (void) mpfr_set_str_raw (y, "0.10110000100100000101101100011111111011101000111000101E-464"); mpfr_sub (z, x, y, GMP_RNDN); if (mpfr_cmp (z, x)) { - fprintf (stderr, "mpfr_sub(z, x, y) failed for prec(x)=112, prec(y)=98\n"); + printf ("mpfr_sub(z, x, y) failed for prec(x)=112, prec(y)=98\n"); printf ("expected "); mpfr_print_binary (x); puts (""); printf ("got "); mpfr_print_binary (z); puts (""); exit (1); @@ -210,7 +208,7 @@ check_diverse (void) mpfr_set_str_raw (y, "0.11111"); if (mpfr_cmp (x, y)) { - fprintf (stderr, "Error in mpfr_sub (x, y, x, GMP_RNDD) for x=2^(-12), y=1\n"); + printf ("Error in mpfr_sub (x, y, x, GMP_RNDD) for x=2^(-12), y=1\n"); exit (1); } @@ -222,7 +220,7 @@ check_diverse (void) mpfr_set_str_raw (y, "-0.1E19"); if (mpfr_cmp (x, y)) { - fprintf (stderr, "Error in mpfr_add (2)\n"); + printf ("Error in mpfr_add (2)\n"); exit (1); } @@ -233,12 +231,12 @@ check_diverse (void) mpfr_set_str_raw (z, "0.100000000000000000000100E15"); if (mpfr_sub (x, y, z, GMP_RNDN) <= 0) { - fprintf (stderr, "Wrong inexact flag in x=mpfr_sub(0,z) for prec(z)>prec(x)\n"); + printf ("Wrong inexact flag in x=mpfr_sub(0,z) for prec(z)>prec(x)\n"); exit (1); } if (mpfr_sub (x, z, y, GMP_RNDN) >= 0) { - fprintf (stderr, "Wrong inexact flag in x=mpfr_sub(z,0) for prec(z)>prec(x)\n"); + printf ("Wrong inexact flag in x=mpfr_sub(z,0) for prec(z)>prec(x)\n"); exit (1); } @@ -267,12 +265,12 @@ bug_ddefour(void) mpfr_sub( tot1, tot, ex1, GMP_RNDN); /* tot1 = tot - ex1 */ mpfr_set( ex3, tot1, GMP_RNDN); /* ex3 = high(tot - ex1) */ - if (mpfr_cmp(ex2, ex3)) + if (mpfr_cmp(ex2, ex3)) { - fprintf (stderr, "Error in ddefour test.\n"); - printf ("ex2="); mpfr_print_binary (ex2); puts (""); - printf ("ex3="); mpfr_print_binary (ex3); puts (""); - exit (1); + printf ("Error in ddefour test.\n"); + printf ("ex2="); mpfr_print_binary (ex2); puts (""); + printf ("ex3="); mpfr_print_binary (ex3); puts (""); + exit (1); } mpfr_clear (ex); @@ -290,7 +288,7 @@ check_two_sum (mp_prec_t p) mpfr_t x, y, u, v, w; mp_rnd_t rnd; int inexact; - + mpfr_init2 (x, p); mpfr_init2 (y, p); mpfr_init2 (u, p); @@ -310,7 +308,7 @@ check_two_sum (mp_prec_t p) ((inexact > 0) && (mpfr_cmp_ui (w, 0) <= 0)) || ((inexact < 0) && (mpfr_cmp_ui (w, 0) >= 0))) { - fprintf (stderr, "Wrong inexact flag for prec=%u, rnd=%s\n", (unsigned)p, + printf ("Wrong inexact flag for prec=%u, rnd=%s\n", (unsigned)p, mpfr_print_rnd_mode (rnd)); printf ("x="); mpfr_print_binary(x); puts (""); printf ("y="); mpfr_print_binary(y); puts (""); @@ -336,7 +334,7 @@ check_inexact (void) mp_prec_t px, py, pu, pz; int inexact, cmp; mp_rnd_t rnd; - + mpfr_init (x); mpfr_init (y); mpfr_init (z); @@ -351,7 +349,7 @@ check_inexact (void) inexact = mpfr_sub (y, y, x, GMP_RNDN); /* y = round(-7/16) = -1/2 */ if (inexact >= 0) { - fprintf (stderr, "Error: wrong inexact flag for -1/16 - (6/16)\n"); + printf ("Error: wrong inexact flag for -1/16 - (6/16)\n"); exit (1); } @@ -364,47 +362,47 @@ check_inexact (void) } while (mpfr_cmp_ui (x, 0) == 0); for (pu=2; pu<MAX_PREC; pu++) - { - mpfr_set_prec (u, pu); + { + mpfr_set_prec (u, pu); do { mpfr_random (u); } while (mpfr_cmp_ui (u, 0) == 0); - for (py=2; py<MAX_PREC; py++) - { - mpfr_set_prec (y, py); + for (py=2; py<MAX_PREC; py++) + { + mpfr_set_prec (y, py); /* warning: MPFR_EXP is undefined for 0 */ - pz = (mpfr_cmpabs (x, u) >= 0) ? MPFR_EXP(x) - MPFR_EXP(u) - : MPFR_EXP(u) - MPFR_EXP(x); - pz = pz + MAX(MPFR_PREC(x), MPFR_PREC(u)); - mpfr_set_prec (z, pz); - rnd = randlimb () % 4; - if (mpfr_sub (z, x, u, rnd)) - { - fprintf (stderr, "z <- x - u should be exact\n"); - exit (1); - } - for (rnd=0; rnd<4; rnd++) - { - inexact = mpfr_sub (y, x, u, rnd); - cmp = mpfr_cmp (y, z); - if (((inexact == 0) && (cmp != 0)) || - ((inexact > 0) && (cmp <= 0)) || - ((inexact < 0) && (cmp >= 0))) - { - fprintf (stderr, "Wrong inexact flag for rnd=%s\n", - mpfr_print_rnd_mode(rnd)); - printf ("expected %d, got %d\n", cmp, inexact); - printf ("x="); mpfr_print_binary (x); puts (""); - printf ("u="); mpfr_print_binary (u); puts (""); - printf ("y= "); mpfr_print_binary (y); puts (""); - printf ("x-u="); mpfr_print_binary (z); puts (""); - exit (1); - } - } - } - } + pz = (mpfr_cmpabs (x, u) >= 0) ? MPFR_EXP(x) - MPFR_EXP(u) + : MPFR_EXP(u) - MPFR_EXP(x); + pz = pz + MAX(MPFR_PREC(x), MPFR_PREC(u)); + mpfr_set_prec (z, pz); + rnd = randlimb () % 4; + if (mpfr_sub (z, x, u, rnd)) + { + printf ("z <- x - u should be exact\n"); + exit (1); + } + for (rnd=0; rnd<4; rnd++) + { + inexact = mpfr_sub (y, x, u, rnd); + cmp = mpfr_cmp (y, z); + if (((inexact == 0) && (cmp != 0)) || + ((inexact > 0) && (cmp <= 0)) || + ((inexact < 0) && (cmp >= 0))) + { + printf ("Wrong inexact flag for rnd=%s\n", + mpfr_print_rnd_mode(rnd)); + printf ("expected %d, got %d\n", cmp, inexact); + printf ("x="); mpfr_print_binary (x); puts (""); + printf ("u="); mpfr_print_binary (u); puts (""); + printf ("y= "); mpfr_print_binary (y); puts (""); + printf ("x-u="); mpfr_print_binary (z); puts (""); + exit (1); + } + } + } + } } mpfr_clear (x); diff --git a/tests/tsub_ui.c b/tests/tsub_ui.c index 5fbeb4a18..298a884cd 100644 --- a/tests/tsub_ui.c +++ b/tests/tsub_ui.c @@ -67,7 +67,7 @@ check_two_sum (mp_prec_t p) mpfr_t y, u, v, w; mp_rnd_t rnd; int inexact; - + mpfr_init2 (y, p); mpfr_init2 (u, p); mpfr_init2 (v, p); @@ -88,8 +88,8 @@ check_two_sum (mp_prec_t p) ((inexact > 0) && (mpfr_cmp_ui (w, 0) <= 0)) || ((inexact < 0) && (mpfr_cmp_ui (w, 0) >= 0))) { - fprintf (stderr, "Wrong inexact flag for prec=%u, rnd=%s\n", (unsigned)p, - mpfr_print_rnd_mode (rnd)); + printf ("Wrong inexact flag for prec=%u, rnd=%s\n", + (unsigned int) p, mpfr_print_rnd_mode (rnd)); printf ("x=%u\n", x); printf ("y="); mpfr_print_binary(y); puts (""); printf ("u="); mpfr_print_binary(u); puts (""); diff --git a/tests/tswap.c b/tests/tswap.c index 80b75e251..4df375d3d 100644 --- a/tests/tswap.c +++ b/tests/tswap.c @@ -1,6 +1,6 @@ /* Test file for mpfr_swap. -Copyright 2000, 2001, 2002 Free Software Foundation, Inc. +Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -38,10 +38,11 @@ main (void) mpfr_set_d (v, 9007199254740991.0, GMP_RNDN); /* 2^53 - 1 */ mpfr_swap (u, v); mpfr_swap (u, v); - if (mpfr_cmp_ui (u, 16777215) || (mpfr_get_d1 (v) != 9007199254740991.0)) { - fprintf (stderr, "Error in mpfr_swap\n"); - exit (1); - } + if (mpfr_cmp_ui (u, 16777215) || (mpfr_get_d1 (v) != 9007199254740991.0)) + { + printf ("Error in mpfr_swap\n"); + exit (1); + } mpfr_clear (u); mpfr_clear (v); diff --git a/tests/ttan.c b/tests/ttan.c index cad07a679..8e6894050 100644 --- a/tests/ttan.c +++ b/tests/ttan.c @@ -41,7 +41,7 @@ check_nans (void) mpfr_tan (y, x, GMP_RNDN); if (! mpfr_nan_p (y)) { - fprintf (stderr, "Error: tan(NaN) != NaN\n"); + printf ("Error: tan(NaN) != NaN\n"); exit (1); } @@ -49,7 +49,7 @@ check_nans (void) mpfr_tan (y, x, GMP_RNDN); if (! mpfr_nan_p (y)) { - fprintf (stderr, "Error: tan(Inf) != NaN\n"); + printf ("Error: tan(Inf) != NaN\n"); exit (1); } @@ -57,7 +57,7 @@ check_nans (void) mpfr_tan (y, x, GMP_RNDN); if (! mpfr_nan_p (y)) { - fprintf (stderr, "Error: tan(-Inf) != NaN\n"); + printf ("Error: tan(-Inf) != NaN\n"); exit (1); } @@ -84,8 +84,8 @@ main(int argc, char *argv[]) mpfr_tan (x, x, GMP_RNDD); if (mpfr_get_d1 (x) != 0.5) { - fprintf (stderr, "mpfr_tan(0.5, GMP_RNDD) failed\n"); - fprintf (stderr, "expected 0.5, got %f\n", mpfr_get_d1 (x)); + printf ("mpfr_tan(0.5, GMP_RNDD) failed\n" + "expected 0.5, got %f\n", mpfr_get_d1 (x)); exit (1); } @@ -99,7 +99,7 @@ main(int argc, char *argv[]) mpfr_tan (x, x, GMP_RNDN); if (mpfr_cmp_si (x, -1)) { - fprintf (stderr, "tan(3*Pi/4) fails for prec=%u\n", prec[i]); + printf ("tan(3*Pi/4) fails for prec=%u\n", prec[i]); exit (1); } } @@ -114,7 +114,7 @@ main(int argc, char *argv[]) mpfr_tan (x, x, GMP_RNDN); if (mpfr_cmp_si (x, -1)) { - fprintf (stderr, "tan(3*Pi/4) fails for prec=%u\n", prec2[i]); + printf ("tan(3*Pi/4) fails for prec=%u\n", prec2[i]); exit (1); } } diff --git a/tests/ttrunc.c b/tests/ttrunc.c index a28828482..dedaa36de 100644 --- a/tests/ttrunc.c +++ b/tests/ttrunc.c @@ -1,6 +1,6 @@ /* Test file for mpfr_trunc, mpfr_ceil, mpfr_floor. -Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -31,117 +31,132 @@ MA 02111-1307, USA. */ int main (void) { - int j, k; mpfr_t x, y, z, t, y2, z2, t2; + int j, k; mpfr_t x, y, z, t, y2, z2, t2; tests_start_mpfr (); - mpfr_init2(x, SIZEX); - mpfr_init2(y, SIZEX); - mpfr_init2(z, SIZEX); - mpfr_init2(t, SIZEX); - mpfr_init2(y2, SIZEX); - mpfr_init2(z2, SIZEX); + mpfr_init2(x, SIZEX); + mpfr_init2(y, SIZEX); + mpfr_init2(z, SIZEX); + mpfr_init2(t, SIZEX); + mpfr_init2(y2, SIZEX); + mpfr_init2(z2, SIZEX); mpfr_init2(t2, SIZEX); mpfr_set_d(x, 0.5, GMP_RNDN); mpfr_ceil(y, x); - if (mpfr_get_d1 (y) != 1.0) { - fprintf(stderr, "Error in mpfr_ceil for x=0.5: expected 1.0, got %f\n", - mpfr_get_d1 (y)); exit(1); - } + if (mpfr_get_d1 (y) != 1.0) + { + printf ("Error in mpfr_ceil for x=0.5: expected 1.0, got %f\n", + mpfr_get_d1 (y)); + exit (1); + } mpfr_set_d(x, 0.0, GMP_RNDN); mpfr_ceil(y, x); - if (mpfr_get_d1 (y) != 0.0) { - fprintf(stderr, "Error in mpfr_ceil for x=0.0: expected 0.0, got %f\n", - mpfr_get_d1 (y)); exit(1); - } + if (mpfr_get_d1 (y) != 0.0) + { + printf ("Error in mpfr_ceil for x=0.0: expected 0.0, got %f\n", + mpfr_get_d1 (y)); + exit (1); + } mpfr_set_d(x, 1.0, GMP_RNDN); mpfr_ceil(y, x); - if (mpfr_get_d1 (y) != 1.0) { - fprintf(stderr, "Error in mpfr_ceil for x=1.0: expected 1.0, got %f\n", - mpfr_get_d1 (y)); exit(1); - } - - for (j=0;j<1000;j++) { - - mpfr_random(x); - MPFR_EXP(x) = 2; - - for (k = 2; k <= SIZEX; k++) - { - mpfr_set_prec(y, k); - mpfr_set_prec(y2, k); - mpfr_set_prec(z, k); - mpfr_set_prec(z2, k); - mpfr_set_prec(t, k); - mpfr_set_prec(t2, k); - - mpfr_floor(y, x); - mpfr_set(y2, x, GMP_RNDD); - - mpfr_trunc(z, x); - mpfr_set(z2, x, GMP_RNDZ); - - mpfr_ceil(t, x); - mpfr_set(t2, x, GMP_RNDU); - - if (!mpfr_eq(y, y2, k)) - { - printf("Error in floor, x = "); mpfr_print_binary(x); printf("\n"); - printf("floor(x) = "); mpfr_print_binary(y); printf("\n"); - printf("round(x, RNDD) = "); mpfr_print_binary(y2); printf("\n"); - mpfr_clear(x); - mpfr_clear(y); - mpfr_clear(y2); - mpfr_clear(z); - mpfr_clear(z2); - mpfr_clear(t); - mpfr_clear(t2); - exit(-1); - } - - if (!mpfr_eq(z, z2, k)) - { - printf("Error in trunc, x = "); mpfr_print_binary(x); printf("\n"); - printf("trunc(x) = "); mpfr_print_binary(z); printf("\n"); - printf("round(x, RNDZ) = "); mpfr_print_binary(z2); printf("\n"); - mpfr_clear(x); - mpfr_clear(y); - mpfr_clear(y2); - mpfr_clear(z); - mpfr_clear(z2); - mpfr_clear(t); - mpfr_clear(t2); - exit(-1); - } - - if (!mpfr_eq(y, y2, k)) - { - printf("Error in ceil, x = "); mpfr_print_binary(x); printf("\n"); - printf("ceil(x) = "); mpfr_print_binary(t); printf("\n"); - printf("round(x, RNDU) = "); mpfr_print_binary(t2); printf("\n"); - mpfr_clear(x); - mpfr_clear(y); - mpfr_clear(y2); - mpfr_clear(z); - mpfr_clear(z2); - mpfr_clear(t); - mpfr_clear(t2); - exit(-1); - } - MPFR_EXP(x)++; - } - } - - mpfr_clear(x); - mpfr_clear(y); - mpfr_clear(y2); - mpfr_clear(z); - mpfr_clear(z2); - mpfr_clear(t); - mpfr_clear(t2); + if (mpfr_get_d1 (y) != 1.0) + { + printf ("Error in mpfr_ceil for x=1.0: expected 1.0, got %f\n", + mpfr_get_d1 (y)); + exit (1); + } + + for (j=0;j<1000;j++) + { + mpfr_random (x); + MPFR_EXP (x) = 2; + + for (k = 2; k <= SIZEX; k++) + { + mpfr_set_prec(y, k); + mpfr_set_prec(y2, k); + mpfr_set_prec(z, k); + mpfr_set_prec(z2, k); + mpfr_set_prec(t, k); + mpfr_set_prec(t2, k); + + mpfr_floor(y, x); + mpfr_set(y2, x, GMP_RNDD); + + mpfr_trunc(z, x); + mpfr_set(z2, x, GMP_RNDZ); + + mpfr_ceil(t, x); + mpfr_set(t2, x, GMP_RNDU); + + if (!mpfr_eq(y, y2, k)) + { + printf("Error in floor, x = "); mpfr_print_binary(x); + printf("\n"); + printf("floor(x) = "); mpfr_print_binary(y); + printf("\n"); + printf("round(x, RNDD) = "); mpfr_print_binary(y2); + printf("\n"); + mpfr_clear(x); + mpfr_clear(y); + mpfr_clear(y2); + mpfr_clear(z); + mpfr_clear(z2); + mpfr_clear(t); + mpfr_clear(t2); + exit(-1); + } + + if (!mpfr_eq(z, z2, k)) + { + printf("Error in trunc, x = "); mpfr_print_binary(x); + printf("\n"); + printf("trunc(x) = "); mpfr_print_binary(z); + printf("\n"); + printf("round(x, RNDZ) = "); mpfr_print_binary(z2); + printf("\n"); + mpfr_clear(x); + mpfr_clear(y); + mpfr_clear(y2); + mpfr_clear(z); + mpfr_clear(z2); + mpfr_clear(t); + mpfr_clear(t2); + exit(-1); + } + + if (!mpfr_eq(y, y2, k)) + { + printf("Error in ceil, x = "); mpfr_print_binary(x); + printf("\n"); + printf("ceil(x) = "); mpfr_print_binary(t); + printf("\n"); + printf("round(x, RNDU) = "); mpfr_print_binary(t2); + printf("\n"); + mpfr_clear(x); + mpfr_clear(y); + mpfr_clear(y2); + mpfr_clear(z); + mpfr_clear(z2); + mpfr_clear(t); + mpfr_clear(t2); + exit(-1); + } + MPFR_EXP(x)++; + } + } + + mpfr_clear(x); + mpfr_clear(y); + mpfr_clear(y2); + mpfr_clear(z); + mpfr_clear(z2); + mpfr_clear(t); + mpfr_clear(t2); tests_end_mpfr (); return 0; diff --git a/tests/tui_div.c b/tests/tui_div.c index 5c4c33a52..da432b5a8 100644 --- a/tests/tui_div.c +++ b/tests/tui_div.c @@ -60,7 +60,7 @@ check_inexact (void) int inexact, cmp; unsigned long int u; mp_rnd_t rnd; - + mpfr_init (x); mpfr_init (y); mpfr_init (z); @@ -75,32 +75,32 @@ check_inexact (void) while (mpfr_cmp_ui (x, 0) == 0); u = randlimb (); for (py=2; py<300; py++) - { - mpfr_set_prec (y, py); - mpfr_set_prec (z, py + px); - for (rnd=0; rnd<4; rnd++) - { - inexact = mpfr_ui_div (y, u, x, rnd); - if (mpfr_mul (z, y, x, rnd)) - { - fprintf (stderr, "z <- y * x should be exact\n"); - exit (1); - } - cmp = mpfr_cmp_ui (z, u); - if (((inexact == 0) && (cmp != 0)) || - ((inexact > 0) && (cmp <= 0)) || - ((inexact < 0) && (cmp >= 0))) - { - fprintf (stderr, "Wrong inexact flag for u=%lu, rnd=%s\n", u, - mpfr_print_rnd_mode(rnd)); - printf ("expected %d, got %d\n", cmp, inexact); - printf ("x="); mpfr_print_binary (x); puts (""); - printf ("y="); mpfr_print_binary (y); puts (""); - printf ("y*x="); mpfr_print_binary (z); puts (""); - exit (1); - } - } - } + { + mpfr_set_prec (y, py); + mpfr_set_prec (z, py + px); + for (rnd=0; rnd<4; rnd++) + { + inexact = mpfr_ui_div (y, u, x, rnd); + if (mpfr_mul (z, y, x, rnd)) + { + printf ("z <- y * x should be exact\n"); + exit (1); + } + cmp = mpfr_cmp_ui (z, u); + if (((inexact == 0) && (cmp != 0)) || + ((inexact > 0) && (cmp <= 0)) || + ((inexact < 0) && (cmp >= 0))) + { + printf ("Wrong inexact flag for u=%lu, rnd=%s\n", + u, mpfr_print_rnd_mode (rnd)); + printf ("expected %d, got %d\n", cmp, inexact); + printf ("x="); mpfr_print_binary (x); puts (""); + printf ("y="); mpfr_print_binary (y); puts (""); + printf ("y*x="); mpfr_print_binary (z); puts (""); + exit (1); + } + } + } } mpfr_clear (x); diff --git a/tests/tui_pow.c b/tests/tui_pow.c index 2287e45ab..e9df640cc 100644 --- a/tests/tui_pow.c +++ b/tests/tui_pow.c @@ -94,9 +94,8 @@ check1 (mpfr_ptr x, mp_prec_t prec, unsigned long nt, mp_rnd_t rnd) ((inexact > 0) && (compare <= 0)) || ((inexact < 0) && (compare >= 0))) { - fprintf (stderr, - "Wrong inexact flag for rnd=%s: expected %d, got %d\n", - mpfr_print_rnd_mode (rnd), compare, inexact); + printf ("Wrong inexact flag for rnd=%s: expected %d, got %d\n", + mpfr_print_rnd_mode (rnd), compare, inexact); printf ("x="); mpfr_print_binary (x); puts (""); printf ("y="); mpfr_print_binary (y); puts (""); printf ("t="); mpfr_print_binary (t); puts (""); diff --git a/tests/tui_sub.c b/tests/tui_sub.c index f53ecbf6f..26ba62bb4 100644 --- a/tests/tui_sub.c +++ b/tests/tui_sub.c @@ -34,7 +34,7 @@ special (void) { mpfr_t x, y, res; int inexact; - + mpfr_init (x); mpfr_init (y); mpfr_init (res); @@ -45,7 +45,7 @@ special (void) inexact = mpfr_ui_sub (x, 1, y, GMP_RNDN); if (inexact) { - fprintf (stderr, "Wrong inexact flag: got %d, expected 0\n", inexact); + printf ("Wrong inexact flag: got %d, expected 0\n", inexact); exit (1); } @@ -54,7 +54,7 @@ special (void) mpfr_set_str_raw (y, "0.111100110001011010111"); if ((inexact = mpfr_ui_sub (x, 38181761, y, GMP_RNDN)) >= 0) { - fprintf (stderr, "Wrong inexact flag: got %d, expected -1\n", inexact); + printf ("Wrong inexact flag: got %d, expected -1\n", inexact); exit (1); } @@ -63,7 +63,7 @@ special (void) mpfr_set_str_raw (y, "0.111110010010100100110101101010001001100101110001000101110111111E-1"); if ((inexact = mpfr_ui_sub (x, 1541116494, y, GMP_RNDN)) <= 0) { - fprintf (stderr, "Wrong inexact flag: got %d, expected +1\n", inexact); + printf ("Wrong inexact flag: got %d, expected +1\n", inexact); exit (1); } @@ -72,7 +72,7 @@ special (void) mpfr_set_str_raw (y, "0.11011000110111010001011100011100E-1"); if ((inexact = mpfr_ui_sub (x, 2000375416, y, GMP_RNDN)) >= 0) { - fprintf (stderr, "Wrong inexact flag: got %d, expected -1\n", inexact); + printf ("Wrong inexact flag: got %d, expected -1\n", inexact); exit (1); } @@ -81,7 +81,7 @@ special (void) mpfr_set_str_raw (y, "0.110011011001010011110111E-2"); if ((inexact = mpfr_ui_sub (x, 927694848, y, GMP_RNDN)) <= 0) { - fprintf (stderr, "Wrong inexact flag: got %d, expected +1\n", inexact); + printf ("Wrong inexact flag: got %d, expected +1\n", inexact); exit (1); } @@ -95,32 +95,34 @@ special (void) mpfr_set_str_raw (res, "0.11111"); if (mpfr_cmp (y, res)) { - fprintf (stderr, "Error in mpfr_ui_sub (y, 1, x, GMP_RNDD) for x=2^(-12)\nexpected 1.1111e-1, got "); - mpfr_out_str (stderr, 2, 0, y, GMP_RNDN); - fprintf (stderr, "\n"); + printf ("Error in mpfr_ui_sub (y, 1, x, GMP_RNDD) for x=2^(-12)\nexpected 1.1111e-1, got "); + mpfr_out_str (stdout, 2, 0, y, GMP_RNDN); + printf ("\n"); exit (1); } - + mpfr_ui_sub (y, 1, x, GMP_RNDU); mpfr_set_str_raw (res, "1.0"); if (mpfr_cmp (y, res)) { - fprintf (stderr, "Error in mpfr_ui_sub (y, 1, x, GMP_RNDU) for x=2^(-12)\nexpected 1.0, got "); - mpfr_out_str (stderr, 2, 0, y, GMP_RNDN); - fprintf (stderr, "\n"); + printf ("Error in mpfr_ui_sub (y, 1, x, GMP_RNDU) for x=2^(-12)\n" + "expected 1.0, got "); + mpfr_out_str (stdout, 2, 0, y, GMP_RNDN); + printf ("\n"); exit (1); } - + mpfr_ui_sub (y, 1, x, GMP_RNDN); mpfr_set_str_raw (res, "1.0"); if (mpfr_cmp (y, res)) { - fprintf (stderr, "Error in mpfr_ui_sub (y, 1, x, GMP_RNDN) for x=2^(-12)\nexpected 1.0, got "); - mpfr_out_str (stderr, 2, 0, y, GMP_RNDN); - fprintf (stderr, "\n"); + printf ("Error in mpfr_ui_sub (y, 1, x, GMP_RNDN) for x=2^(-12)\n" + "expected 1.0, got "); + mpfr_out_str (stdout, 2, 0, y, GMP_RNDN); + printf ("\n"); exit (1); } - + mpfr_clear (x); mpfr_clear (y); mpfr_clear (res); @@ -158,7 +160,7 @@ check_two_sum (mp_prec_t p) mpfr_t y, u, v, w; mp_rnd_t rnd; int inexact; - + mpfr_init2 (y, p); mpfr_init2 (u, p); mpfr_init2 (v, p); @@ -179,8 +181,8 @@ check_two_sum (mp_prec_t p) ((inexact > 0) && (mpfr_cmp_ui (w, 0) <= 0)) || ((inexact < 0) && (mpfr_cmp_ui (w, 0) >= 0))) { - fprintf (stderr, "Wrong inexact flag for prec=%u, rnd=%s\n", (unsigned)p, - mpfr_print_rnd_mode (rnd)); + printf ("Wrong inexact flag for prec=%u, rnd=%s\n", + (unsigned int) p, mpfr_print_rnd_mode (rnd)); printf ("x=%u\n", x); printf ("y="); mpfr_print_binary(y); puts (""); printf ("u="); mpfr_print_binary(u); puts (""); diff --git a/tests/tzeta.c b/tests/tzeta.c index bf9037f32..2ca6793c6 100644 --- a/tests/tzeta.c +++ b/tests/tzeta.c @@ -115,8 +115,8 @@ main (int argc, char *argv[]) if (argc != 1 && argc != 4) { - fprintf (stderr, "Usage: tzeta\n"); - fprintf (stderr, " or tzeta s prec rnd_mode\n"); + printf ("Usage: tzeta\n" + " or tzeta s prec rnd_mode\n"); exit (1); } @@ -160,7 +160,7 @@ main (int argc, char *argv[]) mpfr_zeta (z, s, GMP_RNDN); if (!mpfr_inf_p (z) || MPFR_SIGN (z) < 0) { - fprintf (stderr, "Error in mpfr_zeta for s = 1 (should be +inf)\n"); + printf ("Error in mpfr_zeta for s = 1 (should be +inf)\n"); exit (1); } @@ -169,26 +169,26 @@ main (int argc, char *argv[]) mpfr_zeta (z, s, GMP_RNDN); if (mpfr_cmp (z, y) != 0) { - fprintf (stderr, "Error in mpfr_zeta (1,RNDN)\n"); + printf ("Error in mpfr_zeta (1,RNDN)\n"); exit (1); } mpfr_zeta (z, s, GMP_RNDZ); if (mpfr_cmp (z, y) != 0) { - fprintf (stderr, "Error in mpfr_zeta (1,RNDZ)\n"); + printf ("Error in mpfr_zeta (1,RNDZ)\n"); exit (1); } mpfr_zeta (z, s, GMP_RNDU); if (mpfr_cmp (z, y) != 0) { - fprintf (stderr, "Error in mpfr_zeta (1,RNDU)\n"); + printf ("Error in mpfr_zeta (1,RNDU)\n"); exit (1); } mpfr_zeta (z, s, GMP_RNDD); mpfr_add_one_ulp (y, GMP_RNDD); if (mpfr_cmp (z, y) != 0) { - fprintf (stderr, "Error in mpfr_zeta (1,RNDD)\n"); + printf ("Error in mpfr_zeta (1,RNDD)\n"); exit (1); } @@ -197,26 +197,26 @@ main (int argc, char *argv[]) mpfr_zeta (z, s, GMP_RNDN); if (mpfr_cmp (z, y) != 0) { - fprintf (stderr, "Error in mpfr_zeta (2,RNDN)\n"); + printf ("Error in mpfr_zeta (2,RNDN)\n"); exit (1); } mpfr_zeta (z, s, GMP_RNDZ); if (mpfr_cmp (z, y) != 0) { - fprintf (stderr, "Error in mpfr_zeta (2,RNDZ)\n"); + printf ("Error in mpfr_zeta (2,RNDZ)\n"); exit (1); } mpfr_zeta (z, s, GMP_RNDU); if (mpfr_cmp (z, y) != 0) { - fprintf (stderr, "Error in mpfr_zeta (2,RNDU)\n"); + printf ("Error in mpfr_zeta (2,RNDU)\n"); exit (1); } mpfr_zeta (z, s, GMP_RNDD); mpfr_add_one_ulp (y, GMP_RNDD); if (mpfr_cmp (z, y) != 0) { - fprintf (stderr, "Error in mpfr_zeta (2,RNDD)\n"); + printf ("Error in mpfr_zeta (2,RNDD)\n"); exit (1); } @@ -225,26 +225,26 @@ main (int argc, char *argv[]) mpfr_zeta (z, s, GMP_RNDN); if (mpfr_cmp (z, y) != 0) { - fprintf (stderr, "Error in mpfr_zeta (3,RNDN)\n"); + printf ("Error in mpfr_zeta (3,RNDN)\n"); exit (1); } mpfr_zeta (z, s, GMP_RNDD); if (mpfr_cmp (z, y) != 0) { - fprintf (stderr, "Error in mpfr_zeta (3,RNDD)\n"); + printf ("Error in mpfr_zeta (3,RNDD)\n"); exit (1); } mpfr_sub_one_ulp (y, GMP_RNDZ); mpfr_zeta (z, s, GMP_RNDZ); if (mpfr_cmp (z, y) != 0) { - fprintf (stderr, "Error in mpfr_zeta (3,RNDZ)\n"); + printf ("Error in mpfr_zeta (3,RNDZ)\n"); exit (1); } mpfr_zeta (z, s, GMP_RNDU); if (mpfr_cmp (z, y) != 0) { - fprintf (stderr, "Error in mpfr_zeta (3,RNDU)\n"); + printf ("Error in mpfr_zeta (3,RNDU)\n"); exit (1); } |