diff options
Diffstat (limited to 'tests/tset_si.c')
-rw-r--r-- | tests/tset_si.c | 142 |
1 files changed, 71 insertions, 71 deletions
diff --git a/tests/tset_si.c b/tests/tset_si.c index a07da8cba..1bb5a7294 100644 --- a/tests/tset_si.c +++ b/tests/tset_si.c @@ -36,55 +36,55 @@ test_2exp (void) mpfr_init2 (x, 32); - mpfr_set_ui_2exp (x, 1, 0, GMP_RNDN); + mpfr_set_ui_2exp (x, 1, 0, MPFR_RNDN); if (mpfr_cmp_ui(x, 1)) ERROR("(1U,0)"); - mpfr_set_ui_2exp (x, 1024, -10, GMP_RNDN); + mpfr_set_ui_2exp (x, 1024, -10, MPFR_RNDN); if (mpfr_cmp_ui(x, 1)) ERROR("(1024U,-10)"); - mpfr_set_ui_2exp (x, 1024, 10, GMP_RNDN); + mpfr_set_ui_2exp (x, 1024, 10, MPFR_RNDN); if (mpfr_cmp_ui(x, 1024*1024)) ERROR("(1024U,+10)"); - mpfr_set_si_2exp (x, -1024L * 1024L, -10, GMP_RNDN); + mpfr_set_si_2exp (x, -1024L * 1024L, -10, MPFR_RNDN); if (mpfr_cmp_si(x, -1024)) ERROR("(1M,-10)"); - mpfr_set_ui_2exp (x, 0x92345678, 16, GMP_RNDN); - if (mpfr_cmp_str (x, "92345678@4", 16, GMP_RNDN)) + mpfr_set_ui_2exp (x, 0x92345678, 16, MPFR_RNDN); + if (mpfr_cmp_str (x, "92345678@4", 16, MPFR_RNDN)) ERROR("(x92345678U,+16)"); - mpfr_set_si_2exp (x, -0x1ABCDEF0, -256, GMP_RNDN); - if (mpfr_cmp_str (x, "-1ABCDEF0@-64", 16, GMP_RNDN)) + mpfr_set_si_2exp (x, -0x1ABCDEF0, -256, MPFR_RNDN); + if (mpfr_cmp_str (x, "-1ABCDEF0@-64", 16, MPFR_RNDN)) ERROR("(-x1ABCDEF0,-256)"); mpfr_set_prec (x, 2); - res = mpfr_set_si_2exp (x, 7, 10, GMP_RNDU); + res = mpfr_set_si_2exp (x, 7, 10, MPFR_RNDU); if (mpfr_cmp_ui (x, 1<<13) || res <= 0) ERROR ("Prec 2 + si_2exp"); - res = mpfr_set_ui_2exp (x, 7, 10, GMP_RNDU); + res = mpfr_set_ui_2exp (x, 7, 10, MPFR_RNDU); if (mpfr_cmp_ui (x, 1<<13) || res <= 0) ERROR ("Prec 2 + ui_2exp"); mpfr_clear_flags (); - mpfr_set_ui_2exp (x, 17, MPFR_EMAX_MAX, GMP_RNDN); + mpfr_set_ui_2exp (x, 17, MPFR_EMAX_MAX, MPFR_RNDN); if (!mpfr_inf_p (x) || MPFR_IS_NEG (x)) ERROR ("mpfr_set_ui_2exp and overflow (bad result)"); if (!mpfr_overflow_p ()) ERROR ("mpfr_set_ui_2exp and overflow (overflow flag not set)"); mpfr_clear_flags (); - mpfr_set_si_2exp (x, 17, MPFR_EMAX_MAX, GMP_RNDN); + mpfr_set_si_2exp (x, 17, MPFR_EMAX_MAX, MPFR_RNDN); if (!mpfr_inf_p (x) || MPFR_IS_NEG (x)) ERROR ("mpfr_set_si_2exp (pos) and overflow (bad result)"); if (!mpfr_overflow_p ()) ERROR ("mpfr_set_si_2exp (pos) and overflow (overflow flag not set)"); mpfr_clear_flags (); - mpfr_set_si_2exp (x, -17, MPFR_EMAX_MAX, GMP_RNDN); + mpfr_set_si_2exp (x, -17, MPFR_EMAX_MAX, MPFR_RNDN); if (!mpfr_inf_p (x) || MPFR_IS_POS (x)) ERROR ("mpfr_set_si_2exp (neg) and overflow (bad result)"); if (!mpfr_overflow_p ()) @@ -145,8 +145,8 @@ main (int argc, char *argv[]) for (k = 1; k <= N; k++) { z = (long) (randlimb () & LONG_MAX) + LONG_MIN / 2; - inex = mpfr_set_si (x, z, GMP_RNDZ); - d = mpfr_get_si (x, GMP_RNDZ); + inex = mpfr_set_si (x, z, MPFR_RNDZ); + d = mpfr_get_si (x, MPFR_RNDZ); if (d != z) { printf ("Error in mpfr_set_si: expected %ld got %ld\n", z, d); @@ -163,8 +163,8 @@ main (int argc, char *argv[]) for (k = 1; k <= N; k++) { zl = randlimb (); - inex = mpfr_set_ui (x, zl, GMP_RNDZ); - dl = mpfr_get_ui (x, GMP_RNDZ); + inex = mpfr_set_ui (x, zl, MPFR_RNDZ); + dl = mpfr_get_ui (x, MPFR_RNDZ); if (dl != zl) { printf ("Error in mpfr_set_ui: expected %lu got %lu\n", zl, dl); @@ -179,56 +179,56 @@ main (int argc, char *argv[]) } mpfr_set_prec (x, 2); - if (mpfr_set_si (x, 5, GMP_RNDZ) >= 0) + if (mpfr_set_si (x, 5, MPFR_RNDZ) >= 0) { - printf ("Wrong inexact flag for x=5, rnd=GMP_RNDZ\n"); + printf ("Wrong inexact flag for x=5, rnd=MPFR_RNDZ\n"); exit (1); } mpfr_set_prec (x, 2); - if (mpfr_set_si (x, -5, GMP_RNDZ) <= 0) + if (mpfr_set_si (x, -5, MPFR_RNDZ) <= 0) { - printf ("Wrong inexact flag for x=-5, rnd=GMP_RNDZ\n"); + printf ("Wrong inexact flag for x=-5, rnd=MPFR_RNDZ\n"); exit (1); } mpfr_set_prec (x, 3); - inex = mpfr_set_si (x, 77617, GMP_RNDD); /* should be 65536 */ + inex = mpfr_set_si (x, 77617, MPFR_RNDD); /* should be 65536 */ if (MPFR_MANT(x)[0] != ((mp_limb_t)1 << (mp_bits_per_limb-1)) || inex >= 0) { - printf ("Error in mpfr_set_si(x:3, 77617, GMP_RNDD)\n"); + printf ("Error in mpfr_set_si(x:3, 77617, MPFR_RNDD)\n"); mpfr_print_binary (x); puts (""); exit (1); } - inex = mpfr_set_ui (x, 77617, GMP_RNDD); /* should be 65536 */ + inex = mpfr_set_ui (x, 77617, MPFR_RNDD); /* should be 65536 */ if (MPFR_MANT(x)[0] != ((mp_limb_t)1 << (mp_bits_per_limb-1)) || inex >= 0) { - printf ("Error in mpfr_set_ui(x:3, 77617, GMP_RNDD)\n"); + printf ("Error in mpfr_set_ui(x:3, 77617, MPFR_RNDD)\n"); mpfr_print_binary (x); puts (""); exit (1); } mpfr_set_prec (x, 2); - inex = mpfr_set_si (x, 33096, GMP_RNDU); - if (mpfr_get_si (x, GMP_RNDZ) != 49152 || inex <= 0) + inex = mpfr_set_si (x, 33096, MPFR_RNDU); + if (mpfr_get_si (x, MPFR_RNDZ) != 49152 || inex <= 0) { printf ("Error in mpfr_set_si, exp. 49152, got %ld, inex %d\n", - mpfr_get_si (x, GMP_RNDZ), inex); + mpfr_get_si (x, MPFR_RNDZ), inex); exit (1); } - inex = mpfr_set_ui (x, 33096, GMP_RNDU); - if (mpfr_get_si (x, GMP_RNDZ) != 49152) + inex = mpfr_set_ui (x, 33096, MPFR_RNDU); + if (mpfr_get_si (x, MPFR_RNDZ) != 49152) { printf ("Error in mpfr_set_ui, exp. 49152, got %ld, inex %d\n", - mpfr_get_si (x, GMP_RNDZ), inex); + mpfr_get_si (x, MPFR_RNDZ), inex); exit (1); } - for (r = 0 ; r < GMP_RND_MAX ; r++) + for (r = 0 ; r < MPFR_RND_MAX ; r++) { mpfr_set_si (x, -1, (mp_rnd_t) r); mpfr_set_ui (x, 0, (mp_rnd_t) r); @@ -252,7 +252,7 @@ main (int argc, char *argv[]) /* check potential bug in case mp_limb_t is unsigned */ emax = mpfr_get_emax (); set_emax (0); - mpfr_set_si (x, -1, GMP_RNDN); + mpfr_set_si (x, -1, MPFR_RNDN); if (mpfr_sgn (x) >= 0) { printf ("mpfr_set_si (x, -1) fails\n"); @@ -263,7 +263,7 @@ main (int argc, char *argv[]) emax = mpfr_get_emax (); set_emax (5); mpfr_set_prec (x, 2); - mpfr_set_si (x, -31, GMP_RNDN); + mpfr_set_si (x, -31, MPFR_RNDN); if (mpfr_sgn (x) >= 0) { printf ("mpfr_set_si (x, -31) fails\n"); @@ -272,100 +272,100 @@ main (int argc, char *argv[]) set_emax (emax); /* test for get_ui */ - mpfr_set_ui (x, 0, GMP_RNDN); - MPFR_ASSERTN(mpfr_get_ui (x, GMP_RNDN) == 0); - mpfr_set_ui (x, ULONG_MAX, GMP_RNDU); + mpfr_set_ui (x, 0, MPFR_RNDN); + MPFR_ASSERTN(mpfr_get_ui (x, MPFR_RNDN) == 0); + mpfr_set_ui (x, ULONG_MAX, MPFR_RNDU); mpfr_nextabove (x); - mpfr_get_ui (x, GMP_RNDU); + mpfr_get_ui (x, MPFR_RNDU); /* another test for get_ui */ mpfr_set_prec (x, 10); mpfr_set_str_binary (x, "10.101"); - dl = mpfr_get_ui (x, GMP_RNDN); + dl = mpfr_get_ui (x, MPFR_RNDN); MPFR_ASSERTN (dl == 3); mpfr_set_str_binary (x, "-1.0"); - mpfr_get_ui (x, GMP_RNDN); + mpfr_get_ui (x, MPFR_RNDN); mpfr_set_str_binary (x, "0.1"); - dl = mpfr_get_ui (x, GMP_RNDN); + dl = mpfr_get_ui (x, MPFR_RNDN); MPFR_ASSERTN (dl == 0); - dl = mpfr_get_ui (x, GMP_RNDZ); + dl = mpfr_get_ui (x, MPFR_RNDZ); MPFR_ASSERTN (dl == 0); - dl = mpfr_get_ui (x, GMP_RNDD); + dl = mpfr_get_ui (x, MPFR_RNDD); MPFR_ASSERTN (dl == 0); - dl = mpfr_get_ui (x, GMP_RNDU); + dl = mpfr_get_ui (x, MPFR_RNDU); MPFR_ASSERTN (dl == 1); /* coverage tests */ mpfr_set_prec (x, 2); - mpfr_set_si (x, -7, GMP_RNDD); + mpfr_set_si (x, -7, MPFR_RNDD); MPFR_ASSERTN(mpfr_cmp_si (x, -8) == 0); mpfr_set_prec (x, 2); - mpfr_set_ui (x, 7, GMP_RNDU); + mpfr_set_ui (x, 7, MPFR_RNDU); MPFR_ASSERTN(mpfr_cmp_ui (x, 8) == 0); emax = mpfr_get_emax (); set_emax (3); - mpfr_set_ui (x, 7, GMP_RNDU); + mpfr_set_ui (x, 7, MPFR_RNDU); MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0); set_emax (1); - MPFR_ASSERTN( mpfr_set_ui (x, 7, GMP_RNDU) ); + MPFR_ASSERTN( mpfr_set_ui (x, 7, MPFR_RNDU) ); MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0); set_emax (emax); - mpfr_set_ui_2exp (x, 17, -50, GMP_RNDN); - MPFR_ASSERTN (mpfr_get_ui (x, GMP_RNDD) == 0); - MPFR_ASSERTN (mpfr_get_si (x, GMP_RNDD) == 0); + mpfr_set_ui_2exp (x, 17, -50, MPFR_RNDN); + MPFR_ASSERTN (mpfr_get_ui (x, MPFR_RNDD) == 0); + MPFR_ASSERTN (mpfr_get_si (x, MPFR_RNDD) == 0); /* Test for ERANGE flag + correct behaviour if overflow */ mpfr_set_prec (x, 256); - mpfr_set_ui (x, ULONG_MAX, GMP_RNDN); + mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN); mpfr_clear_erangeflag (); - dl = mpfr_get_ui (x, GMP_RNDN); + dl = mpfr_get_ui (x, MPFR_RNDN); if (dl != ULONG_MAX || mpfr_erangeflag_p ()) { printf ("ERROR for get_ui + ERANGE + ULONG_MAX (1)\n"); exit (1); } - mpfr_add_ui (x, x, 1, GMP_RNDN); - dl = mpfr_get_ui (x, GMP_RNDN); + mpfr_add_ui (x, x, 1, MPFR_RNDN); + dl = mpfr_get_ui (x, MPFR_RNDN); if (dl != ULONG_MAX || !mpfr_erangeflag_p ()) { printf ("ERROR for get_ui + ERANGE + ULONG_MAX (2)\n"); exit (1); } - mpfr_set_si (x, -1, GMP_RNDN); + mpfr_set_si (x, -1, MPFR_RNDN); mpfr_clear_erangeflag (); - dl = mpfr_get_ui (x, GMP_RNDN); + dl = mpfr_get_ui (x, MPFR_RNDN); if (dl != 0 || !mpfr_erangeflag_p ()) { printf ("ERROR for get_ui + ERANGE + -1 \n"); exit (1); } - mpfr_set_si (x, LONG_MAX, GMP_RNDN); + mpfr_set_si (x, LONG_MAX, MPFR_RNDN); mpfr_clear_erangeflag (); - d = mpfr_get_si (x, GMP_RNDN); + d = mpfr_get_si (x, MPFR_RNDN); if (d != LONG_MAX || mpfr_erangeflag_p ()) { printf ("ERROR for get_si + ERANGE + LONG_MAX (1): %ld\n", d); exit (1); } - mpfr_add_ui (x, x, 1, GMP_RNDN); - d = mpfr_get_si (x, GMP_RNDN); + mpfr_add_ui (x, x, 1, MPFR_RNDN); + d = mpfr_get_si (x, MPFR_RNDN); if (d != LONG_MAX || !mpfr_erangeflag_p ()) { printf ("ERROR for get_si + ERANGE + LONG_MAX (2)\n"); exit (1); } - mpfr_set_si (x, LONG_MIN, GMP_RNDN); + mpfr_set_si (x, LONG_MIN, MPFR_RNDN); mpfr_clear_erangeflag (); - d = mpfr_get_si (x, GMP_RNDN); + d = mpfr_get_si (x, MPFR_RNDN); if (d != LONG_MIN || mpfr_erangeflag_p ()) { printf ("ERROR for get_si + ERANGE + LONG_MIN (1)\n"); exit (1); } - mpfr_sub_ui (x, x, 1, GMP_RNDN); - d = mpfr_get_si (x, GMP_RNDN); + mpfr_sub_ui (x, x, 1, MPFR_RNDN); + d = mpfr_get_si (x, MPFR_RNDN); if (d != LONG_MIN || !mpfr_erangeflag_p ()) { printf ("ERROR for get_si + ERANGE + LONG_MIN (2)\n"); @@ -377,34 +377,34 @@ main (int argc, char *argv[]) mpfr_set_emin (4); mpfr_clear_flags (); - mpfr_set_ui (x, 7, GMP_RNDU); + mpfr_set_ui (x, 7, MPFR_RNDU); flag = mpfr_underflow_p (); mpfr_set_emin (emin); if (mpfr_cmp_ui (x, 8) != 0) { - printf ("Error for mpfr_set_ui (x, 7, GMP_RNDU), prec = 2, emin = 4\n"); + printf ("Error for mpfr_set_ui (x, 7, MPFR_RNDU), prec = 2, emin = 4\n"); exit (1); } if (flag) { - printf ("mpfr_set_ui (x, 7, GMP_RNDU) should not underflow " + printf ("mpfr_set_ui (x, 7, MPFR_RNDU) should not underflow " "with prec = 2, emin = 4\n"); exit (1); } mpfr_set_emin (4); mpfr_clear_flags (); - mpfr_set_si (x, -7, GMP_RNDD); + mpfr_set_si (x, -7, MPFR_RNDD); flag = mpfr_underflow_p (); mpfr_set_emin (emin); if (mpfr_cmp_si (x, -8) != 0) { - printf ("Error for mpfr_set_si (x, -7, GMP_RNDD), prec = 2, emin = 4\n"); + printf ("Error for mpfr_set_si (x, -7, MPFR_RNDD), prec = 2, emin = 4\n"); exit (1); } if (flag) { - printf ("mpfr_set_si (x, -7, GMP_RNDD) should not underflow " + printf ("mpfr_set_si (x, -7, MPFR_RNDD) should not underflow " "with prec = 2, emin = 4\n"); exit (1); } |