From bab5aab404897a12fe1c87734ebf2aa270b9b73b Mon Sep 17 00:00:00 2001 From: vlefevre Date: Thu, 18 Aug 2005 16:35:19 +0000 Subject: Converted tabs to spaces with expand. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3725 280ebfd0-de03-0410-8827-d642c229c3f4 --- tests/RRTest.c | 10 +- tests/reuse.c | 48 +++++----- tests/tabs.c | 14 +-- tests/tadd.c | 178 ++++++++++++++++++------------------ tests/tadd_ui.c | 8 +- tests/tagm.c | 2 +- tests/tasin.c | 2 +- tests/tatan.c | 2 +- tests/tcan_round.c | 20 ++-- tests/tcheck.c | 18 ++-- tests/tcmp2.c | 2 +- tests/tcmpabs.c | 4 +- tests/tconst_euler.c | 50 +++++----- tests/tconst_log2.c | 2 +- tests/tcos.c | 2 +- tests/tdiv.c | 158 ++++++++++++++++---------------- tests/tdiv_ui.c | 22 ++--- tests/texceptions.c | 2 +- tests/texp.c | 20 ++-- tests/texp2.c | 2 +- tests/tfactorial.c | 98 ++++++++++---------- tests/tgeneric.c | 14 +-- tests/tgeneric_ui.c | 14 +-- tests/tget_d.c | 8 +- tests/tget_z.c | 52 +++++------ tests/tgmpop.c | 254 +++++++++++++++++++++++++-------------------------- tests/tlog.c | 2 +- tests/tmul.c | 78 ++++++++-------- tests/tmul_2exp.c | 8 +- tests/tmul_ui.c | 2 +- tests/tout_str.c | 2 +- tests/toutimpl.c | 16 ++-- tests/tpow_z.c | 36 ++++---- tests/trandom.c | 10 +- tests/trint.c | 4 +- tests/tset.c | 2 +- tests/tset_si.c | 20 ++-- tests/tset_sj.c | 40 ++++---- tests/tset_str.c | 18 ++-- tests/tsgn.c | 46 +++++----- tests/tsi_op.c | 2 +- tests/tsin_cos.c | 18 ++-- tests/tsqr.c | 4 +- tests/tsqrt.c | 84 ++++++++--------- tests/tstrtofr.c | 56 ++++++------ tests/tsub.c | 2 +- tests/tsub_ui.c | 2 +- tests/tsum.c | 4 +- tests/tui_div.c | 10 +- tests/tui_pow.c | 10 +- tests/tui_sub.c | 16 ++-- tests/tzeta.c | 20 ++-- 52 files changed, 759 insertions(+), 759 deletions(-) (limited to 'tests') diff --git a/tests/RRTest.c b/tests/RRTest.c index 1e177479a..9c09b28c9 100644 --- a/tests/RRTest.c +++ b/tests/RRTest.c @@ -103,20 +103,20 @@ main (void) RR::SetPrecision(pa); cos (d, b #ifdef TWO_ARGS - , c + , c #endif - ); + ); if (d != a) { cerr << "error at line " << line << endl; - cerr << "b="; Output(b, pb); + cerr << "b="; Output(b, pb); #ifdef TWO_ARGS cerr << " c="; Output(c, pc); #endif cerr << "expected "; Output(a, pa); cerr << "got "; Output(d, pa); - cerr << "difference is " << ulp (a, d, pa) << " ulps" << endl; - cerr << ++errors << " errors" << endl; + cerr << "difference is " << ulp (a, d, pa) << " ulps" << endl; + cerr << ++errors << " errors" << endl; } } } diff --git a/tests/reuse.c b/tests/reuse.c index 845f638da..50a4f7014 100644 --- a/tests/reuse.c +++ b/tests/reuse.c @@ -118,7 +118,7 @@ test3 (int (*testfunc)(mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t), if (mpfr_compare (res1, ref1)) { printf ("Error for %s(a, a, c) for ", foo); - DISP("a=",ref2); DISP2(", c=",ref3); + DISP("a=",ref2); DISP2(", c=",ref3); printf ("expected "); mpfr_print_binary (ref1); puts (""); printf ("got "); mpfr_print_binary (res1); puts (""); exit (1); @@ -130,8 +130,8 @@ test3 (int (*testfunc)(mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t), if (mpfr_compare (res1, ref1)) { printf ("Error for %s(a, b, a) for ", foo); - DISP("b=",ref2); DISP2(", a=", ref3); - DISP("expected ", ref1); DISP2(", got ",res1); + DISP("b=",ref2); DISP2(", a=", ref3); + DISP("expected ", ref1); DISP2(", got ",res1); exit (1); } @@ -144,8 +144,8 @@ test3 (int (*testfunc)(mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t), if (mpfr_compare (res1, ref1)) { printf ("Error for %s(a, a, a) for ", foo); - DISP2("a=",ref2); - DISP("expected ", ref1); DISP2(", got", res1); + DISP2("a=",ref2); + DISP("expected ", ref1); DISP2(", got", res1); exit (1); } } @@ -182,10 +182,10 @@ test4 (int (*testfunc)(mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr, set_special (op1, i); for (j=0; j= 0) ? MPFR_EXP(x) - MPFR_EXP(u) + : MPFR_EXP(u) - MPFR_EXP(x); + /* x + u is exactly representable with precision + abs(EXP(x)-EXP(u)) + max(prec(x), prec(u)) + 1 */ + pz = pz + MAX(MPFR_PREC(x), MPFR_PREC(u)) + 1; + mpfr_set_prec (z, pz); + rnd = (mp_rnd_t) RND_RAND(); + if (test_add (z, x, u, rnd)) + { + printf ("z <- x + u should be exact\n"); + printf ("x="); mpfr_print_binary (x); puts (""); + printf ("u="); mpfr_print_binary (u); puts (""); + printf ("z="); mpfr_print_binary (z); puts (""); + exit (1); + } + { rnd = (mp_rnd_t) RND_RAND(); - inexact = test_add (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", + inexact = test_add (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); - } - } - } - } + 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); @@ -829,62 +829,62 @@ tests (void) check64(); check("293607738.0", "1.9967571564050541e-5", GMP_RNDU, 64, 53, 53, - "2.9360773800002003e8"); + "2.9360773800002003e8"); check("880524.0", "-2.0769715792901673e-5", GMP_RNDN, 64, 53, 53, - "8.8052399997923023e5"); + "8.8052399997923023e5"); check("1196426492.0", "-1.4218093058435347e-3", GMP_RNDN, 64, 53, 53, - "1.1964264919985781e9"); + "1.1964264919985781e9"); check("982013018.0", "-8.941829477291838e-7", GMP_RNDN, 64, 53, 53, - "9.8201301799999905e8"); + "9.8201301799999905e8"); check("1092583421.0", "1.0880649218158844e9", GMP_RNDN, 64, 53, 53, - "2.1806483428158846e9"); + "2.1806483428158846e9"); check("1.8476886419022969e-6", "961494401.0", GMP_RNDN, 53, 64, 53, - "9.6149440100000179e8"); + "9.6149440100000179e8"); check("-2.3222118418069868e5", "1229318102.0", GMP_RNDN, 53, 64, 53, - "1.2290858808158193e9"); + "1.2290858808158193e9"); check("-3.0399171300395734e-6", "874924868.0", GMP_RNDN, 53, 64, 53, - "8.749248679999969e8"); + "8.749248679999969e8"); check("9.064246624706179e1", "663787413.0", GMP_RNDN, 53, 64, 53, - "6.6378750364246619e8"); + "6.6378750364246619e8"); check("-1.0954322421551264e2", "281806592.0", GMP_RNDD, 53, 64, 53, - "2.8180648245677572e8"); + "2.8180648245677572e8"); check("5.9836930386056659e-8", "1016217213.0", GMP_RNDN, 53, 64, 53, - "1.0162172130000001e9"); + "1.0162172130000001e9"); check("-1.2772161928500301e-7", "1237734238.0", GMP_RNDN, 53, 64, 53, - "1.2377342379999998e9"); + "1.2377342379999998e9"); check("-4.567291988483277e8", "1262857194.0", GMP_RNDN, 53, 64, 53, - "8.0612799515167236e8"); + "8.0612799515167236e8"); check("4.7719471752925262e7", "196089880.0", GMP_RNDN, 53, 53, 53, - "2.4380935175292528e8"); + "2.4380935175292528e8"); check("4.7719471752925262e7", "196089880.0", GMP_RNDN, 53, 64, 53, - "2.4380935175292528e8"); + "2.4380935175292528e8"); check("-1.716113812768534e-140", "1271212614.0", GMP_RNDZ, 53, 64, 53, - "1.2712126139999998e9"); + "1.2712126139999998e9"); check("-1.2927455200185474e-50", "1675676122.0", GMP_RNDD, 53, 64, 53, - "1.6756761219999998e9"); + "1.6756761219999998e9"); check53("1.22191250737771397120e+20", "948002822.0", GMP_RNDN, - "122191250738719408128.0"); + "122191250738719408128.0"); check53("9966027674114492.0", "1780341389094537.0", GMP_RNDN, - "11746369063209028.0"); + "11746369063209028.0"); check53("2.99280481918991653800e+272", "5.34637717585790933424e+271", - GMP_RNDN, "3.5274425367757071711e272"); + GMP_RNDN, "3.5274425367757071711e272"); check_same(); check53("6.14384195492641560499e-02", "-6.14384195401037683237e-02", - GMP_RNDU, "9.1603877261370314499e-12"); + GMP_RNDU, "9.1603877261370314499e-12"); check53("1.16809465359248765399e+196", "7.92883212101990665259e+196", - GMP_RNDU, "9.0969267746123943065e196"); + GMP_RNDU, "9.0969267746123943065e196"); check53("3.14553393112021279444e-67", "3.14553401015952024126e-67", GMP_RNDU, - "6.2910679412797336946e-67"); + "6.2910679412797336946e-67"); check53("5.43885304644369509058e+185","-1.87427265794105342763e-57",GMP_RNDN, - "5.4388530464436950905e185"); + "5.4388530464436950905e185"); check53("5.43885304644369509058e+185","-1.87427265794105342763e-57",GMP_RNDZ, - "5.4388530464436944867e185"); + "5.4388530464436944867e185"); check53("5.43885304644369509058e+185","-1.87427265794105342763e-57",GMP_RNDU, - "5.4388530464436950905e185"); + "5.4388530464436950905e185"); check53("5.43885304644369509058e+185","-1.87427265794105342763e-57",GMP_RNDD, - "5.4388530464436944867e185"); + "5.4388530464436944867e185"); check2b("1.001010101110011000000010100101110010111001010000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e358",187, "-1.11100111001101100010001111111110101101110001000000000000000000000000000000000000000000e160",87, @@ -1009,50 +1009,50 @@ tests (void) /* Checking double precision (53 bits) */ check53("-8.22183238641455905806e-19", "7.42227178769761587878e-19",GMP_RNDD, - "-7.9956059871694317927e-20"); + "-7.9956059871694317927e-20"); check53("5.82106394662028628236e+234","-5.21514064202368477230e+89",GMP_RNDD, - "5.8210639466202855763e234"); + "5.8210639466202855763e234"); check53("5.72931679569871602371e+122","-5.72886070363264321230e+122", - GMP_RNDN, "4.5609206607281141508e118"); + GMP_RNDN, "4.5609206607281141508e118"); check53("-5.09937369394650450820e+238", "2.70203299854862982387e+250", - GMP_RNDD, "2.7020329985435301323e250"); + GMP_RNDD, "2.7020329985435301323e250"); check53("-2.96695924472363684394e+27", "1.22842938251111500000e+16",GMP_RNDD, - "-2.96695924471135255027e27"); + "-2.96695924471135255027e27"); check53("1.74693641655743793422e-227", "-7.71776956366861843469e-229", - GMP_RNDN, "1.669758720920751867e-227"); + GMP_RNDN, "1.669758720920751867e-227"); /* x = -7883040437021647.0; for (i=0; i<468; i++) x = x / 2.0;*/ check53("-1.03432206392780011159e-125", "1.30127034799251347548e-133", - GMP_RNDN, - "-1.0343220509150965661100887242027378881805094180354e-125"); + GMP_RNDN, + "-1.0343220509150965661100887242027378881805094180354e-125"); check53("1.05824655795525779205e+71", "-1.06022698059744327881e+71",GMP_RNDZ, - "-1.9804226421854867632e68"); + "-1.9804226421854867632e68"); check53("-5.84204911040921732219e+240", "7.26658169050749590763e+240", - GMP_RNDD, "1.4245325800982785854e240"); + GMP_RNDD, "1.4245325800982785854e240"); check53("1.00944884131046636376e+221","2.33809162651471520268e+215",GMP_RNDN, - "1.0094511794020929787e221"); + "1.0094511794020929787e221"); /*x = 7045852550057985.0; for (i=0; i<986; i++) x = x / 2.0;*/ check53("4.29232078932667367325e-278", - "1.0773525047389793833221116707010783793203080117586e-281" - , GMP_RNDU, "4.2933981418314132787e-278"); + "1.0773525047389793833221116707010783793203080117586e-281" + , GMP_RNDU, "4.2933981418314132787e-278"); check53("5.27584773801377058681e-80", "8.91207657803547196421e-91", GMP_RNDN, - "5.2758477381028917269e-80"); + "5.2758477381028917269e-80"); check53("2.99280481918991653800e+272", "5.34637717585790933424e+271", - GMP_RNDN, "3.5274425367757071711e272"); + GMP_RNDN, "3.5274425367757071711e272"); check53("4.67302514390488041733e-184", "2.18321376145645689945e-190", - GMP_RNDN, "4.6730273271186420541e-184"); + GMP_RNDN, "4.6730273271186420541e-184"); check53("5.57294120336300389254e+71", "2.60596167942024924040e+65", GMP_RNDZ, - "5.5729438093246831053e71"); + "5.5729438093246831053e71"); check53("6.6052588496951015469e24", "4938448004894539.0", GMP_RNDU, - "6.6052588546335505068e24"); + "6.6052588546335505068e24"); check53("1.23056185051606761523e-190", "1.64589756643433857138e-181", - GMP_RNDU, "1.6458975676649006598e-181"); + GMP_RNDU, "1.6458975676649006598e-181"); check53("2.93231171510175981584e-280", "3.26266919161341483877e-273", - GMP_RNDU, "3.2626694848445867288e-273"); + GMP_RNDU, "3.2626694848445867288e-273"); check53("5.76707395945001907217e-58", "4.74752971449827687074e-51", GMP_RNDD, - "4.747530291205672325e-51"); + "4.747530291205672325e-51"); check53("277363943109.0", "11.0", GMP_RNDN, "277363943120.0"); check53("1.44791789689198883921e-140", "-1.90982880222349071284e-121", - GMP_RNDN, "-1.90982880222349071e-121"); + GMP_RNDN, "-1.90982880222349071e-121"); /* tests for particular cases (Vincent Lefevre, 22 Aug 2001) */ diff --git a/tests/tadd_ui.c b/tests/tadd_ui.c index dfd8ab69f..11933fd72 100644 --- a/tests/tadd_ui.c +++ b/tests/tadd_ui.c @@ -102,13 +102,13 @@ main (int argc, char *argv[]) special (); check3 ("-1.716113812768534e-140", 1271212614, GMP_RNDZ, - "1.27121261399999976e9"); + "1.27121261399999976e9"); check3 ("1.22191250737771397120e+20", 948002822, GMP_RNDN, - "122191250738719408128.0"); + "122191250738719408128.0"); check3 ("-6.72658901114033715233e-165", 2000878121, GMP_RNDZ, - "2.0008781209999997615e9"); + "2.0008781209999997615e9"); check3 ("-2.0769715792901673e-5", 880524, GMP_RNDN, - "8.8052399997923023e5"); + "8.8052399997923023e5"); test_generic_ui (2, 1000, 100); tests_end_mpfr (); diff --git a/tests/tagm.c b/tests/tagm.c index 6a7d92e24..f58c9b8e8 100644 --- a/tests/tagm.c +++ b/tests/tagm.c @@ -209,7 +209,7 @@ main (int argc, char* argv[]) check4 ("8.0", "1.0", GMP_RNDU, "3.615756177597362786"); check4 ("1.0", "44.0", GMP_RNDU, "1.33658354512981247808e1"); check4 ("1.0", "3.7252902984619140625e-9", GMP_RNDU, - "7.55393356971199025907e-02"); + "7.55393356971199025907e-02"); test_generic (2, 300, 17); tests_end_mpfr (); diff --git a/tests/tasin.c b/tests/tasin.c index 6be9044ed..77a6511cc 100644 --- a/tests/tasin.c +++ b/tests/tasin.c @@ -178,7 +178,7 @@ special_overflow (void) mpfr_set_str_binary (x, "0.101100100000000000110100E0"); mpfr_asin (y, x, GMP_RNDN); if (mpfr_cmp_str (y, "0.110001001101001111110000010110001000111011001000E0", - 2, GMP_RNDN)) + 2, GMP_RNDN)) { printf("Special Overflow error.\n"); mpfr_dump (y); diff --git a/tests/tatan.c b/tests/tatan.c index 6d8b2c44b..bb4c4afe9 100644 --- a/tests/tatan.c +++ b/tests/tatan.c @@ -165,7 +165,7 @@ special (void) mpfr_set_prec (x, 51); mpfr_set_prec (y, 51); mpfr_set_str_binary (x, - "0.101100100000101111111010001111111000001000000000000E-11"); + "0.101100100000101111111010001111111000001000000000000E-11"); i = mpfr_atan (y, x, GMP_RNDN); if (mpfr_cmp_str (y, "1.01100100000101111111001110011001010110100100000000e-12", 2, GMP_RNDN) diff --git a/tests/tcan_round.c b/tests/tcan_round.c index c272a57bb..06532f53d 100644 --- a/tests/tcan_round.c +++ b/tests/tcan_round.c @@ -42,17 +42,17 @@ check_round_p (void) err = p + randlimb () % BITS_PER_MP_LIMB; r1 = mpfr_round_p (buf, n, err, p); r2 = mpfr_can_round_raw (buf, n, MPFR_SIGN_POS, err, - GMP_RNDN, GMP_RNDZ, p); + GMP_RNDN, GMP_RNDZ, p); if (r1 != r2) - { - printf ("mpfr_round_p(%d) != mpfr_can_round(%d)!\n" - "bn=%ld err0=%ld prec=%ld\nbp=", - r1, r2, n, err, p); - while (n--) - printf ("%08lX ", buf[n]); - putchar ('\n'); - exit (1); - } + { + printf ("mpfr_round_p(%d) != mpfr_can_round(%d)!\n" + "bn=%ld err0=%ld prec=%ld\nbp=", + r1, r2, n, err, p); + while (n--) + printf ("%08lX ", buf[n]); + putchar ('\n'); + exit (1); + } } } diff --git a/tests/tcheck.c b/tests/tcheck.c index 18b3282eb..547943692 100644 --- a/tests/tcheck.c +++ b/tests/tcheck.c @@ -54,11 +54,11 @@ main (void) mpfr_clear_overflow(); max = 1000; /* Allows max 2^1000 bits for the exponent */ while ((!mpfr_overflow_p()) && (max>0)) - { - mpfr_mul(a, a, a, GMP_RNDN); - if (!mpfr_check(a)) ERROR("for mul"); - max--; - } + { + mpfr_mul(a, a, a, GMP_RNDN); + if (!mpfr_check(a)) ERROR("for mul"); + max--; + } if (max==0) ERROR("can't reach overflow"); mpfr_set_ui(a, 2137, GMP_RNDN); /* Corrupt a and check for it */ @@ -96,10 +96,10 @@ main (void) /* Check normal form */ tmp = MPFR_MANT(a)[0]; if ((pr % BITS_PER_MP_LIMB) != 0) - { - MPFR_MANT(a)[0] = ~0; - if (mpfr_check(a)) ERROR("last bits non 0"); - } + { + MPFR_MANT(a)[0] = ~0; + if (mpfr_check(a)) ERROR("last bits non 0"); + } MPFR_MANT(a)[0] = tmp; MPFR_MANT(a)[MPFR_LIMB_SIZE(a)-1] &= MPFR_LIMB_MASK (BITS_PER_MP_LIMB-1); if (mpfr_check(a)) ERROR("last bits non 0"); diff --git a/tests/tcmp2.c b/tests/tcmp2.c index 6e680e3c6..346886e0c 100644 --- a/tests/tcmp2.c +++ b/tests/tcmp2.c @@ -96,7 +96,7 @@ worst_cases (void) b = randlimb () % 2; set_bit (x, i + j + 2, b); set_bit (y, i + j + 2, b); - for (k=0; k<64; k++) + for (k=0; k<64; k++) { if (k) set_bit (x, i + j + k + 1, 0); diff --git a/tests/tcmpabs.c b/tests/tcmpabs.c index 7f8aa2540..c3e1e6cc7 100644 --- a/tests/tcmpabs.c +++ b/tests/tcmpabs.c @@ -107,8 +107,8 @@ main (void) mpfr_set_prec (yy, 128); mpfr_set_str_binary (xx, "0.1E10"); mpfr_set_str_binary (yy, - "0.100000000000000000000000000000000000000000000000" - "00000000000000000000000000000000000000000000001E10"); + "0.100000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000001E10"); if (mpfr_cmpabs (xx, yy) >= 0) ERROR ("Error in mpfr_cmpabs(10.235, 2346.09234)\n"); mpfr_swap (xx, yy); diff --git a/tests/tconst_euler.c b/tests/tconst_euler.c index 27aa3791a..1f8e63b25 100644 --- a/tests/tconst_euler.c +++ b/tests/tconst_euler.c @@ -66,31 +66,31 @@ main (int argc, char *argv[]) yprec = prec + 10; for (rnd = 0; rnd < GMP_RND_MAX; rnd++) - { - mpfr_set_prec (y, yprec); - mpfr_const_euler (y, (mp_rnd_t) rnd); - err = (rnd == GMP_RNDN) ? yprec + 1 : yprec; - if (mpfr_can_round (y, err, (mp_rnd_t) rnd, (mp_rnd_t) rnd, prec)) - { - mpfr_set (t, y, (mp_rnd_t) rnd); - mpfr_const_euler (z, (mp_rnd_t) rnd); - if (mpfr_cmp (t, z)) - { - printf ("results differ for prec=%u rnd_mode=%s\n", prec, - mpfr_print_rnd_mode ((mp_rnd_t) rnd)); - printf (" got "); - mpfr_out_str (stdout, 2, prec, z, GMP_RNDN); - puts (""); - printf (" expected "); - mpfr_out_str (stdout, 2, prec, t, GMP_RNDN); - puts (""); - printf (" approximation was "); - mpfr_print_binary (y); - puts (""); - exit (1); - } - } - } + { + mpfr_set_prec (y, yprec); + mpfr_const_euler (y, (mp_rnd_t) rnd); + err = (rnd == GMP_RNDN) ? yprec + 1 : yprec; + if (mpfr_can_round (y, err, (mp_rnd_t) rnd, (mp_rnd_t) rnd, prec)) + { + mpfr_set (t, y, (mp_rnd_t) rnd); + mpfr_const_euler (z, (mp_rnd_t) rnd); + if (mpfr_cmp (t, z)) + { + printf ("results differ for prec=%u rnd_mode=%s\n", prec, + mpfr_print_rnd_mode ((mp_rnd_t) rnd)); + printf (" got "); + mpfr_out_str (stdout, 2, prec, z, GMP_RNDN); + puts (""); + printf (" expected "); + mpfr_out_str (stdout, 2, prec, t, GMP_RNDN); + puts (""); + printf (" approximation was "); + mpfr_print_binary (y); + puts (""); + exit (1); + } + } + } } mpfr_clear (y); diff --git a/tests/tconst_log2.c b/tests/tconst_log2.c index c40e888be..33b0d43e4 100644 --- a/tests/tconst_log2.c +++ b/tests/tconst_log2.c @@ -48,7 +48,7 @@ check (mp_prec_t p0, mp_prec_t p1) mpfr_const_log2 (x, rnd); mpfr_set (y, z, rnd); if ((dif = mpfr_cmp (x, y)) - && mpfr_can_round (z, mpfr_get_prec(z), GMP_RNDN, + && mpfr_can_round (z, mpfr_get_prec(z), GMP_RNDN, rnd, p0)) { printf ("mpfr_const_log2 fails for prec=%u, rnd=%s Diff=%d\n", diff --git a/tests/tcos.c b/tests/tcos.c index a76b3b986..fa6c5671e 100644 --- a/tests/tcos.c +++ b/tests/tcos.c @@ -58,7 +58,7 @@ check53 (const char *xs, const char *cos_xs, mp_rnd_t rnd_mode) if (mpfr_cmp_str1 (c, cos_xs)) { printf ("mpfr_cos failed for x=%s, rnd=%s\n", - xs, mpfr_print_rnd_mode (rnd_mode)); + xs, mpfr_print_rnd_mode (rnd_mode)); printf ("mpfr_cos gives cos(x)="); mpfr_out_str(stdout, 10, 0, c, GMP_RNDN); printf(", expected %s\n", cos_xs); diff --git a/tests/tdiv.c b/tests/tdiv.c index 510991441..dafaa48cb 100644 --- a/tests/tdiv.c +++ b/tests/tdiv.c @@ -66,7 +66,7 @@ inex_cmp (int a, int b) static void check4 (const char *Ns, const char *Ds, mp_rnd_t rnd_mode, int p, - const char *Qs) + const char *Qs) { mpfr_t q, n, d; @@ -166,21 +166,21 @@ check_double(void) { check53("0.0", "1.0", GMP_RNDZ, "0.0"); check53("-7.4988969224688591e63", "4.8816866450288732e306", GMP_RNDD, - "-1.5361282826510687291e-243"); + "-1.5361282826510687291e-243"); check53("-1.33225773037748601769e+199", "3.63449540676937123913e+79", - GMP_RNDZ, "-3.6655920045905428978e119"); + GMP_RNDZ, "-3.6655920045905428978e119"); check53("9.89438396044940256501e-134", "5.93472984109987421717e-67",GMP_RNDU, - "1.6672003992376663654e-67"); + "1.6672003992376663654e-67"); check53("9.89438396044940256501e-134", "-5.93472984109987421717e-67", - GMP_RNDU, "-1.6672003992376663654e-67"); + GMP_RNDU, "-1.6672003992376663654e-67"); check53("-4.53063926135729747564e-308", "7.02293374921793516813e-84", - GMP_RNDD, "-6.4512060388748850857e-225"); + GMP_RNDD, "-6.4512060388748850857e-225"); check53("6.25089225176473806123e-01","-2.35527154824420243364e-230", - GMP_RNDD, "-2.6540006635008291192e229"); + GMP_RNDD, "-2.6540006635008291192e229"); check53("6.52308934689126e15", "-1.62063546601505417497e273", GMP_RNDN, - "-4.0250194961676020848e-258"); + "-4.0250194961676020848e-258"); check53("1.04636807108079349236e-189", "3.72295730823253012954e-292", - GMP_RNDZ, "2.810583051186143125e102"); + GMP_RNDZ, "2.810583051186143125e102"); /* problems found by Kevin under HP-PA */ check53 ("2.861044553323177e-136", "-1.1120354257068143e+45", GMP_RNDZ, "-2.5727998292003016e-181"); @@ -309,41 +309,41 @@ check_hard (void) else /* use q2=1 */ mpfr_set_ui (q2, 1, GMP_RNDN); for (precv = precq; precv <= 10 * precq; precv += precq) - { - mpfr_set_prec (v, precv); - do - { - mpfr_random (v); - } - while (mpfr_cmp_ui (v, 0) == 0); - for (precu = precq; precu <= 10 * precq; precu += precq) - { - mpfr_set_prec (u, precu); - mpfr_mul (u, v, q2, GMP_RNDN); - mpfr_nextbelow (u); - for (i = 0; i <= 2; i++) - { - for (rnd = 0; rnd < GMP_RND_MAX; rnd++) - { - inex = test_div (q, u, v, (mp_rnd_t) rnd); - inex2 = get_inexact (q, u, v); - if (inex_cmp (inex, inex2)) - { - printf ("Wrong inexact flag for rnd=%s: expected %d, got %d\n", - mpfr_print_rnd_mode ((mp_rnd_t) rnd), inex2, inex); - printf ("u= "); mpfr_dump (u); - printf ("v= "); mpfr_dump (v); - printf ("q= "); mpfr_dump (q); - mpfr_set_prec (q2, precq + precv); - mpfr_mul (q2, q, v, GMP_RNDN); - printf ("q*v="); mpfr_dump (q2); - exit (1); - } - } - mpfr_nextabove (u); - } - } - } + { + mpfr_set_prec (v, precv); + do + { + mpfr_random (v); + } + while (mpfr_cmp_ui (v, 0) == 0); + for (precu = precq; precu <= 10 * precq; precu += precq) + { + mpfr_set_prec (u, precu); + mpfr_mul (u, v, q2, GMP_RNDN); + mpfr_nextbelow (u); + for (i = 0; i <= 2; i++) + { + for (rnd = 0; rnd < GMP_RND_MAX; rnd++) + { + inex = test_div (q, u, v, (mp_rnd_t) rnd); + inex2 = get_inexact (q, u, v); + if (inex_cmp (inex, inex2)) + { + printf ("Wrong inexact flag for rnd=%s: expected %d, got %d\n", + mpfr_print_rnd_mode ((mp_rnd_t) rnd), inex2, inex); + printf ("u= "); mpfr_dump (u); + printf ("v= "); mpfr_dump (v); + printf ("q= "); mpfr_dump (q); + mpfr_set_prec (q2, precq + precv); + mpfr_mul (q2, q, v, GMP_RNDN); + printf ("q*v="); mpfr_dump (q2); + exit (1); + } + } + mpfr_nextabove (u); + } + } + } } } @@ -405,7 +405,7 @@ check_lowr (void) mpfr_mul (x, z, tmp, GMP_RNDN); /* exact */ c = test_div (z2, x, tmp, GMP_RNDN); /* since z2 has one less bit that z, either the division is exact - if z is representable on 9 bits, or we have an even round case */ + if z is representable on 9 bits, or we have an even round case */ c2 = get_inexact (z2, x, tmp); if ((mpfr_cmp (z2, z) == 0 && c) || inex_cmp (c, c2)) @@ -417,8 +417,8 @@ check_lowr (void) exit (1); } else if (c == 2) - { - mpfr_nexttoinf (z); + { + mpfr_nexttoinf (z); if (mpfr_cmp(z2, z)) { printf ("Error in mpfr_div [even rnd?] rnd=GMP_RNDN\n"); @@ -487,8 +487,8 @@ check_lowr (void) if (c != 1 || mpfr_cmp (z2, z)) { printf ("Error in mpfr_div rnd=GMP_RNDU\n"); - printf ("u="); mpfr_dump (x); - printf ("v="); mpfr_dump (y); + printf ("u="); mpfr_dump (x); + printf ("v="); mpfr_dump (y); printf ("got "); mpfr_print_binary (z2); puts (""); printf ("instead of "); mpfr_print_binary (z); puts (""); printf ("inex flag = %d\n", c); @@ -581,38 +581,38 @@ check_inexact (void) mpfr_set_prec (x, px); mpfr_random (x); for (pu=2; pu<=MAX_PREC; pu++) - { - mpfr_set_prec (u, pu); - do { mpfr_random (u); } while (mpfr_cmp_ui (u, 0) == 0); - { + { + mpfr_set_prec (u, pu); + do { mpfr_random (u); } while (mpfr_cmp_ui (u, 0) == 0); + { py = MPFR_PREC_MIN + (randlimb () % (MAX_PREC - MPFR_PREC_MIN)); - mpfr_set_prec (y, py); - mpfr_set_prec (z, py + pu); - { + mpfr_set_prec (y, py); + mpfr_set_prec (z, py + pu); + { rnd = (mp_rnd_t) RND_RAND (); - inexact = test_div (y, x, u, rnd); - if (mpfr_mul (z, y, u, rnd)) - { - printf ("z <- y * u should be exact\n"); - exit (1); - } - cmp = mpfr_cmp (z, x); - if (((inexact == 0) && (cmp != 0)) || - ((inexact > 0) && (cmp <= 0)) || - ((inexact < 0) && (cmp >= 0))) - { - printf ("Wrong inexact flag for rnd=%s\n", + inexact = test_div (y, x, u, rnd); + if (mpfr_mul (z, y, u, rnd)) + { + printf ("z <- y * u should be exact\n"); + exit (1); + } + cmp = mpfr_cmp (z, x); + 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 ("y*u="); mpfr_print_binary (z); puts (""); - exit (1); - } - } - } - } + 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 ("y*u="); mpfr_print_binary (z); puts (""); + exit (1); + } + } + } + } } mpfr_clear (x); @@ -755,7 +755,7 @@ main (int argc, char *argv[]) check4("1.0","2.10263340267725788209e+187", GMP_RNDU, 65, "0.11010011111001101011111001100111110100000001101001111100111000000E-622"); check4("2.44394909079968374564e-150", "2.10263340267725788209e+187",GMP_RNDU, - 65, + 65, "0.11010011111001101011111001100111110100000001101001111100111000000E-1119"); test_generic (2, 800, 50); diff --git a/tests/tdiv_ui.c b/tests/tdiv_ui.c index c54d72bb3..f105c62e6 100644 --- a/tests/tdiv_ui.c +++ b/tests/tdiv_ui.c @@ -116,17 +116,17 @@ special (void) mpfr_set_prec (x, xprec); mpfr_set_str_binary (x, "0.1100100100001111110011111000000011011100001100110111E2"); for (yprec = 53; yprec <= 128; yprec++) - { - mpfr_set_prec (y, yprec); - mpfr_div_ui (y, x, 1, GMP_RNDN); - if (mpfr_cmp(x,y)) - { - printf ("division by 1.0 fails for xprec=%u, yprec=%u\n", xprec, yprec); - printf ("expected "); mpfr_print_binary (x); puts (""); - printf ("got "); mpfr_print_binary (y); puts (""); - exit (1); - } - } + { + mpfr_set_prec (y, yprec); + mpfr_div_ui (y, x, 1, GMP_RNDN); + if (mpfr_cmp(x,y)) + { + printf ("division by 1.0 fails for xprec=%u, yprec=%u\n", xprec, yprec); + printf ("expected "); mpfr_print_binary (x); puts (""); + printf ("got "); mpfr_print_binary (y); puts (""); + exit (1); + } + } } mpfr_clear (x); diff --git a/tests/texceptions.c b/tests/texceptions.c index d26a16c02..f100f47dd 100644 --- a/tests/texceptions.c +++ b/tests/texceptions.c @@ -51,7 +51,7 @@ check_default_rnd (void) mpfr_set_default_rounding_mode ((mp_rnd_t) r); t = (mpfr_get_default_rounding_mode) (); if ((mp_rnd_t) r != t) - ERROR("ERROR in setting / getting default rounding mode (1)"); + ERROR("ERROR in setting / getting default rounding mode (1)"); } mpfr_set_default_rounding_mode ((mp_rnd_t) 4); if (mpfr_get_default_rounding_mode() != GMP_RNDD) diff --git a/tests/texp.c b/tests/texp.c index a3e593dab..5c567235d 100644 --- a/tests/texp.c +++ b/tests/texp.c @@ -61,7 +61,7 @@ check3 (const char *op, mp_rnd_t rnd, const char *res) if (mpfr_cmp_str1 (y, res) ) { printf ("mpfr_exp failed for x=%s, rnd=%s\n", - op, mpfr_print_rnd_mode (rnd)); + op, mpfr_print_rnd_mode (rnd)); printf ("expected result is %s, got ", res); mpfr_out_str (stdout, 10, 0, y, GMP_RNDN); putchar('\n'); @@ -246,11 +246,11 @@ check_special () mpfr_set_emin (MPFR_EMIN_DEFAULT); mpfr_set_str (x, "0.1011000101110010000101111111010100001100000001110001100111001101E30", - 2, GMP_RNDN); + 2, GMP_RNDN); mpfr_exp (x, x, GMP_RNDD); if (mpfr_cmp_str (x, ".1111111111111111111111111111111111111111111111111111111111111111E1073741823", - 2, GMP_RNDN) != 0) + 2, GMP_RNDN) != 0) { printf ("Wrong overflow detection in mpfr_exp\n"); mpfr_dump (x); @@ -391,12 +391,12 @@ check_special () mpfr_set_prec (x, 107); mpfr_set_prec (y, 107); mpfr_set_str_binary (x, "0.11110000000000000000000000000000000000000000000" - "0000000000000000000000000000000000000000000000000000" - "00000000E4"); + "0000000000000000000000000000000000000000000000000000" + "00000000E4"); test_exp (y, x, GMP_RNDN); if (mpfr_cmp_str (y, "0.11000111100001100110010101111101011010010101010000" - "1101110111100010111001011111111000110111001011001101010" - "01E22", 2, GMP_RNDN)) + "1101110111100010111001011111111000110111001011001101010" + "01E22", 2, GMP_RNDN)) { printf ("Special overflow error (1)\n"); mpfr_dump (y); @@ -415,10 +415,10 @@ check_special () mpfr_set_prec (x, 163); mpfr_set_str (x, "-4.28ac8fceeadcda06bb56359017b1c81b85b392e7", 16, - GMP_RNDN); + GMP_RNDN); mpfr_exp (x, x, GMP_RNDN); if (mpfr_cmp_str (x, "3.fffffffffffffffffffffffffffffffffffffffe8@-2", - 16, GMP_RNDN)) + 16, GMP_RNDN)) { printf ("Error for x= -4.28ac8fceeadcda06bb56359017b1c81b85b392e7"); printf ("expected 3.fffffffffffffffffffffffffffffffffffffffe8@-2"); @@ -442,7 +442,7 @@ check_inexact (void) mpfr_init2 (y, 53); mpfr_set_str_binary (x, - "1.0000000000001001000110100100101000001101101011100101e2"); + "1.0000000000001001000110100100101000001101101011100101e2"); inexact = test_exp (y, x, GMP_RNDN); if (inexact <= 0) { diff --git a/tests/texp2.c b/tests/texp2.c index 85131ccaa..65bc8d198 100644 --- a/tests/texp2.c +++ b/tests/texp2.c @@ -90,7 +90,7 @@ main (int argc, char *argv[]) mpfr_set_prec (x, 53); mpfr_set_prec (y, 53); mpfr_set_str (x, /*-1683977482443233.0 / 2199023255552.0*/ - "-7.6578429909351734750089235603809357e2", 10,GMP_RNDN); + "-7.6578429909351734750089235603809357e2", 10,GMP_RNDN); mpfr_exp2 (y, x, GMP_RNDN); if (mpfr_cmp_str1 (y, "2.991959870867646566478e-231")) { diff --git a/tests/tfactorial.c b/tests/tfactorial.c index 7379827b7..4f9cff08d 100644 --- a/tests/tfactorial.c +++ b/tests/tfactorial.c @@ -152,55 +152,55 @@ main (int argc, char *argv[]) mpfr_set_prec (y, yprec); for (n = 0; n < 50; n++) - for (rnd = 0; rnd < GMP_RND_MAX; rnd++) - { - inexact = mpfr_fac_ui (y, n, (mp_rnd_t) rnd); - err = (rnd == GMP_RNDN) ? yprec + 1 : yprec; - if (mpfr_can_round (y, err, (mp_rnd_t) rnd, (mp_rnd_t) rnd, prec)) - { - mpfr_set (t, y, (mp_rnd_t) rnd); - inexact = mpfr_fac_ui (z, n, (mp_rnd_t) rnd); - /* fact(n) ends with floor(n/2)+floor(n/4)+... zeros */ - for (k=n/2, zeros=0; k; k >>= 1) - zeros += k; - if (MPFR_EXP(y) <= (mp_exp_t) (prec + zeros)) - /* result should be exact */ - { - if (inexact) - { - printf ("Wrong inexact flag: expected exact\n"); - exit (1); - } - } - else /* result is inexact */ - { - if (!inexact) - { - printf ("Wrong inexact flag: expected inexact\n"); - printf ("n=%u prec=%u\n", n, prec); - mpfr_print_binary(z); puts (""); - exit (1); - } - } - if (mpfr_cmp (t, z)) - { - printf ("results differ for x="); - mpfr_out_str (stdout, 2, prec, x, GMP_RNDN); - printf (" prec=%u rnd_mode=%s\n", prec, - mpfr_print_rnd_mode ((mp_rnd_t) rnd)); - printf (" got "); - mpfr_out_str (stdout, 2, prec, z, GMP_RNDN); - puts (""); - printf (" expected "); - mpfr_out_str (stdout, 2, prec, t, GMP_RNDN); - puts (""); - printf (" approximation was "); - mpfr_print_binary (y); - puts (""); - exit (1); - } - } - } + for (rnd = 0; rnd < GMP_RND_MAX; rnd++) + { + inexact = mpfr_fac_ui (y, n, (mp_rnd_t) rnd); + err = (rnd == GMP_RNDN) ? yprec + 1 : yprec; + if (mpfr_can_round (y, err, (mp_rnd_t) rnd, (mp_rnd_t) rnd, prec)) + { + mpfr_set (t, y, (mp_rnd_t) rnd); + inexact = mpfr_fac_ui (z, n, (mp_rnd_t) rnd); + /* fact(n) ends with floor(n/2)+floor(n/4)+... zeros */ + for (k=n/2, zeros=0; k; k >>= 1) + zeros += k; + if (MPFR_EXP(y) <= (mp_exp_t) (prec + zeros)) + /* result should be exact */ + { + if (inexact) + { + printf ("Wrong inexact flag: expected exact\n"); + exit (1); + } + } + else /* result is inexact */ + { + if (!inexact) + { + printf ("Wrong inexact flag: expected inexact\n"); + printf ("n=%u prec=%u\n", n, prec); + mpfr_print_binary(z); puts (""); + exit (1); + } + } + if (mpfr_cmp (t, z)) + { + printf ("results differ for x="); + mpfr_out_str (stdout, 2, prec, x, GMP_RNDN); + printf (" prec=%u rnd_mode=%s\n", prec, + mpfr_print_rnd_mode ((mp_rnd_t) rnd)); + printf (" got "); + mpfr_out_str (stdout, 2, prec, z, GMP_RNDN); + puts (""); + printf (" expected "); + mpfr_out_str (stdout, 2, prec, t, GMP_RNDN); + puts (""); + printf (" approximation was "); + mpfr_print_binary (y); + puts (""); + exit (1); + } + } + } } mpfr_clear (x); diff --git a/tests/tgeneric.c b/tests/tgeneric.c index a6747cc64..8d4015b5e 100644 --- a/tests/tgeneric.c +++ b/tests/tgeneric.c @@ -54,18 +54,18 @@ test_generic (mp_prec_t p0, mp_prec_t p1, unsigned int N) #if defined(RAND_FUNCTION) RAND_FUNCTION (x); #ifdef TWO_ARGS - RAND_FUNCTION (u); + RAND_FUNCTION (u); #endif #else mpfr_random (x); #ifdef TWO_ARGS - mpfr_random (u); + mpfr_random (u); #endif #endif rnd = (mp_rnd_t) RND_RAND (); mpfr_set_prec (y, yprec); #if defined(TWO_ARGS) - compare = TEST_FUNCTION (y, x, u, rnd); + compare = TEST_FUNCTION (y, x, u, rnd); #else compare = TEST_FUNCTION (y, x, rnd); #endif @@ -73,7 +73,7 @@ test_generic (mp_prec_t p0, mp_prec_t p1, unsigned int N) { mpfr_set (t, y, rnd); #if defined(TWO_ARGS) - inexact = TEST_FUNCTION (z, x, u, rnd); + inexact = TEST_FUNCTION (z, x, u, rnd); #else inexact = TEST_FUNCTION (z, x, rnd); #endif @@ -82,8 +82,8 @@ test_generic (mp_prec_t p0, mp_prec_t p1, unsigned int N) printf ("results differ for x="); mpfr_out_str (stdout, 2, prec, x, GMP_RNDN); #ifdef TWO_ARGS - printf ("\nu="); - mpfr_out_str (stdout, 2, prec, u, GMP_RNDN); + printf ("\nu="); + mpfr_out_str (stdout, 2, prec, u, GMP_RNDN); #endif printf (" prec=%u rnd_mode=%s\n", (unsigned) prec, mpfr_print_rnd_mode (rnd)); @@ -113,7 +113,7 @@ test_generic (mp_prec_t p0, mp_prec_t p1, unsigned int N) "\n", mpfr_print_rnd_mode (rnd), compare, inexact); printf ("x="); mpfr_print_binary (x); puts (""); #ifdef TWO_ARGS - printf ("u="); mpfr_print_binary (u); puts (""); + printf ("u="); mpfr_print_binary (u); puts (""); #endif printf ("y="); mpfr_print_binary (y); puts (""); printf ("t="); mpfr_print_binary (t); puts (""); diff --git a/tests/tgeneric_ui.c b/tests/tgeneric_ui.c index 442e644c5..3a40a35cf 100644 --- a/tests/tgeneric_ui.c +++ b/tests/tgeneric_ui.c @@ -56,23 +56,23 @@ test_generic_ui (mp_prec_t p0, mp_prec_t p1, unsigned int N) for (n=0; n= 0) - compare = compare + compare2; - else - compare = inexact; /* cannot determine sign(t-f(x)) */ - if (((inexact == 0) && (compare != 0)) || - ((inexact > 0) && (compare <= 0)) || - ((inexact < 0) && (compare >= 0))) - { - printf ("Wrong inexact flag for rnd=%s and %s_z:\n" - "expected %d, got %d\n", - mpfr_print_rnd_mode (rnd), op, compare, inexact); - printf ("\narg1="); mpfr_print_binary (arg1); - printf ("\narg2="); mpz_out_str(stdout, 2, arg2); - printf ("\ndstl="); mpfr_print_binary (dst_big); - printf ("\ndsts="); mpfr_print_binary (dst_small); + mpfr_print_binary (arg1); + printf("\narg2="); + mpz_out_str (stdout, 2, arg2); + printf ("\ngot "); + mpfr_dump (dst_small); + printf ("expected "); + mpfr_dump (tmp); + printf ("approx "); + mpfr_dump (dst_big); + exit (1); + } + compare2 = mpfr_cmp (tmp, dst_big); + /* if rounding to nearest, cannot know the sign of t - f(x) + because of composed rounding: y = o(f(x)) and t = o(y) */ + if (compare * compare2 >= 0) + compare = compare + compare2; + else + compare = inexact; /* cannot determine sign(t-f(x)) */ + if (((inexact == 0) && (compare != 0)) || + ((inexact > 0) && (compare <= 0)) || + ((inexact < 0) && (compare >= 0))) + { + printf ("Wrong inexact flag for rnd=%s and %s_z:\n" + "expected %d, got %d\n", + mpfr_print_rnd_mode (rnd), op, compare, inexact); + printf ("\narg1="); mpfr_print_binary (arg1); + printf ("\narg2="); mpz_out_str(stdout, 2, arg2); + printf ("\ndstl="); mpfr_print_binary (dst_big); + printf ("\ndsts="); mpfr_print_binary (dst_small); printf ("\ntmp ="); mpfr_dump (tmp); - exit (1); - } - } - } + exit (1); + } + } + } } mpz_clear (arg2); @@ -468,7 +468,7 @@ test_genericz (mp_prec_t p0, mp_prec_t p1, unsigned int N, static void test_genericq (mp_prec_t p0, mp_prec_t p1, unsigned int N, int (*func)(mpfr_ptr, mpfr_srcptr, mpq_srcptr, mp_rnd_t), - const char *op) + const char *op) { mp_prec_t prec; mpfr_t arg1, dst_big, dst_small, tmp; @@ -490,7 +490,7 @@ test_genericq (mp_prec_t p0, mp_prec_t p1, unsigned int N, { mpfr_urandomb (arg1, RANDS); mpq_set_ui (arg2, randlimb (), randlimb() ); - mpq_canonicalize (arg2); + mpq_canonicalize (arg2); rnd = (mp_rnd_t) RND_RAND (); mpfr_set_prec (dst_big, prec+10); compare = func(dst_big, arg1, arg2, rnd); @@ -501,7 +501,7 @@ test_genericq (mp_prec_t p0, mp_prec_t p1, unsigned int N, if (mpfr_cmp (tmp, dst_small)) { printf ("Results differ for prec=%u rnd_mode=%s and %s_q:\n" - "arg1=", + "arg1=", (unsigned) prec, mpfr_print_rnd_mode (rnd), op); mpfr_print_binary (arg1); printf("\narg2="); @@ -512,7 +512,7 @@ test_genericq (mp_prec_t p0, mp_prec_t p1, unsigned int N, mpfr_print_binary (tmp); printf ("\napprox "); mpfr_print_binary (dst_big); - putchar('\n'); + putchar('\n'); exit (1); } compare2 = mpfr_cmp (tmp, dst_big); @@ -527,14 +527,14 @@ test_genericq (mp_prec_t p0, mp_prec_t p1, unsigned int N, ((inexact < 0) && (compare >= 0))) { printf ("Wrong inexact flag for rnd=%s and %s_q:\n" - "expected %d, got %d", - mpfr_print_rnd_mode (rnd), op, compare, inexact); + "expected %d, got %d", + mpfr_print_rnd_mode (rnd), op, compare, inexact); printf ("\narg1="); mpfr_print_binary (arg1); printf ("\narg2="); mpq_out_str(stdout, 2, arg2); printf ("\ndstl="); mpfr_print_binary (dst_big); printf ("\ndsts="); mpfr_print_binary (dst_small); printf ("\ntmp ="); mpfr_print_binary (tmp); - putchar('\n'); + putchar('\n'); exit (1); } } @@ -547,9 +547,9 @@ test_genericq (mp_prec_t p0, mp_prec_t p1, unsigned int N, static void test_specialq (mp_prec_t p0, mp_prec_t p1, unsigned int N, - int (*mpfr_func)(mpfr_ptr, mpfr_srcptr, mpq_srcptr, mp_rnd_t), + int (*mpfr_func)(mpfr_ptr, mpfr_srcptr, mpq_srcptr, mp_rnd_t), void (*mpq_func)(mpq_ptr, mpq_srcptr, mpq_srcptr), - const char *op) + const char *op) { mpfr_t fra, frb, frq; mpq_t q1, q2, qr; @@ -562,30 +562,30 @@ test_specialq (mp_prec_t p0, mp_prec_t p1, unsigned int N, mpq_init (q1); mpq_init(q2); mpq_init (qr); for( n = 0 ; n < N ; n++) - { - mpq_set_ui(q1, randlimb(), randlimb() ); - mpq_set_ui(q2, randlimb(), randlimb() ); - mpq_canonicalize (q1); - mpq_canonicalize (q2); - mpq_func (qr, q1, q2); - mpfr_set_q (fra, q1, GMP_RNDD); - mpfr_func (fra, fra, q2, GMP_RNDD); - mpfr_set_q (frb, q1, GMP_RNDU); - mpfr_func (frb, frb, q2, GMP_RNDU); - mpfr_set_q (frq, qr, GMP_RNDN); - /* We should have fra <= qr <= frb */ - if ( (mpfr_cmp(fra, frq) > 0) || (mpfr_cmp (frq, frb) > 0)) - { - printf("Range error for prec=%lu and %s", prec, op); - printf ("\nq1="); mpq_out_str(stdout, 2, q1); - printf ("\nq2="); mpq_out_str(stdout, 2, q2); - printf ("\nfr_dn="); mpfr_print_binary (fra); - printf ("\nfr_q ="); mpfr_print_binary (frq); - printf ("\nfr_up="); mpfr_print_binary (frb); - putchar('\n'); - exit (1); - } - } + { + mpq_set_ui(q1, randlimb(), randlimb() ); + mpq_set_ui(q2, randlimb(), randlimb() ); + mpq_canonicalize (q1); + mpq_canonicalize (q2); + mpq_func (qr, q1, q2); + mpfr_set_q (fra, q1, GMP_RNDD); + mpfr_func (fra, fra, q2, GMP_RNDD); + mpfr_set_q (frb, q1, GMP_RNDU); + mpfr_func (frb, frb, q2, GMP_RNDU); + mpfr_set_q (frq, qr, GMP_RNDN); + /* We should have fra <= qr <= frb */ + if ( (mpfr_cmp(fra, frq) > 0) || (mpfr_cmp (frq, frb) > 0)) + { + printf("Range error for prec=%lu and %s", prec, op); + printf ("\nq1="); mpq_out_str(stdout, 2, q1); + printf ("\nq2="); mpq_out_str(stdout, 2, q2); + printf ("\nfr_dn="); mpfr_print_binary (fra); + printf ("\nfr_q ="); mpfr_print_binary (frq); + printf ("\nfr_up="); mpfr_print_binary (frb); + putchar('\n'); + exit (1); + } + } mpq_clear (q1); mpq_clear (q2); mpq_clear (qr); mpfr_clears (fra, frb, frq, NULL); diff --git a/tests/tlog.c b/tests/tlog.c index 54285cb51..6990d5a49 100644 --- a/tests/tlog.c +++ b/tests/tlog.c @@ -59,7 +59,7 @@ check2 (const char *as, mp_rnd_t rnd_mode, const char *res1s) if (mpfr_cmp_str1 (tres, res1s)) { printf ("mpfr_log failed for a=%s, rnd_mode=%s\n", - as, mpfr_print_rnd_mode (rnd_mode)); + as, mpfr_print_rnd_mode (rnd_mode)); printf ("correct result is %s\n mpfr_log gives ", res1s); mpfr_out_str(stdout, 10, 0, tres, GMP_RNDN); diff --git a/tests/tmul.c b/tests/tmul.c index 6b2aa2f3b..3203bbafc 100644 --- a/tests/tmul.c +++ b/tests/tmul.c @@ -55,7 +55,7 @@ test_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) /* checks that x*y gives the right result */ static void pcheck (const char *xs, const char *ys, const char *res, mp_rnd_t rnd_mode, - unsigned int px, unsigned int py, unsigned int pz) + unsigned int px, unsigned int py, unsigned int pz) { mpfr_t xx, yy, zz; @@ -72,16 +72,16 @@ pcheck (const char *xs, const char *ys, const char *res, mp_rnd_t rnd_mode, printf ("correct is %s, mpfr_mul gives ", res); mpfr_out_str(stdout, 10, 0, zz, GMP_RNDN); /* - printf("\nBinary forms:\nxx="); - mpfr_print_binary (xx); - printf("\nyy="); - mpfr_print_binary (yy); - printf("\nzz="); - mpfr_print_binary(zz); - printf("\nre="); - mpfr_set_str1 (zz, res); - mpfr_print_binary(zz); - putchar('\n');*/ + printf("\nBinary forms:\nxx="); + mpfr_print_binary (xx); + printf("\nyy="); + mpfr_print_binary (yy); + printf("\nzz="); + mpfr_print_binary(zz); + printf("\nre="); + mpfr_set_str1 (zz, res); + mpfr_print_binary(zz); + putchar('\n');*/ exit (1); } mpfr_clear(xx); mpfr_clear(yy); mpfr_clear(zz); @@ -103,16 +103,16 @@ check53 (const char *xs, const char *ys, mp_rnd_t rnd_mode, const char *zs) printf ("correct result is %s,\n mpfr_mul gives ", zs); mpfr_out_str(stdout, 10, 0, zz, GMP_RNDN); /* - printf("\nBinary forms:\nxx="); - mpfr_print_binary (xx); - printf("\nyy="); - mpfr_print_binary (yy); - printf("\nzz="); - mpfr_print_binary(zz); - printf("\nre="); - mpfr_set_str1 (zz, zs); - mpfr_print_binary(zz); - putchar('\n'); */ + printf("\nBinary forms:\nxx="); + mpfr_print_binary (xx); + printf("\nyy="); + mpfr_print_binary (yy); + printf("\nzz="); + mpfr_print_binary(zz); + printf("\nre="); + mpfr_set_str1 (zz, zs); + mpfr_print_binary(zz); + putchar('\n'); */ exit (1); } mpfr_clears (xx, yy, zz, NULL); @@ -131,7 +131,7 @@ check24 (const char *xs, const char *ys, mp_rnd_t rnd_mode, const char *zs) if (mpfr_cmp_str1 (zz, zs) ) { printf ("(3) mpfr_mul failed for x=%s y=%s with " - "rnd=%s\n", xs, ys, mpfr_print_rnd_mode(rnd_mode)); + "rnd=%s\n", xs, ys, mpfr_print_rnd_mode(rnd_mode)); printf ("correct result is gives %s, mpfr_mul gives ", zs); mpfr_out_str(stdout, 10, 0, zz, GMP_RNDN); putchar('\n'); @@ -546,12 +546,12 @@ check_regression (void) i = mpfr_mul (x, y, z, GMP_RNDU); mpfr_set_prec (y, 184); mpfr_set_str (y, "3.0080038f2ac5054e3e71ccbb95f76aaab2221715025a28@255", - 16, GMP_RNDN); + 16, GMP_RNDN); if (mpfr_cmp (x, y) || i <= 0) { printf ("Regression test (4) failed! (i=%d - expected 1)\n", i); printf ("Ref: 3.0080038f2ac5054e3e71ccbb95f76aaab2221715025a28@255\n" - "Got: "); + "Got: "); mpfr_out_str (stdout, 16, 0, x, GMP_RNDN); printf ("\n"); exit (1); @@ -567,7 +567,7 @@ check_regression (void) mpfr_set_str (z, "-f.fffffffffffffffffffffffffffffffffffffffffffffffffffffff" "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" "ffffffffffffffffffffffffffffffffffffffffffffffffffffff99be91f83ec6f0ed28a3d42" - "e6e9a327230345ea6@-1", 16, GMP_RNDN); + "e6e9a327230345ea6@-1", 16, GMP_RNDN); i = mpfr_mul (x, y, z, GMP_RNDU); mpfr_set_str (y, "f.ffffffffffffffffffffffffffffffffffffffffffffffffffffffff" "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" @@ -604,12 +604,12 @@ check_regression (void) mpfr_set_prec (x, 439); mpfr_set_prec (y, 393); mpfr_set_str (y, "-1.921fb54442d18469898cc51701b839a252049c1114cf98e804177d" - "4c76273644a29410f31c6809bbdf2a33679a748636600", - 16, GMP_RNDN); + "4c76273644a29410f31c6809bbdf2a33679a748636600", + 16, GMP_RNDN); i = mpfr_mul (x, y, y, GMP_RNDU); if (mpfr_cmp_str (x, "2.77a79937c8bbcb495b89b36602306b1c2159a8ff834288a19a08" "84094f1cda3dc426da61174c4544a173de83c2500f8bfea2e0569e3698", - 16, GMP_RNDN) != 0 + 16, GMP_RNDN) != 0 || i <= 0) { printf ("Regression test (7) failed! (i=%d - expected 1)\nx=", i); @@ -655,27 +655,27 @@ main (int argc, char *argv[]) check53("0.0", "6.9314718055994530941514e-1", GMP_RNDZ, "0.0"); check_sign(); check53("-4.165000000e4", "-0.00004801920768307322868063274915", GMP_RNDN, - "2.0"); + "2.0"); check53("2.71331408349172961467e-08", "-6.72658901114033715233e-165", - GMP_RNDZ, "-1.8251348697787782844e-172"); + GMP_RNDZ, "-1.8251348697787782844e-172"); check53("0.31869277231188065", "0.88642843322303122", GMP_RNDZ, - "2.8249833483992453642e-1"); + "2.8249833483992453642e-1"); check("8.47622108205396074254e-01", "3.24039313247872939883e-01", GMP_RNDU, - 28, 45, 2, "0.375"); + 28, 45, 2, "0.375"); check("2.63978122803639081440e-01", "6.8378615379333496093e-1", GMP_RNDN, - 34, 23, 31, "0.180504585267044603"); + 34, 23, 31, "0.180504585267044603"); check("1.0", "0.11835170935876249132", GMP_RNDU, 6, 41, 36, - "0.1183517093595583"); + "0.1183517093595583"); check53("67108865.0", "134217729.0", GMP_RNDN, "9.007199456067584e15"); check("1.37399642157394197284e-01", "2.28877275604219221350e-01", GMP_RNDN, - 49, 15, 32, "0.0314472340833162888"); + 49, 15, 32, "0.0314472340833162888"); check("4.03160720978664954828e-01", "5.854828e-1" - /*"5.85483042917246621073e-01"*/, GMP_RNDZ, - 51, 22, 32, "0.2360436821472831"); + /*"5.85483042917246621073e-01"*/, GMP_RNDZ, + 51, 22, 32, "0.2360436821472831"); check("3.90798504668055102229e-14", "9.85394674650308388664e-04", GMP_RNDN, - 46, 22, 12, "0.385027296503914762e-16"); + 46, 22, 12, "0.385027296503914762e-16"); check("4.58687081072827851358e-01", "2.20543551472118792844e-01", GMP_RNDN, - 49, 3, 2, "0.09375"); + 49, 3, 2, "0.09375"); check_max(); check_min(); diff --git a/tests/tmul_2exp.c b/tests/tmul_2exp.c index 482bc77c6..dfef2a3e9 100644 --- a/tests/tmul_2exp.c +++ b/tests/tmul_2exp.c @@ -125,10 +125,10 @@ main (int argc, char *argv[]) mpfr_div_2ui (w, w, lmp1, GMP_RNDZ); mpfr_mul_2ui (w, w, lmp1 - LONG_MAX/2, GMP_RNDZ); if (!mpfr_cmp_ui (w, 1)) - { - printf ("Underflow LONG_MAX error!\n"); - exit (1); - } + { + printf ("Underflow LONG_MAX error!\n"); + exit (1); + } } mpfr_clears (w, z, NULL); diff --git a/tests/tmul_ui.c b/tests/tmul_ui.c index 02bb6b2c7..f5d88789d 100644 --- a/tests/tmul_ui.c +++ b/tests/tmul_ui.c @@ -153,7 +153,7 @@ main (int argc, char *argv[]) set_emax (emax); mpfr_set_str (x, /*1.0/3.0*/ - "0.333333333333333333333333333333333", 10, GMP_RNDZ); + "0.333333333333333333333333333333333", 10, GMP_RNDZ); mpfr_mul_ui (x, x, 3, GMP_RNDU); if (mpfr_cmp_ui (x, 1)) { diff --git a/tests/tout_str.c b/tests/tout_str.c index 530d45ec3..780733400 100644 --- a/tests/tout_str.c +++ b/tests/tout_str.c @@ -139,7 +139,7 @@ main (int argc, char *argv[]) fout = fopen ("/dev/null", "w"); /* If we failed to open this device, try with a dummy file */ if (fout == NULL) - fout = fopen ("mpfrtest.txt", "w"); + fout = fopen ("mpfrtest.txt", "w"); } else { diff --git a/tests/toutimpl.c b/tests/toutimpl.c index 27aba6468..486e18c39 100644 --- a/tests/toutimpl.c +++ b/tests/toutimpl.c @@ -103,16 +103,16 @@ int main() for(i = 0 ; i < sizeof(Buffer)-1 ; i++) { if (feof (f)) - { - fprintf (stderr, "Error EOF\n"); - exit (1); - } + { + fprintf (stderr, "Error EOF\n"); + exit (1); + } if (Buffer[i] != fgetc (f)) - { - fprintf (stderr, "Character mismatch for i=%d / %lu\n", - i, (unsigned long) sizeof(Buffer)); + { + fprintf (stderr, "Character mismatch for i=%d / %lu\n", + i, (unsigned long) sizeof(Buffer)); exit (1); - } + } } fclose (f); diff --git a/tests/tpow_z.c b/tests/tpow_z.c index 93dac17ad..de6811aee 100644 --- a/tests/tpow_z.c +++ b/tests/tpow_z.c @@ -154,27 +154,27 @@ static void check_integer (mp_prec_t begin, mp_prec_t end, unsigned long max) { mpfr_mul_2ui (x, x, 1, GMP_RNDN); /* 0 <= x < 2 */ rnd = (mp_rnd_t) RND_RAND (); if (mpz_fits_slong_p (z)) { - n = mpz_get_si (z); - /* printf ("New test for x=%ld\nCheck Pow_si\n", n); */ - res1 = mpfr_pow_si (y1, x, n, rnd); - /* printf ("Check pow_z\n"); */ - res2 = mpfr_pow_z (y2, x, z, rnd); - if (mpfr_cmp (y1, y2) != 0) { - printf ("Error for p=%lu, z=%ld, rnd=%s and x=", p, n, - mpfr_print_rnd_mode (rnd)); - mpfr_dump (x); - printf ("Ypowui="); mpfr_dump (y1); - printf ("Ypowz ="); mpfr_dump (y2); - exit (1); - } - if (res1 != res2) { - printf ("Wrong inexact flags for p=%lu, z=%ld, rnd=%s and x=", p, n, + n = mpz_get_si (z); + /* printf ("New test for x=%ld\nCheck Pow_si\n", n); */ + res1 = mpfr_pow_si (y1, x, n, rnd); + /* printf ("Check pow_z\n"); */ + res2 = mpfr_pow_z (y2, x, z, rnd); + if (mpfr_cmp (y1, y2) != 0) { + printf ("Error for p=%lu, z=%ld, rnd=%s and x=", p, n, + mpfr_print_rnd_mode (rnd)); + mpfr_dump (x); + printf ("Ypowui="); mpfr_dump (y1); + printf ("Ypowz ="); mpfr_dump (y2); + exit (1); + } + if (res1 != res2) { + printf ("Wrong inexact flags for p=%lu, z=%ld, rnd=%s and x=", p, n, mpfr_print_rnd_mode (rnd)); - mpfr_dump (x); + mpfr_dump (x); printf ("Ypowui(%d)=", res1); mpfr_dump (y1); printf ("Ypowz (%d)=", res2); mpfr_dump (y2); - exit (1); - } + exit (1); + } } } /* for i */ } /* for p */ diff --git a/tests/trandom.c b/tests/trandom.c index b0e996120..d0092c0fc 100644 --- a/tests/trandom.c +++ b/tests/trandom.c @@ -60,7 +60,7 @@ test_random (long nbtests, mp_prec_t prec, int verbose) printf("Average = %.5f\nVariance = %.5f\n", av, var); printf("Repartition for random. Each integer should be close to %d.\n", - (int)th); + (int)th); for (k = 0; k < size_tab; k++) { @@ -71,7 +71,7 @@ test_random (long nbtests, mp_prec_t prec, int verbose) } printf("\nChi2 statistics value (with %d degrees of freedom) : %.5f\n\n", - size_tab - 1, chi2); + size_tab - 1, chi2); printf("\n"); @@ -149,7 +149,7 @@ test_random2 (long nbtests, mp_prec_t prec, int verbose) } printf("\nChi2 statistics value (with %d degrees of freedom) : %.5f\n\n", - size_tab - 1, chi2); + size_tab - 1, chi2); free(tab); return; @@ -217,7 +217,7 @@ test_urandomb (long nbtests, mp_prec_t prec, int verbose) th = (double)nbtests / size_tab; printf("Average = %.5f\nVariance = %.5f\n", av, var); printf("Repartition for urandomb. Each integer should be close to %d.\n", - (int)th); + (int)th); for (k = 0; k < size_tab; k++) { @@ -228,7 +228,7 @@ test_urandomb (long nbtests, mp_prec_t prec, int verbose) } printf("\nChi2 statistics value (with %d degrees of freedom) : %.5f\n\n", - size_tab - 1, chi2); + size_tab - 1, chi2); free(tab); return; diff --git a/tests/trint.c b/tests/trint.c index 5b79cf506..b23481a61 100644 --- a/tests/trint.c +++ b/tests/trint.c @@ -138,10 +138,10 @@ special (void) mpfr_set_prec (x, 84); mpfr_set_str_binary (x, "0.110011010010001000000111101101001111111100101110010000000000000" \ - "000000000000000000000E32"); + "000000000000000000000E32"); mpfr_round (x, x); if (mpfr_cmp_str (x, "0.1100110100100010000001111011010100000000000000" \ - "00000000000000000000000000000000000000E32", 2, GMP_RNDN)) + "00000000000000000000000000000000000000E32", 2, GMP_RNDN)) { printf ("Rounding error when dest=src\n"); exit (1); diff --git a/tests/tset.c b/tests/tset.c index 328e7df53..f45957c59 100644 --- a/tests/tset.c +++ b/tests/tset.c @@ -113,7 +113,7 @@ main (void) mpfr_set_prec (x, p); mpfr_random (x); if (randlimb () % 2) - mpfr_neg (x, x, GMP_RNDN); + mpfr_neg (x, x, GMP_RNDN); for (q=2; q<2*p; q++) { mpfr_set_prec (y, q); diff --git a/tests/tset_si.c b/tests/tset_si.c index 3918d20fc..5c2625e31 100644 --- a/tests/tset_si.c +++ b/tests/tset_si.c @@ -182,20 +182,20 @@ main (int argc, char *argv[]) mpfr_set_si (x, -1, (mp_rnd_t) r); mpfr_set_ui (x, 0, (mp_rnd_t) r); if (MPFR_IS_NEG (x) || mpfr_get_ui (x, (mp_rnd_t) r) != 0) - { - printf ("mpfr_set_ui (x, 0) gives -0 for %s\n", - mpfr_print_rnd_mode ((mp_rnd_t) r)); - exit (1); - } + { + printf ("mpfr_set_ui (x, 0) gives -0 for %s\n", + mpfr_print_rnd_mode ((mp_rnd_t) r)); + exit (1); + } mpfr_set_si (x, -1, (mp_rnd_t) r); mpfr_set_si (x, 0, (mp_rnd_t) r); if (MPFR_IS_NEG (x) || mpfr_get_si (x, (mp_rnd_t) r) != 0) - { - printf ("mpfr_set_si (x, 0) gives -0 for %s\n", - mpfr_print_rnd_mode ((mp_rnd_t) r)); - exit (1); - } + { + printf ("mpfr_set_si (x, 0) gives -0 for %s\n", + mpfr_print_rnd_mode ((mp_rnd_t) r)); + exit (1); + } } /* check potential bug in case mp_limb_t is unsigned */ diff --git a/tests/tset_sj.c b/tests/tset_sj.c index 2f154f9fb..621441704 100644 --- a/tests/tset_sj.c +++ b/tests/tset_sj.c @@ -71,27 +71,27 @@ check_set_uj (mp_prec_t pmin, mp_prec_t pmax, int N) mpfr_set_prec (x, p); mpfr_set_prec (y, p); for (n = 0 ; n < N ; n++) - { - /* mp_limb_t may be unsigned long long */ - limb = (unsigned long) randlimb (); - inex1 = mpfr_set_uj (x, limb, GMP_RNDN); - inex2 = mpfr_set_ui (y, limb, GMP_RNDN); - if (mpfr_cmp (x, y)) - { - printf ("ERROR for mpfr_set_uj and j=%lu and p=%lu\n", - (unsigned long) limb, p); - printf ("X="); mpfr_dump (x); - printf ("Y="); mpfr_dump (y); - exit (1); - } - if (inexact_sign (inex1) != inexact_sign (inex2)) - { - printf ("ERROR for inexact(set_uj): j=%lu p=%lu\n" - "Inexact1= %d Inexact2= %d\n", - (unsigned long) limb, p, inex1, inex2); + { + /* mp_limb_t may be unsigned long long */ + limb = (unsigned long) randlimb (); + inex1 = mpfr_set_uj (x, limb, GMP_RNDN); + inex2 = mpfr_set_ui (y, limb, GMP_RNDN); + if (mpfr_cmp (x, y)) + { + printf ("ERROR for mpfr_set_uj and j=%lu and p=%lu\n", + (unsigned long) limb, p); + printf ("X="); mpfr_dump (x); + printf ("Y="); mpfr_dump (y); exit (1); - } - } + } + if (inexact_sign (inex1) != inexact_sign (inex2)) + { + printf ("ERROR for inexact(set_uj): j=%lu p=%lu\n" + "Inexact1= %d Inexact2= %d\n", + (unsigned long) limb, p, inex1, inex2); + exit (1); + } + } } /* Special case */ mpfr_set_prec (x, sizeof(uintmax_t)*CHAR_BIT); diff --git a/tests/tset_str.c b/tests/tset_str.c index c83353821..c563084b8 100644 --- a/tests/tset_str.c +++ b/tests/tset_str.c @@ -60,8 +60,8 @@ check_underflow (void) if (!MPFR_IS_ZERO (a)) { printf("ERROR for mpfr_set_str (a, \"0.00000000001\", 10, GMP_RNDN)\n" - " with emin=-20\n" - "res=%d\n", res); + " with emin=-20\n" + "res=%d\n", res); mpfr_dump (a); exit (1); } @@ -116,7 +116,7 @@ main (int argc, char *argv[]) if (bd) { for(k = 1; k <= bd; k++) - *(str2++) = (randlimb () & 1) + '0'; + *(str2++) = (randlimb () & 1) + '0'; } else *(str2++) = '0'; @@ -204,13 +204,13 @@ main (int argc, char *argv[]) logbase = (randlimb () % 5) + 1; base = 1 << logbase; /* 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 */ + '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 */ if (base == 2) - baseprec = prec; + baseprec = prec; else - baseprec = 1 + (prec - 2 + logbase) / logbase; + baseprec = 1 + (prec - 2 + logbase) / logbase; str = mpfr_get_str (NULL, &e, base, baseprec, x, (mp_rnd_t) k); mpfr_set_str (y, str, base, (mp_rnd_t) k); MPFR_EXP(y) += logbase * (e - strlen (str)); @@ -780,7 +780,7 @@ main (int argc, char *argv[]) printf ("return : "); mpfr_print_binary (y); puts (""); - exit (1); + exit (1); } } diff --git a/tests/tsgn.c b/tests/tsgn.c index 30d2298da..353442f18 100644 --- a/tests/tsgn.c +++ b/tests/tsgn.c @@ -68,34 +68,34 @@ check_sgn(void) { mpfr_random(x); if (i&1) - { - MPFR_SET_POS(x); - s2 = 1; - } + { + MPFR_SET_POS(x); + s2 = 1; + } else - { - MPFR_SET_NEG(x); - s2 = -1; - } + { + MPFR_SET_NEG(x); + s2 = -1; + } s1 = mpfr_sgn(x); if (s1 < -1 || s1 > 1) - { - printf("Error for sgn: out of range.\n"); - goto lexit; - } + { + printf("Error for sgn: out of range.\n"); + goto lexit; + } else if (MPFR_IS_NAN(x) || MPFR_IS_ZERO(x)) - { - if (s1 != 0) - { - printf("Error for sgn: Nan or Zero should return 0.\n"); - goto lexit; - } - } + { + if (s1 != 0) + { + printf("Error for sgn: Nan or Zero should return 0.\n"); + goto lexit; + } + } else if (s1 != s2) - { - printf("Error for sgn. Return %d instead of %d.\n", s1, s2); - goto lexit; - } + { + printf("Error for sgn. Return %d instead of %d.\n", s1, s2); + goto lexit; + } } mpfr_clear(x); return; diff --git a/tests/tsi_op.c b/tests/tsi_op.c index b71c6a6d3..fdf15d895 100644 --- a/tests/tsi_op.c +++ b/tests/tsi_op.c @@ -109,7 +109,7 @@ main (int argc, char *argv[]) y = tab[i].op2; mpfr_add_si (z, x, y, GMP_RNDZ); if (mpfr_cmp_str (z, tab[i].res_add, 16, GMP_RNDN)) - ERROR1("add_si", i, z, tab[i].res_add); + ERROR1("add_si", i, z, tab[i].res_add); mpfr_sub_si (z, x, y, GMP_RNDZ); if (mpfr_cmp_str (z, tab[i].res_sub, 16, GMP_RNDN)) ERROR1("sub_si", i, z, tab[i].res_sub); diff --git a/tests/tsin_cos.c b/tests/tsin_cos.c index e60db78b3..441f3d5ad 100644 --- a/tests/tsin_cos.c +++ b/tests/tsin_cos.c @@ -45,7 +45,7 @@ large_test (int prec, int N) static void check53 (const char *xs, const char *sin_xs, const char *cos_xs, - mp_rnd_t rnd_mode) + mp_rnd_t rnd_mode) { mpfr_t xx, s, c; @@ -179,21 +179,21 @@ main(int argc, char *argv[]) /* worst case from PhD thesis of Vincent Lefe`vre: x=8980155785351021/2^54 */ check53 ("4.984987858808754279e-1", "4.781075595393330379e-1", - "8.783012931285841817e-1", GMP_RNDN); + "8.783012931285841817e-1", GMP_RNDN); check53 ("4.984987858808754279e-1", "4.781075595393329824e-1", - "8.783012931285840707e-1", GMP_RNDD); + "8.783012931285840707e-1", GMP_RNDD); check53 ("4.984987858808754279e-1", "4.781075595393329824e-1", - "8.783012931285840707e-1", GMP_RNDZ); + "8.783012931285840707e-1", GMP_RNDZ); check53 ("4.984987858808754279e-1", "4.781075595393330379e-1", - "8.783012931285841817e-1", GMP_RNDU); + "8.783012931285841817e-1", GMP_RNDU); check53 ("1.00031274099908640274", "8.416399183372403892e-1", - "0.540039116973283217504", GMP_RNDN); + "0.540039116973283217504", GMP_RNDN); check53 ("1.00229256850978698523", "8.427074524447979442e-1", - "0.538371757797526551137", GMP_RNDZ); + "0.538371757797526551137", GMP_RNDZ); check53 ("1.00288304857059840103", "8.430252033025980029e-1", - "0.537874062022526966409", GMP_RNDZ); + "0.537874062022526966409", GMP_RNDZ); check53 ("1.00591265847407274059", "8.446508805292128885e-1", - "0.53531755997839769456", GMP_RNDN); + "0.53531755997839769456", GMP_RNDN); /* check one argument only */ check53sin ("1.00591265847407274059", "8.446508805292128885e-1", GMP_RNDN); diff --git a/tests/tsqr.c b/tests/tsqr.c index 1d1d7b9cc..103b8bced 100644 --- a/tests/tsqr.c +++ b/tests/tsqr.c @@ -49,7 +49,7 @@ inexact_sign (int x) static void error1 (mp_rnd_t rnd, mpfr_prec_t prec, - mpfr_t in, mpfr_t outmul, mpfr_t outsqr) + mpfr_t in, mpfr_t outmul, mpfr_t outsqr) { printf("ERROR: for %s and prec=%lu\nINPUT=", mpfr_print_rnd_mode(rnd), prec); mpfr_dump(in); @@ -60,7 +60,7 @@ error1 (mp_rnd_t rnd, mpfr_prec_t prec, static void error2 (mp_rnd_t rnd, mpfr_prec_t prec, mpfr_t in, mpfr_t out, - int inexactmul, int inexactsqr) + int inexactmul, int inexactsqr) { printf("ERROR: for %s and prec=%lu\nINPUT=", mpfr_print_rnd_mode(rnd), prec); mpfr_dump(in); diff --git a/tests/tsqrt.c b/tests/tsqrt.c index 7859ce0d7..b01898775 100644 --- a/tests/tsqrt.c +++ b/tests/tsqrt.c @@ -78,7 +78,7 @@ check4 (const char *as, mp_rnd_t rnd_mode, const char *Qs) if (mpfr_cmp_str (q, Qs, 16, GMP_RNDN)) { printf ("mpfr_sqrt failed for a=%s, rnd_mode=%s\n", - as, mpfr_print_rnd_mode(rnd_mode)); + as, mpfr_print_rnd_mode(rnd_mode)); printf ("expected "); mpfr_out_str (stdout, 16, 0, q, GMP_RNDN); printf ("\ngot %s\n", Qs); @@ -99,7 +99,7 @@ check24 (const char *as, mp_rnd_t rnd_mode, const char *qs) if (mpfr_cmp_str1 (q, qs)) { printf ("mpfr_sqrt failed for a=%s, prec=24, rnd_mode=%s\n", - as, mpfr_print_rnd_mode(rnd_mode)); + as, mpfr_print_rnd_mode(rnd_mode)); printf ("expected sqrt is %s, got ",qs); mpfr_out_str (stdout, 10, 0, q, GMP_RNDN); printf ("\n"); @@ -119,7 +119,7 @@ check_diverse (const char *as, mp_prec_t p, const char *qs) if (mpfr_cmp_str1 (q, qs)) { printf ("mpfr_sqrt failed for a=%s, prec=%lu, rnd_mode=%s\n", - as, p, mpfr_print_rnd_mode (GMP_RNDN)); + as, p, mpfr_print_rnd_mode (GMP_RNDN)); printf ("expected sqrt is %s, got ", qs); mpfr_out_str (stdout, 10, 0, q, GMP_RNDN); printf ("\n"); @@ -248,12 +248,12 @@ special (void) mpfr_nexttoinf (z); test_sqrt (x, z, GMP_RNDU); if (mpfr_cmp_ui_2exp(x, 3, -1)) - { - printf ("Error: sqrt(1+ulp(1), up) should give 1.5 (prec=%u)\n", + { + 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); - } + printf ("got "); mpfr_print_binary (x); puts (""); + exit (1); + } } /* check inexact flag */ @@ -594,82 +594,82 @@ main (void) Generation for Directed Rounding" from Michael Parks, Table 4 */ check4 ("78652858805036375191418371571712.0", GMP_RNDN, - "1.f81fc40f32063@13"); + "1.f81fc40f32063@13"); check4 ("38510074998589467860312736661504.0", GMP_RNDN, - "1.60c012a92fc65@13"); + "1.60c012a92fc65@13"); check4 ("35318779685413012908190921129984.0", GMP_RNDN, - "1.51d17526c7161@13"); + "1.51d17526c7161@13"); check4 ("26729022595358440976973142425600.0", GMP_RNDN, - "1.25e19302f7e51@13"); + "1.25e19302f7e51@13"); check4 ("22696567866564242819241453027328.0", GMP_RNDN, - "1.0ecea7dd2ec3d@13"); + "1.0ecea7dd2ec3d@13"); check4 ("22696888073761729132924856434688.0", GMP_RNDN, - "1.0ecf250e8e921@13"); + "1.0ecf250e8e921@13"); check4 ("36055652513981905145251657416704.0", GMP_RNDN, - "1.5552f3eedcf33@13"); + "1.5552f3eedcf33@13"); check4 ("30189856268896404997497182748672.0", GMP_RNDN, - "1.3853ee10c9c99@13"); + "1.3853ee10c9c99@13"); check4 ("36075288240584711210898775080960.0", GMP_RNDN, - "1.556abe212b56f@13"); + "1.556abe212b56f@13"); check4 ("72154663483843080704304789585920.0", GMP_RNDN, - "1.e2d9a51977e6e@13"); + "1.e2d9a51977e6e@13"); check4 ("78652858805036375191418371571712.0", GMP_RNDZ, - "1.f81fc40f32062@13"); + "1.f81fc40f32062@13"); check4 ("38510074998589467860312736661504.0", GMP_RNDZ, - "1.60c012a92fc64@13"); + "1.60c012a92fc64@13"); check4 ("35318779685413012908190921129984.0", GMP_RNDZ, "1.51d17526c716@13"); check4 ("26729022595358440976973142425600.0", GMP_RNDZ, "1.25e19302f7e5@13"); check4 ("22696567866564242819241453027328.0", GMP_RNDZ, - "1.0ecea7dd2ec3c@13"); + "1.0ecea7dd2ec3c@13"); check4 ("22696888073761729132924856434688.0", GMP_RNDZ, "1.0ecf250e8e92@13"); check4 ("36055652513981905145251657416704.0", GMP_RNDZ, - "1.5552f3eedcf32@13"); + "1.5552f3eedcf32@13"); check4 ("30189856268896404997497182748672.0", GMP_RNDZ, - "1.3853ee10c9c98@13"); + "1.3853ee10c9c98@13"); check4 ("36075288240584711210898775080960.0", GMP_RNDZ, - "1.556abe212b56e@13"); + "1.556abe212b56e@13"); check4 ("72154663483843080704304789585920.0", GMP_RNDZ, - "1.e2d9a51977e6d@13"); + "1.e2d9a51977e6d@13"); check4 ("78652858805036375191418371571712.0", GMP_RNDU, - "1.f81fc40f32063@13"); + "1.f81fc40f32063@13"); check4 ("38510074998589467860312736661504.0", GMP_RNDU, - "1.60c012a92fc65@13"); + "1.60c012a92fc65@13"); check4 ("35318779685413012908190921129984.0", GMP_RNDU, - "1.51d17526c7161@13"); + "1.51d17526c7161@13"); check4 ("26729022595358440976973142425600.0", GMP_RNDU, - "1.25e19302f7e51@13"); + "1.25e19302f7e51@13"); check4 ("22696567866564242819241453027328.0", GMP_RNDU, - "1.0ecea7dd2ec3d@13"); + "1.0ecea7dd2ec3d@13"); check4 ("22696888073761729132924856434688.0", GMP_RNDU, - "1.0ecf250e8e921@13"); + "1.0ecf250e8e921@13"); check4 ("36055652513981905145251657416704.0", GMP_RNDU, - "1.5552f3eedcf33@13"); + "1.5552f3eedcf33@13"); check4 ("30189856268896404997497182748672.0", GMP_RNDU, - "1.3853ee10c9c99@13"); + "1.3853ee10c9c99@13"); check4 ("36075288240584711210898775080960.0", GMP_RNDU, - "1.556abe212b56f@13"); + "1.556abe212b56f@13"); check4 ("72154663483843080704304789585920.0", GMP_RNDU, - "1.e2d9a51977e6e@13"); + "1.e2d9a51977e6e@13"); check4 ("78652858805036375191418371571712.0", GMP_RNDD, - "1.f81fc40f32062@13"); + "1.f81fc40f32062@13"); check4 ("38510074998589467860312736661504.0", GMP_RNDD, - "1.60c012a92fc64@13"); + "1.60c012a92fc64@13"); check4 ("35318779685413012908190921129984.0", GMP_RNDD, "1.51d17526c716@13"); check4 ("26729022595358440976973142425600.0", GMP_RNDD, "1.25e19302f7e5@13"); check4 ("22696567866564242819241453027328.0", GMP_RNDD, - "1.0ecea7dd2ec3c@13"); + "1.0ecea7dd2ec3c@13"); check4 ("22696888073761729132924856434688.0", GMP_RNDD, "1.0ecf250e8e92@13"); check4 ("36055652513981905145251657416704.0", GMP_RNDD, - "1.5552f3eedcf32@13"); + "1.5552f3eedcf32@13"); check4 ("30189856268896404997497182748672.0", GMP_RNDD, - "1.3853ee10c9c98@13"); + "1.3853ee10c9c98@13"); check4 ("36075288240584711210898775080960.0", GMP_RNDD, - "1.556abe212b56e@13"); + "1.556abe212b56e@13"); check4 ("72154663483843080704304789585920.0", GMP_RNDD, - "1.e2d9a51977e6d@13"); + "1.e2d9a51977e6d@13"); tests_end_mpfr (); return 0; diff --git a/tests/tstrtofr.c b/tests/tstrtofr.c index b9e1cdcae..eca635dbe 100644 --- a/tests/tstrtofr.c +++ b/tests/tstrtofr.c @@ -64,7 +64,7 @@ check_special (void) if (mpfr_cmp (x, y)) { printf ("Results differ between strtofr and set_str.\n" - " set_str gives: "); + " set_str gives: "); mpfr_dump (y); printf (" strtofr gives: "); mpfr_dump (x); @@ -199,11 +199,11 @@ int main() mpfr_init (x); printf ("struct dymmy_test { \n" - " mp_prec_t prec; \n" - " int base; \n" - " const char *str; \n" - " const char *binstr; \n" - " } RefTable[] = { \n"); + " mp_prec_t prec; \n" + " int base; \n" + " const char *str; \n" + " const char *binstr; \n" + " } RefTable[] = { \n"); for (i = 0 ; i < MAX_NUM ; i++) { p = randomab(2, 180); @@ -551,27 +551,27 @@ check_reftable () mpfr_set_str_binary (x, RefTable[i].binstr); mpfr_strtofr (y, RefTable[i].str, &s, base, GMP_RNDN); if (s == NULL || *s != 0) - { - printf ("strtofr didn't parse entire input for i=%d:\n" - " Str=%s", i, RefTable[i].str); - exit (1); - } + { + printf ("strtofr didn't parse entire input for i=%d:\n" + " Str=%s", i, RefTable[i].str); + exit (1); + } if (mpfr_cmp (x, y)) - { - printf ("Results differ between strtofr and set_binary for i=%d:\n" - " Set binary gives: ", i); - mpfr_dump (x); - printf (" strtofr gives: "); - mpfr_dump (y); - printf (" setstr gives: "); - mpfr_set_str (x, RefTable[i].str, base, GMP_RNDN); - mpfr_dump (x); - mpfr_set_prec (x, 2*p); - mpfr_set_str (x, RefTable[i].str, base, GMP_RNDN); - printf (" setstr ++ gives: "); - mpfr_dump (x); - exit (1); - } + { + printf ("Results differ between strtofr and set_binary for i=%d:\n" + " Set binary gives: ", i); + mpfr_dump (x); + printf (" strtofr gives: "); + mpfr_dump (y); + printf (" setstr gives: "); + mpfr_set_str (x, RefTable[i].str, base, GMP_RNDN); + mpfr_dump (x); + mpfr_set_prec (x, 2*p); + mpfr_set_str (x, RefTable[i].str, base, GMP_RNDN); + printf (" setstr ++ gives: "); + mpfr_dump (x); + exit (1); + } } mpfr_clear (y); mpfr_clear (x); @@ -758,7 +758,7 @@ check_overflow (void) exit (1); } mpfr_strtofr (x, "123456789E170141183460469231731687303715884105728", - &s, 0, GMP_RNDN); + &s, 0, GMP_RNDN); if (s[0] != 0 || !MPFR_IS_INF (x) || !MPFR_IS_POS (x) ) { printf ("Check overflow failed (3) with:\n s=%s\n x=", s); @@ -812,7 +812,7 @@ check_overflow (void) exit (1); } mpfr_strtofr (x, "-123456789E-170141183460469231731687303715884105728", - &s, 0, GMP_RNDN); + &s, 0, GMP_RNDN); if (s[0] != 0 || !MPFR_IS_ZERO (x) || !MPFR_IS_NEG (x) ) { printf ("Check underflow failed (3) with:\n s=%s\n x=", s); diff --git a/tests/tsub.c b/tests/tsub.c index 097915138..abbbf5643 100644 --- a/tests/tsub.c +++ b/tests/tsub.c @@ -368,7 +368,7 @@ check_two_sum (mp_prec_t p) ((inexact < 0) && (mpfr_cmp_ui (w, 0) >= 0))) { printf ("Wrong inexact flag for prec=%u, rnd=%s\n", (unsigned)p, - mpfr_print_rnd_mode (rnd)); + mpfr_print_rnd_mode (rnd)); printf ("x="); mpfr_print_binary(x); puts (""); printf ("y="); mpfr_print_binary(y); puts (""); printf ("u="); mpfr_print_binary(u); puts (""); diff --git a/tests/tsub_ui.c b/tests/tsub_ui.c index a64503170..55ea783dd 100644 --- a/tests/tsub_ui.c +++ b/tests/tsub_ui.c @@ -135,7 +135,7 @@ main (int argc, char *argv[]) check_two_sum (p); check3 ("0.9999999999", 1, GMP_RNDN, - "-10000000827403709990903735160827636718750e-50"); + "-10000000827403709990903735160827636718750e-50"); test_generic_ui (2, 1000, 100); diff --git a/tests/tsum.c b/tests/tsum.c index b98508ee4..e2934d719 100644 --- a/tests/tsum.c +++ b/tests/tsum.c @@ -91,10 +91,10 @@ algo_exact (mpfr_t somme, mpfr_t *tab, unsigned long n, mp_prec_t f) for (i = 0; i < n; i++) { if (mpfr_add(somme, somme, tab[i], GMP_RNDN)) - { + { printf ("FIXME: algo_exact is buggy.\n"); exit (1); - } + } } } diff --git a/tests/tui_div.c b/tests/tui_div.c index 38ca4514e..42a3ecb1c 100644 --- a/tests/tui_div.c +++ b/tests/tui_div.c @@ -167,15 +167,15 @@ main (int argc, char *argv[]) check_nan (); check_inexact (); check(948002822, "1.22191250737771397120e+20", GMP_RNDN, - "7.758352715731357946e-12"); + "7.758352715731357946e-12"); check(1976245324, "1.25296395864546893357e+232", GMP_RNDZ, - "1.5772563211925444801e-223"); + "1.5772563211925444801e-223"); check(740454110, "2.11496253355831863313e+183", GMP_RNDZ, - "3.5010270784996976041e-175"); + "3.5010270784996976041e-175"); check(1690540942, "1.28278599852446657468e-276", GMP_RNDU, - "1.3178666932321966062e285"); + "1.3178666932321966062e285"); check(1476599377, "-2.14191393656148625995e+305", GMP_RNDD, - "-6.8938315017943889615e-297"); + "-6.8938315017943889615e-297"); tests_end_mpfr (); return 0; diff --git a/tests/tui_pow.c b/tests/tui_pow.c index 9904fe359..54f9d801c 100644 --- a/tests/tui_pow.c +++ b/tests/tui_pow.c @@ -64,7 +64,7 @@ test1 (void) if (mpfr_cmp (z, a) || res1 != res2) { printf ("Error for ui_pow_ui for 17^42\n" - "Inexact1 = %d Inexact2 = %d\n", res1, res2); + "Inexact1 = %d Inexact2 = %d\n", res1, res2); mpfr_dump (z); mpfr_dump (a); exit (1); @@ -244,13 +244,13 @@ main (int argc, char *argv[]) { mpfr_set_prec (x, prec); for (n=0; n