diff options
author | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-01-09 16:00:54 +0000 |
---|---|---|
committer | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-01-09 16:00:54 +0000 |
commit | 21249c6b35c1ef09485172cb22598a1c78a2d151 (patch) | |
tree | c130d87f19bfd8807b624a985c6bf34a45499835 /tests | |
parent | 0f61bc59c3dedca12d28706db41b52d5da474edb (diff) | |
download | mpfr-21249c6b35c1ef09485172cb22598a1c78a2d151.tar.gz |
Update the tests to reduce the use of floats.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2620 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rw-r--r-- | tests/cmp_str.c | 36 | ||||
-rw-r--r-- | tests/tadd.c | 1 | ||||
-rw-r--r-- | tests/tcbrt.c | 4 | ||||
-rw-r--r-- | tests/tcheck.c | 4 | ||||
-rw-r--r-- | tests/tgmpop.c | 24 | ||||
-rw-r--r-- | tests/tsqrt.c | 314 | ||||
-rw-r--r-- | tests/tsqrt_ui.c | 21 | ||||
-rw-r--r-- | tests/tsub.c | 13 | ||||
-rw-r--r-- | tests/tsub_ui.c | 51 | ||||
-rw-r--r-- | tests/tswap.c | 6 | ||||
-rw-r--r-- | tests/ttan.c | 6 | ||||
-rw-r--r-- | tests/ttrunc.c | 59 | ||||
-rw-r--r-- | tests/tui_div.c | 47 | ||||
-rw-r--r-- | tests/tui_sub.c | 69 |
15 files changed, 324 insertions, 333 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 884c60a9e..d31eb8c82 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -8,7 +8,7 @@ LDADD = libfrtests.a $(MPFR_LIBM) $(top_builddir)/libmpfr.a @LDADD@ INCLUDES = -I$(top_srcdir) @INCLUDES@ check_LIBRARIES = libfrtests.a -libfrtests_a_SOURCES = memory.c rnd_mode.c tests.c +libfrtests_a_SOURCES = memory.c rnd_mode.c tests.c cmp_str.c EXTRA_libfrtests_a_SOURCES = amd64.asm x86.asm libfrtests_a_DEPENDENCIES = $(TESTS_ASM_OBJECTS) libfrtests_a_LIBADD = $(libfrtests_a_DEPENDENCIES) diff --git a/tests/cmp_str.c b/tests/cmp_str.c new file mode 100644 index 000000000..e59f0ae01 --- /dev/null +++ b/tests/cmp_str.c @@ -0,0 +1,36 @@ +/* mpfr_cmp_str -- compare a floating-point number with a string. + +Copyright 2004 Free Software Foundation, Inc. + +This file is part of the MPFR Library. + +The MPFR Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The MPFR Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the MPFR Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include "mpfr-test.h" + +int mpfr_cmp_str(mpfr_srcptr x, const char *s, int base, mp_rnd_t rnd) +{ + mpfr_t y; + int res; + + mpfr_init2(y, MPFR_PREC(x) ); + mpfr_set_str(y, s, base, rnd); + res = mpfr_cmp(x,y); + mpfr_clear(y); + return res; +} + + diff --git a/tests/tadd.c b/tests/tadd.c index 44ec8c60f..6ef4f8d60 100644 --- a/tests/tadd.c +++ b/tests/tadd.c @@ -24,7 +24,6 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <float.h> -#include <time.h> #include "mpfr-test.h" diff --git a/tests/tcbrt.c b/tests/tcbrt.c index d6ee3f034..e1cfa8aef 100644 --- a/tests/tcbrt.c +++ b/tests/tcbrt.c @@ -1,6 +1,6 @@ /* Test file for mpfr_cbrt. -Copyright 2002, 2003 Free Software Foundation, Inc. +Copyright 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -38,7 +38,7 @@ main (void) mpfr_set_prec (x, 53); mpfr_set_str (x, "8.39005285514734966412e-01", 10, GMP_RNDN); mpfr_cbrt (x, x, GMP_RNDN); - if (mpfr_get_d1 (x) != 9.43166207799662426048e-01) + if (mpfr_cmp_str1(x, "9.43166207799662426048e-01")) { printf ("Error (1)\n"); exit (1); diff --git a/tests/tcheck.c b/tests/tcheck.c index 62927209a..ffe65a6d8 100644 --- a/tests/tcheck.c +++ b/tests/tcheck.c @@ -1,6 +1,6 @@ /* Test file for mpfr_check. -Copyright 2003 Free Software Foundation. +Copyright 2003, 2004 Free Software Foundation. This file is part of the MPFR Library. @@ -24,7 +24,7 @@ MA 02111-1307, USA. */ #include "mpfr-test.h" -#define ERROR(s) fprintf(stderr, "mpfr_check failed " s " Prec=%lu\n", pr), abort() +#define ERROR(s) printf("mpfr_check failed " s " Prec=%lu\n", pr), abort() int main (void) diff --git a/tests/tgmpop.c b/tests/tgmpop.c index af641ca8f..299184b29 100644 --- a/tests/tgmpop.c +++ b/tests/tgmpop.c @@ -279,22 +279,22 @@ main (int argc, char *argv[]) { tests_start_mpfr (); - test_genericz (2, 200, 100, mpfr_add_z, "add"); - test_genericz (2, 200, 100, mpfr_sub_z, "sub"); - test_genericz (2, 200, 100, mpfr_mul_z, "mul"); - test_genericz (2, 200, 100, mpfr_div_z, "div"); + test_genericz (2, 150, 100, mpfr_add_z, "add"); + test_genericz (2, 150, 100, mpfr_sub_z, "sub"); + test_genericz (2, 150, 100, mpfr_mul_z, "mul"); + test_genericz (2, 150, 100, mpfr_div_z, "div"); test_specialz (mpfr_add_z, mpz_add, "add"); test_specialz (mpfr_sub_z, mpz_sub, "sub"); test_specialz (mpfr_mul_z, mpz_mul, "mul"); - test_genericq (2, 200, 100, mpfr_add_q, "add"); - test_genericq (2, 200, 100, mpfr_sub_q, "sub"); - test_genericq (2, 200, 100, mpfr_mul_q, "mul"); - test_genericq (2, 200, 100, mpfr_div_q, "div"); - test_specialq (2, 200, 100, mpfr_mul_q, mpq_mul, "mul"); - test_specialq (2, 200, 100, mpfr_div_q, mpq_div, "div"); - test_specialq (2, 200, 100, mpfr_add_q, mpq_add, "add"); - test_specialq (2, 200, 100, mpfr_sub_q, mpq_sub, "sub"); + test_genericq (2, 150, 100, mpfr_add_q, "add"); + test_genericq (2, 150, 100, mpfr_sub_q, "sub"); + test_genericq (2, 150, 100, mpfr_mul_q, "mul"); + test_genericq (2, 150, 100, mpfr_div_q, "div"); + test_specialq (2, 150, 100, mpfr_mul_q, mpq_mul, "mul"); + test_specialq (2, 150, 100, mpfr_div_q, mpq_div, "div"); + test_specialq (2, 150, 100, mpfr_add_q, mpq_add, "add"); + test_specialq (2, 150, 100, mpfr_sub_q, mpq_sub, "sub"); tests_end_mpfr (); return 0; diff --git a/tests/tsqrt.c b/tests/tsqrt.c index f1900030b..d73a7b375 100644 --- a/tests/tsqrt.c +++ b/tests/tsqrt.c @@ -1,6 +1,6 @@ /* Test file for mpfr_sqrt. -Copyright 1999, 2001, 2002, 2003 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -21,74 +21,66 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include <time.h> #include "mpfr-test.h" -#define check(a,r) check3(a,r,-1.0) - -int maxulp=0; - static void -check3 (double a, mp_rnd_t rnd_mode, double Q) +check3 (const char *as, mp_rnd_t rnd_mode, const char *qs) { mpfr_t q; - double Q2; - int u; mpfr_init2 (q, 53); - mpfr_set_d (q, a, rnd_mode); + mpfr_set_str1 (q, as); mpfr_sqrt (q, q, rnd_mode); - Q2 = mpfr_get_d1 (q); - if (Q!=Q2 && !(Isnan(Q) && Isnan(Q2))) + if (mpfr_cmp_str1 (q, qs) ) { - u = ulp (Q2,Q); - printf ("mpfr_sqrt failed for a=%1.20e, rnd_mode=%s\n", - a, mpfr_print_rnd_mode (rnd_mode)); - printf ("expected sqrt is %1.20e, got %1.20e (%d ulp)\n",Q,Q2,u); - mpfr_clear (q); + printf ("mpfr_sqrt failed for a=%s, rnd_mode=%s\n", + as, mpfr_print_rnd_mode (rnd_mode)); + printf ("expected sqrt is %s, got ",qs); + mpfr_out_str(stdout, 10, 0, q, GMP_RNDN); + putchar('\n'); exit (1); } mpfr_clear (q); } static void -check4 (double a, mp_rnd_t rnd_mode, char *Q) +check4 (const char *as, mp_rnd_t rnd_mode, const char *Qs) { - mpfr_t q, res; + mpfr_t q; - mpfr_init2(q, 53); mpfr_init2(res, 53); - mpfr_set_d(q, a, rnd_mode); + mpfr_init2(q, 53); + mpfr_set_str1 (q, as); mpfr_sqrt(q, q, rnd_mode); - mpfr_set_str(res, Q, 16, GMP_RNDN); - if (mpfr_cmp(q, res)) + if (mpfr_cmp_str (q, Qs, 16, GMP_RNDN)) { - printf("mpfr_sqrt failed for a=%1.20e, rnd_mode=%s\n", - a, mpfr_print_rnd_mode(rnd_mode)); - printf("expected "); mpfr_print_binary(res); puts (""); - printf("got "); mpfr_print_binary(q); puts (""); - mpfr_clear(q); mpfr_clear(res); + printf("mpfr_sqrt failed for a=%s, rnd_mode=%s\n", + as, mpfr_print_rnd_mode(rnd_mode)); + printf("expected "); + mpfr_out_str(stdout, 16, 0, q, GMP_RNDN); + printf("\ngot %s\n", Qs); + mpfr_clear(q); exit(1); } - mpfr_clear(res); mpfr_clear(q); } static void -check24 (float a, mp_rnd_t rnd_mode, float Q) +check24 (const char *as, mp_rnd_t rnd_mode, const char *qs) { - mpfr_t q; float Q2; + mpfr_t q; mpfr_init2(q, 24); - mpfr_set_d(q, a, rnd_mode); + mpfr_set_str1(q, as); mpfr_sqrt(q, q, rnd_mode); - Q2 = mpfr_get_d1 (q); - if (Q!=Q2) { - printf("mpfr_sqrt failed for a=%1.10e, prec=24, rnd_mode=%s\n", - a, mpfr_print_rnd_mode(rnd_mode)); - printf("expected sqrt is %1.10e, got %1.10e\n",Q,Q2); - exit(1); - } + 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)); + printf("expected sqrt is %s, got ",qs); + mpfr_out_str(stdout, 10, 0, q, GMP_RNDN); + exit(1); + } mpfr_clear(q); } @@ -97,51 +89,49 @@ check24 (float a, mp_rnd_t rnd_mode, float Q) static void check_float (void) { - float b = 8388608.0; /* 2^23 */ - - check24(b*8388610.0, GMP_RNDN, 8.388609e6); - check24(b*2.0*16777214.0, GMP_RNDN, 1.6777215e7); - check24(b*8388612.0, GMP_RNDN, 8.388610e6); - check24(b*2.0*16777212.0, GMP_RNDN, 1.6777214e7); - check24(b*11946704.0, GMP_RNDN, 1.0010805e7); - check24(b*14321479.0, GMP_RNDN, 1.0960715e7); - check24(b*2.0*13689673.0, GMP_RNDN, 1.5155019e7); - check24(b*8388614.0, GMP_RNDN, 8.388611e6); - check24(b*2.0*16777210.0, GMP_RNDN, 1.6777213e7); - check24(b*10873622.0, GMP_RNDN, 9.550631e6); - - check24(b*8388610.0, GMP_RNDZ, 8.388608e6); - check24(b*2.0*16777214.0, GMP_RNDZ, 1.6777214e7); - check24(b*8388612.0, GMP_RNDZ, 8.388609e6); - check24(b*2.0*16777212.0, GMP_RNDZ, 1.6777213e7); - check24(b*11946704.0, GMP_RNDZ, 1.0010805e7); - check24(b*14321479.0, GMP_RNDZ, 1.0960715e7); - check24(b*2.0*13689673.0, GMP_RNDZ, 1.5155019e7); - check24(b*8388614.0, GMP_RNDZ, 8.38861e6); - check24(b*2.0*16777210.0, GMP_RNDZ, 1.6777212e7); - check24(b*10873622.0, GMP_RNDZ, 9.550631e6); - - check24(b*8388610.0, GMP_RNDU, 8.388609e6); - check24(b*2.0*16777214.0, GMP_RNDU, 1.6777215e7); - check24(b*8388612.0, GMP_RNDU, 8.388610e6); - check24(b*2.0*16777212.0, GMP_RNDU, 1.6777214e7); - check24(b*11946704.0, GMP_RNDU, 1.0010806e7); - check24(b*14321479.0, GMP_RNDU, 1.0960716e7); - check24(b*2.0*13689673.0, GMP_RNDU, 1.515502e7); - check24(b*8388614.0, GMP_RNDU, 8.388611e6); - check24(b*2.0*16777210.0, GMP_RNDU, 1.6777213e7); - check24(b*10873622.0, GMP_RNDU, 9.550632e6); - - check24(b*8388610.0, GMP_RNDD, 8.388608e6); - check24(b*2.0*16777214.0, GMP_RNDD, 1.6777214e7); - check24(b*8388612.0, GMP_RNDD, 8.388609e6); - check24(b*2.0*16777212.0, GMP_RNDD, 1.6777213e7); - check24(b*11946704.0, GMP_RNDD, 1.0010805e7); - check24(b*14321479.0, GMP_RNDD, 1.0960715e7); - check24(b*2.0*13689673.0, GMP_RNDD, 1.5155019e7); - check24(b*8388614.0, GMP_RNDD, 8.38861e6); - check24(b*2.0*16777210.0, GMP_RNDD, 1.6777212e7); - check24(b*10873622.0, GMP_RNDD, 9.550631e6); + check24("70368760954880.0", GMP_RNDN, "8.388609e6"); + check24("281474943156224.0", GMP_RNDN, "1.6777215e7"); + check24("70368777732096.0", GMP_RNDN, "8.388610e6"); + check24("281474909601792.0", GMP_RNDN, "1.6777214e7"); + check24("100216216748032.0", GMP_RNDN, "1.0010805e7"); + check24("120137273311232.0", GMP_RNDN, "1.0960715e7"); + check24("229674600890368.0", GMP_RNDN, "1.5155019e7"); + check24("70368794509312.0", GMP_RNDN, "8.388611e6"); + check24("281474876047360.0", GMP_RNDN, "1.6777213e7"); + check24("91214552498176.0", GMP_RNDN, "9.550631e6"); + + check24("70368760954880.0", GMP_RNDZ, "8.388608e6"); + check24("281474943156224.0", GMP_RNDZ, "1.6777214e7"); + check24("70368777732096.0", GMP_RNDZ, "8.388609e6"); + check24("281474909601792.0", GMP_RNDZ, "1.6777213e7"); + check24("100216216748032.0", GMP_RNDZ, "1.0010805e7"); + check24("120137273311232.0", GMP_RNDZ, "1.0960715e7"); + check24("229674600890368.0", GMP_RNDZ, "1.5155019e7"); + check24("70368794509312.0", GMP_RNDZ, "8.38861e6"); + check24("281474876047360.0", GMP_RNDZ, "1.6777212e7"); + check24("91214552498176.0", GMP_RNDZ, "9.550631e6"); + + check24("70368760954880.0", GMP_RNDU, "8.388609e6"); + check24("281474943156224.0",GMP_RNDU, "1.6777215e7"); + check24("70368777732096.0", GMP_RNDU, "8.388610e6"); + check24("281474909601792.0", GMP_RNDU, "1.6777214e7"); + check24("100216216748032.0", GMP_RNDU, "1.0010806e7"); + check24("120137273311232.0", GMP_RNDU, "1.0960716e7"); + check24("229674600890368.0", GMP_RNDU, "1.515502e7"); + check24("70368794509312.0", GMP_RNDU, "8.388611e6"); + check24("281474876047360.0", GMP_RNDU, "1.6777213e7"); + check24("91214552498176.0", GMP_RNDU, "9.550632e6"); + + check24("70368760954880.0", GMP_RNDD, "8.388608e6"); + check24("281474943156224.0", GMP_RNDD, "1.6777214e7"); + check24("70368777732096.0", GMP_RNDD, "8.388609e6"); + check24("281474909601792.0", GMP_RNDD, "1.6777213e7"); + check24("100216216748032.0", GMP_RNDD, "1.0010805e7"); + check24("120137273311232.0", GMP_RNDD, "1.0960715e7"); + check24("229674600890368.0", GMP_RNDD, "1.5155019e7"); + check24("70368794509312.0", GMP_RNDD, "8.38861e6"); + check24("281474876047360.0", GMP_RNDD, "1.6777212e7"); + check24("91214552498176.0", GMP_RNDD, "9.550631e6"); } static void @@ -196,8 +186,9 @@ special (void) mpfr_sqrt (z, x, GMP_RNDN); if (mpfr_cmp_ui (z, 0) < 0) { - printf ("Error: square root of %e gives %e\n", - mpfr_get_d1 (x), mpfr_get_d1 (z)); + printf ("Error: square root of 1 gives "); + mpfr_print_binary(z); + putchar('\n'); exit (1); } @@ -304,12 +295,9 @@ check_nan (void) mpfr_clear (got); } -double five = 5.0; - int main (void) { - double a; mp_prec_t p; int k; @@ -323,68 +311,100 @@ main (void) special (); check_float(); - check3 (-0.0, GMP_RNDN, 0.0); - check4 (6.37983013646045901440e+32, GMP_RNDN, "5.9bc5036d09e0c@13"); - check4 (1.0, GMP_RNDN, "1"); - check4 (1.0, GMP_RNDZ, "1"); - check4 (3.725290298461914062500000e-9, GMP_RNDN, "4@-4"); - check4 (3.725290298461914062500000e-9, GMP_RNDZ, "4@-4"); - a = 1190456976439861.0; - check4 (a, GMP_RNDZ, "2.0e7957873529a@6"); - check4 (1024.0*a, GMP_RNDZ, "4.1cf2af0e6a534@7"); + check3 ("-0.0", GMP_RNDN, "0.0"); + check4 ("6.37983013646045901440e+32", GMP_RNDN, "5.9bc5036d09e0c@13"); + check4 ("1.0", GMP_RNDN, "1"); + check4 ("1.0", GMP_RNDZ, "1"); + check4 ("3.725290298461914062500000e-9", GMP_RNDN, "4@-4"); + check4 ("3.725290298461914062500000e-9", GMP_RNDZ, "4@-4"); + check4 ("1190456976439861.0", GMP_RNDZ, "2.0e7957873529a@6"); + check4 ("1219027943874417664.0", GMP_RNDZ, "4.1cf2af0e6a534@7"); /* the following examples are bugs in Cygnus compiler/system, found by Fabrice Rouillier while porting mpfr to Windows */ - check4 (9.89438396044940256501e-134, GMP_RNDU, "8.7af7bf0ebbee@-56"); - check4 (7.86528588050363751914e+31, GMP_RNDZ, "1.f81fc40f32062@13"); - check4 (0.99999999999999988897, GMP_RNDN, "f.ffffffffffff8@-1"); - check4 (1.00000000000000022204, GMP_RNDN, "1"); + check4 ("9.89438396044940256501e-134", GMP_RNDU, "8.7af7bf0ebbee@-56"); + check4 ("7.86528588050363751914e+31", GMP_RNDZ, "1.f81fc40f32062@13"); + check4 ("0.99999999999999988897", GMP_RNDN, "f.ffffffffffff8@-1"); + check4 ("1.00000000000000022204", GMP_RNDN, "1"); /* the following examples come from the paper "Number-theoretic Test Generation for Directed Rounding" from Michael Parks, Table 4 */ - a = 4503599627370496.0; /* 2^52 */ - - check4 (a*2.0*8732221479794286.0, GMP_RNDN, "1.f81fc40f32063@13"); - check4 (a*8550954388695124.0, GMP_RNDN, "1.60c012a92fc65@13"); - check4 (a*7842344481681754.0, GMP_RNDN, "1.51d17526c7161@13"); - check4 (a*5935035262218600.0, GMP_RNDN, "1.25e19302f7e51@13"); - check4 (a*5039650445085418.0, GMP_RNDN, "1.0ecea7dd2ec3d@13"); - check4 (a*5039721545366078.0, GMP_RNDN, "1.0ecf250e8e921@13"); - check4 (a*8005963117781324.0, GMP_RNDN, "1.5552f3eedcf33@13"); - check4 (a*6703494707970582.0, GMP_RNDN, "1.3853ee10c9c99@13"); - check4 (a*8010323124937260.0, GMP_RNDN, "1.556abe212b56f@13"); - check4 (a*2.0*8010776873384260.0, GMP_RNDN, "1.e2d9a51977e6e@13"); - - check4 (a*2.0*8732221479794286.0, GMP_RNDZ, "1.f81fc40f32062@13"); - check4 (a*8550954388695124.0, GMP_RNDZ, "1.60c012a92fc64@13"); - check4 (a*7842344481681754.0, GMP_RNDZ, "1.51d17526c716@13"); - check4 (a*5935035262218600.0, GMP_RNDZ, "1.25e19302f7e5@13"); - check4 (a*5039650445085418.0, GMP_RNDZ, "1.0ecea7dd2ec3c@13"); - check4 (a*5039721545366078.0, GMP_RNDZ, "1.0ecf250e8e92@13"); - check4 (a*8005963117781324.0, GMP_RNDZ, "1.5552f3eedcf32@13"); - check4 (a*6703494707970582.0, GMP_RNDZ, "1.3853ee10c9c98@13"); - check4 (a*8010323124937260.0, GMP_RNDZ, "1.556abe212b56e@13"); - check4 (a*2.0*8010776873384260.0, GMP_RNDZ, "1.e2d9a51977e6d@13"); - - check4 (a*2.0*8732221479794286.0, GMP_RNDU, "1.f81fc40f32063@13"); - check4 (a*8550954388695124.0, GMP_RNDU, "1.60c012a92fc65@13"); - check4 (a*7842344481681754.0, GMP_RNDU, "1.51d17526c7161@13"); - check4 (a*5935035262218600.0, GMP_RNDU, "1.25e19302f7e51@13"); - check4 (a*5039650445085418.0, GMP_RNDU, "1.0ecea7dd2ec3d@13"); - check4 (a*5039721545366078.0, GMP_RNDU, "1.0ecf250e8e921@13"); - check4 (a*8005963117781324.0, GMP_RNDU, "1.5552f3eedcf33@13"); - check4 (a*6703494707970582.0, GMP_RNDU, "1.3853ee10c9c99@13"); - check4 (a*8010323124937260.0, GMP_RNDU, "1.556abe212b56f@13"); - check4 (a*2.0*8010776873384260.0, GMP_RNDU, "1.e2d9a51977e6e@13"); - - check4 (a*2.0*8732221479794286.0, GMP_RNDD, "1.f81fc40f32062@13"); - check4 (a*8550954388695124.0, GMP_RNDD, "1.60c012a92fc64@13"); - check4 (a*7842344481681754.0, GMP_RNDD, "1.51d17526c716@13"); - check4 (a*5935035262218600.0, GMP_RNDD, "1.25e19302f7e5@13"); - check4 (a*5039650445085418.0, GMP_RNDD, "1.0ecea7dd2ec3c@13"); - check4 (a*5039721545366078.0, GMP_RNDD, "1.0ecf250e8e92@13"); - check4 (a*8005963117781324.0, GMP_RNDD, "1.5552f3eedcf32@13"); - check4 (a*6703494707970582.0, GMP_RNDD, "1.3853ee10c9c98@13"); - check4 (a*8010323124937260.0, GMP_RNDD, "1.556abe212b56e@13"); - check4 (a*2.0*8010776873384260.0, GMP_RNDD, "1.e2d9a51977e6d@13"); + + check4 ("78652858805036375191418371571712.0", GMP_RNDN, + "1.f81fc40f32063@13"); + check4 ("38510074998589467860312736661504.0", GMP_RNDN, + "1.60c012a92fc65@13"); + check4 ("35318779685413012908190921129984.0", GMP_RNDN, + "1.51d17526c7161@13"); + check4 ("26729022595358440976973142425600.0", GMP_RNDN, + "1.25e19302f7e51@13"); + check4 ("22696567866564242819241453027328.0", GMP_RNDN, + "1.0ecea7dd2ec3d@13"); + check4 ("22696888073761729132924856434688.0", GMP_RNDN, + "1.0ecf250e8e921@13"); + check4 ("36055652513981905145251657416704.0", GMP_RNDN, + "1.5552f3eedcf33@13"); + check4 ("30189856268896404997497182748672.0", GMP_RNDN, + "1.3853ee10c9c99@13"); + check4 ("36075288240584711210898775080960.0", GMP_RNDN, + "1.556abe212b56f@13"); + check4 ("72154663483843080704304789585920.0", GMP_RNDN, + "1.e2d9a51977e6e@13"); + + check4 ("78652858805036375191418371571712.0", GMP_RNDZ, + "1.f81fc40f32062@13"); + check4 ("38510074998589467860312736661504.0", GMP_RNDZ, + "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"); + check4 ("22696888073761729132924856434688.0", GMP_RNDZ, "1.0ecf250e8e92@13"); + check4 ("36055652513981905145251657416704.0", GMP_RNDZ, + "1.5552f3eedcf32@13"); + check4 ("30189856268896404997497182748672.0", GMP_RNDZ, + "1.3853ee10c9c98@13"); + check4 ("36075288240584711210898775080960.0", GMP_RNDZ, + "1.556abe212b56e@13"); + check4 ("72154663483843080704304789585920.0", GMP_RNDZ, + "1.e2d9a51977e6d@13"); + + check4 ("78652858805036375191418371571712.0", GMP_RNDU, + "1.f81fc40f32063@13"); + check4 ("38510074998589467860312736661504.0", GMP_RNDU, + "1.60c012a92fc65@13"); + check4 ("35318779685413012908190921129984.0", GMP_RNDU, + "1.51d17526c7161@13"); + check4 ("26729022595358440976973142425600.0", GMP_RNDU, + "1.25e19302f7e51@13"); + check4 ("22696567866564242819241453027328.0", GMP_RNDU, + "1.0ecea7dd2ec3d@13"); + check4 ("22696888073761729132924856434688.0", GMP_RNDU, + "1.0ecf250e8e921@13"); + check4 ("36055652513981905145251657416704.0", GMP_RNDU, + "1.5552f3eedcf33@13"); + check4 ("30189856268896404997497182748672.0", GMP_RNDU, + "1.3853ee10c9c99@13"); + check4 ("36075288240584711210898775080960.0", GMP_RNDU, + "1.556abe212b56f@13"); + check4 ("72154663483843080704304789585920.0", GMP_RNDU, + "1.e2d9a51977e6e@13"); + + check4 ("78652858805036375191418371571712.0", GMP_RNDD, + "1.f81fc40f32062@13"); + check4 ("38510074998589467860312736661504.0", GMP_RNDD, + "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"); + check4 ("22696888073761729132924856434688.0", GMP_RNDD, "1.0ecf250e8e92@13"); + check4 ("36055652513981905145251657416704.0", GMP_RNDD, + "1.5552f3eedcf32@13"); + check4 ("30189856268896404997497182748672.0", GMP_RNDD, + "1.3853ee10c9c98@13"); + check4 ("36075288240584711210898775080960.0", GMP_RNDD, + "1.556abe212b56e@13"); + check4 ("72154663483843080704304789585920.0", GMP_RNDD, + "1.e2d9a51977e6d@13"); tests_end_mpfr (); return 0; diff --git a/tests/tsqrt_ui.c b/tests/tsqrt_ui.c index d3ae201a4..30ef866a7 100644 --- a/tests/tsqrt_ui.c +++ b/tests/tsqrt_ui.c @@ -21,43 +21,34 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include <time.h> #include "mpfr-test.h" -int maxulp=0; - static void -check (unsigned long a, mp_rnd_t rnd_mode, double Q) +check (unsigned long a, mp_rnd_t rnd_mode, const char *qs) { mpfr_t q; - double Q2; - int u; mpfr_init2 (q, 53); mpfr_sqrt_ui (q, a, rnd_mode); - Q2 = mpfr_get_d1 (q); - if (Q != Q2 && !(Isnan(Q) && Isnan(Q2))) + if (mpfr_cmp_str1 (q, qs)) { - u = ulp (Q2,Q); printf ("mpfr_sqrt_ui failed for a=%lu, rnd_mode=%s\n", a, mpfr_print_rnd_mode (rnd_mode)); - printf ("sqrt gives %1.20e, mpfr_sqrt_ui gives %1.20e (%d ulp)\n", - Q, Q2, u); + printf ("sqrt gives %s, mpfr_sqrt_ui gives ", qs); + mpfr_out_str(stdout, 10, 0, q, GMP_RNDN); exit (1); } mpfr_clear (q); } -double five = 5.0; - int main (void) { tests_start_mpfr (); - check (0, GMP_RNDN, 0.0); - check (2116118, GMP_RNDU, 1.45468828276026215e3); + check (0, GMP_RNDN, "0.0"); + check (2116118, GMP_RNDU, "1.45468828276026215e3"); tests_end_mpfr (); return 0; diff --git a/tests/tsub.c b/tests/tsub.c index 0dc91b9f8..d94d77a7b 100644 --- a/tests/tsub.c +++ b/tests/tsub.c @@ -28,7 +28,6 @@ static void check_diverse (void) { mpfr_t x, y, z; - double res, got; int inexact; mpfr_init (x); @@ -180,15 +179,15 @@ check_diverse (void) mpfr_set_prec (x, 53); mpfr_set_prec (y, 53); mpfr_set_prec (z, 53); - mpfr_set_str (x, "1.229318102e+09", 10, GMP_RNDN); - mpfr_set_str (y, "2.32221184180698677665e+05", 10, GMP_RNDN); + mpfr_set_str1 (x, "1.229318102e+09"); + mpfr_set_str1 (y, "2.32221184180698677665e+05"); mpfr_sub (z, x, y, GMP_RNDN); - res = 1229085880.815819263458251953125; - got = mpfr_get_d1 (z); - if (got != res) + if (mpfr_cmp_str1 (z, "1229085880.815819263458251953125")) { printf ("Error in mpfr_sub (1.22e9 - 2.32e5)\n"); - printf ("expected %1.20e, got %1.20e\n", res, got); + printf ("expected 1229085880.815819263458251953125, got "); + mpfr_out_str(stdout, 10, 0, z, GMP_RNDN); + putchar('\n'); exit (1); } diff --git a/tests/tsub_ui.c b/tests/tsub_ui.c index d58315fc3..926f4addb 100644 --- a/tests/tsub_ui.c +++ b/tests/tsub_ui.c @@ -1,6 +1,6 @@ /* Test file for mpfr_sub_ui -Copyright 2000, 2001, 2002, 2003 Free Software Foundation. +Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation. This file is part of the MPFR Library. @@ -22,36 +22,27 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <float.h> -#include <time.h> #include "mpfr-test.h" -#define check(x,y,r) check3(x,y,r,0.0) - -/* checks that x+y gives the same results in double - and with mpfr with 53 bits of precision */ +/* checks that x-y gives the right results with 53 bits of precision */ static void -check3 (double x, unsigned long y, mp_rnd_t rnd_mode, double z1) +check3 (const char *xs, unsigned long y, mp_rnd_t rnd_mode, const char *zs) { - double z2; mpfr_t xx,zz; - mpfr_init (xx); - mpfr_init (zz); - mpfr_set_prec (xx, 53); - mpfr_set_prec (zz, 53); - mpfr_set_d (xx, x, rnd_mode); + mpfr_inits2 (53, xx, zz, NULL); + mpfr_set_str1 (xx, xs); mpfr_sub_ui (zz, xx, y, rnd_mode); - z2 = mpfr_get_d1 (zz); - if (z1!=z2 && !(Isnan(z1) && Isnan(z2))) + if (mpfr_cmp_str1(zz, zs)) { - printf ("expected sum is %1.20e, got %1.20e\n",z1,z2); - printf ("mpfr_sub_ui failed for x=%1.20e y=%lu with rnd_mode=%s\n", - x, y, mpfr_print_rnd_mode (rnd_mode)); + printf ("expected sum is %s, got ", zs); + mpfr_print_binary(zz); + printf ("\nmpfr_sub_ui failed for x=%s y=%lu with rnd_mode=%s\n", + xs, y, mpfr_print_rnd_mode (rnd_mode)); exit (1); } - mpfr_clear (xx); - mpfr_clear (zz); + mpfr_clears (xx, zz, NULL); } /* FastTwoSum: if EXP(x) >= EXP(y), u = o(x+y), v = o(u-x), w = o(y-v), @@ -65,21 +56,17 @@ check_two_sum (mp_prec_t p) mp_rnd_t rnd; int inexact; - mpfr_init2 (y, p); - mpfr_init2 (u, p); - mpfr_init2 (v, p); - mpfr_init2 (w, p); + mpfr_inits2 (p, y, u, v, w, NULL); do { x = randlimb (); } while (x < 1); mpfr_random (y); - rnd = randlimb () % 4; rnd = GMP_RNDN; - inexact = mpfr_sub_ui (u, y, x, GMP_RNDN); - mpfr_add_ui (v, u, x, GMP_RNDN); - mpfr_sub (w, v, y, GMP_RNDN); + inexact = mpfr_sub_ui (u, y, x, rnd); + mpfr_add_ui (v, u, x, rnd); + mpfr_sub (w, v, y, rnd); /* as u - (y-x) = w, we should have inexact and w of same sign */ if (((inexact == 0) && mpfr_cmp_ui (w, 0)) || ((inexact > 0) && (mpfr_cmp_ui (w, 0) <= 0)) || @@ -95,10 +82,7 @@ check_two_sum (mp_prec_t p) printf ("inexact = %d\n", inexact); exit (1); } - mpfr_clear (y); - mpfr_clear (u); - mpfr_clear (v); - mpfr_clear (w); + mpfr_clears (y, u, v, w, NULL); } static void @@ -144,7 +128,8 @@ main (int argc, char *argv[]) for (k=0; k<200; k++) check_two_sum (p); - check3 (0.9999999999, 1, GMP_RNDN, -56295.0 / 562949953421312.0); + check3 ("0.9999999999", 1, GMP_RNDN, + "-10000000827403709990903735160827636718750e-50"); tests_end_mpfr (); return 0; diff --git a/tests/tswap.c b/tests/tswap.c index 5edda71e2..5b2fbae5d 100644 --- a/tests/tswap.c +++ b/tests/tswap.c @@ -1,6 +1,6 @@ /* Test file for mpfr_swap. -Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -34,10 +34,10 @@ main (void) mpfr_init2 (u, 24); mpfr_init2 (v, 53); mpfr_set_ui (u, 16777215, GMP_RNDN); /* 2^24 - 1 */ - mpfr_set_str (v, "9007199254740991.0", 10, GMP_RNDN); /* 2^53 - 1 */ + mpfr_set_str1 (v, "9007199254740991.0"); /* 2^53 - 1 */ mpfr_swap (u, v); mpfr_swap (u, v); - if (mpfr_cmp_ui (u, 16777215) || (mpfr_get_d1 (v) != 9007199254740991.0)) + if (mpfr_cmp_ui (u, 16777215) || mpfr_cmp_str1 (v, "9007199254740991.0")) { printf ("Error in mpfr_swap\n"); exit (1); diff --git a/tests/ttan.c b/tests/ttan.c index cbc1c678f..81dfdee42 100644 --- a/tests/ttan.c +++ b/tests/ttan.c @@ -1,6 +1,6 @@ /* Test file for mpfr_tan. -Copyright 2001, 2002, 2003 Free Software Foundation, Inc. +Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -83,7 +83,9 @@ main(int argc, char *argv[]) if (mpfr_cmp_ui_2exp(x, 1, -1)) { printf ("mpfr_tan(0.5, GMP_RNDD) failed\n" - "expected 0.5, got %f\n", mpfr_get_d1 (x)); + "expected 0.5, got"); + mpfr_print_binary(x); + putchar('\n'); exit (1); } diff --git a/tests/ttrunc.c b/tests/ttrunc.c index f1cf9d20e..3409ebc0b 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, 2003 Free Software Foundation, Inc. +Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -29,24 +29,20 @@ 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(t2, SIZEX); + mpfr_inits2(SIZEX, x, y, z, t, y2, z2, t2, NULL); - mpfr_set_str (x, "0.5", 10, GMP_RNDN); + mpfr_set_str1 (x, "0.5"); mpfr_ceil(y, x); if (mpfr_cmp_ui (y, 1)) { - printf ("Error in mpfr_ceil for x=0.5: expected 1.0, got %f\n", - mpfr_get_d1 (y)); + printf ("Error in mpfr_ceil for x=0.5: expected 1.0, got "); + mpfr_print_binary(y); + putchar('\n'); exit (1); } @@ -54,8 +50,9 @@ main (void) mpfr_ceil(y, x); if (mpfr_cmp_ui(y,0)) { - printf ("Error in mpfr_ceil for x=0.0: expected 0.0, got %f\n", - mpfr_get_d1 (y)); + printf ("Error in mpfr_ceil for x=0.0: expected 0.0, got "); + mpfr_print_binary(y); + putchar('\n'); exit (1); } @@ -63,8 +60,9 @@ main (void) mpfr_ceil(y, x); if (mpfr_cmp_ui(y,1)) { - printf ("Error in mpfr_ceil for x=1.0: expected 1.0, got %f\n", - mpfr_get_d1 (y)); + printf ("Error in mpfr_ceil for x=1.0: expected 1.0, got "); + mpfr_print_binary(y); + putchar('\n'); exit (1); } @@ -99,13 +97,6 @@ main (void) 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); } @@ -117,13 +108,6 @@ main (void) 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); } @@ -135,26 +119,13 @@ main (void) 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); + mpfr_clears(x, y, z, t, y2, z2, t2, NULL); tests_end_mpfr (); return 0; diff --git a/tests/tui_div.c b/tests/tui_div.c index 961dc1f83..e59737652 100644 --- a/tests/tui_div.c +++ b/tests/tui_div.c @@ -1,6 +1,6 @@ /* Test file for mpfr_ui_div. -Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -21,32 +21,27 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include <time.h> #include "mpfr-test.h" -/* checks that y/x gives the same results in double - and with mpfr with 53 bits of precision */ +/* checks that y/x gives the right result with 53 bits of precision */ static void -check (unsigned long y, double x, mp_rnd_t rnd_mode, double z1) +check (unsigned long y, const char *xs, mp_rnd_t rnd_mode, const char *zs) { - double z2; mpfr_t xx, zz; - mpfr_init2 (xx, 53); - mpfr_init2 (zz, 53); - mpfr_set_d (xx, x, rnd_mode); + mpfr_inits2 (53, xx, zz, NULL); + mpfr_set_str1 (xx, xs); mpfr_ui_div (zz, y, xx, rnd_mode); - z2 = mpfr_get_d1 (zz); - if (z1 != z2 && !(Isnan(z1) && Isnan(z2))) + if (mpfr_cmp_str1(zz, zs)) { - printf ("expected quotient is %1.20e, got %1.20e\n", z1, z2); - printf ("mpfr_ui_div failed for y=%lu x=%1.20e with rnd_mode=%s\n", - y, x, mpfr_print_rnd_mode (rnd_mode)); + printf ("expected quotient is %s, got ", zs); + mpfr_out_str (stdout, 10, 0, zz, GMP_RNDN); + printf ("mpfr_ui_div failed for y=%lu x=%s with rnd_mode=%s\n", + y, xs, mpfr_print_rnd_mode (rnd_mode)); exit (1); } - mpfr_clear (xx); - mpfr_clear (zz); + mpfr_clears (xx, zz, NULL); } static void @@ -150,16 +145,16 @@ main (int argc, char *argv[]) check_nan (); check_inexact (); - check(948002822, 1.22191250737771397120e+20, GMP_RNDN, - 7.758352715731357946e-12); - check(1976245324, 1.25296395864546893357e+232, GMP_RNDZ, - 1.5772563211925444801e-223); - check(740454110, 2.11496253355831863313e+183, GMP_RNDZ, - 3.5010270784996976041e-175); - check(1690540942, 1.28278599852446657468e-276, GMP_RNDU, - 1.3178666932321966062e285); - check(1476599377, -2.14191393656148625995e+305, GMP_RNDD, - -6.8938315017943889615e-297); + check(948002822, "1.22191250737771397120e+20", GMP_RNDN, + "7.758352715731357946e-12"); + check(1976245324, "1.25296395864546893357e+232", GMP_RNDZ, + "1.5772563211925444801e-223"); + check(740454110, "2.11496253355831863313e+183", GMP_RNDZ, + "3.5010270784996976041e-175"); + check(1690540942, "1.28278599852446657468e-276", GMP_RNDU, + "1.3178666932321966062e285"); + check(1476599377, "-2.14191393656148625995e+305", GMP_RNDD, + "-6.8938315017943889615e-297"); tests_end_mpfr (); return 0; diff --git a/tests/tui_sub.c b/tests/tui_sub.c index 410f41d49..fc849b32a 100644 --- a/tests/tui_sub.c +++ b/tests/tui_sub.c @@ -125,28 +125,24 @@ special (void) mpfr_clear (res); } -/* checks that y/x gives the same results in double - and with mpfr with 53 bits of precision */ +/* checks that (y-x) gives the right results with 53 bits of precision */ static void -check (unsigned long y, double x, mp_rnd_t rnd_mode, double z1) +check (unsigned long y, const char *xs, mp_rnd_t rnd_mode, const char *zs) { - double z2; mpfr_t xx, zz; - mpfr_init2 (xx, 53); - mpfr_init2 (zz, 53); - mpfr_set_d (xx, x, rnd_mode); + mpfr_inits2 (53, xx, zz, NULL); + mpfr_set_str1 (xx, xs); mpfr_ui_sub (zz, y, xx, rnd_mode); - z2 = mpfr_get_d1 (zz); - if (z1 != z2 && !(Isnan(z1) && Isnan(z2))) + if (mpfr_cmp_str1 (zz, zs) ) { - printf ("expected difference is %1.20e, got %1.20e\n",z1,z2); - printf ("mpfr_ui_sub failed for y=%lu x=%1.20e with rnd_mode=%s\n", - y, x, mpfr_print_rnd_mode (rnd_mode)); + printf ("expected difference is %s, got\n",zs); + mpfr_out_str(stdout, 10, 0, zz, GMP_RNDN); + printf ("mpfr_ui_sub failed for y=%lu x=%s with rnd_mode=%s\n", + y, xs, mpfr_print_rnd_mode (rnd_mode)); exit (1); } - mpfr_clear (xx); - mpfr_clear (zz); + mpfr_clears (xx, zz, NULL); } /* if u = o(x-y), v = o(u-x), w = o(v+y), then x-y = u-w */ @@ -158,21 +154,17 @@ check_two_sum (mp_prec_t p) mp_rnd_t rnd; int inexact; - mpfr_init2 (y, p); - mpfr_init2 (u, p); - mpfr_init2 (v, p); - mpfr_init2 (w, p); + mpfr_inits2 (p, y, u, v, w, NULL); do { x = randlimb (); } while (x < 1); mpfr_random (y); - rnd = randlimb () % 4; rnd = GMP_RNDN; - inexact = mpfr_ui_sub (u, x, y, GMP_RNDN); - mpfr_sub_ui (v, u, x, GMP_RNDN); - mpfr_add (w, v, y, GMP_RNDN); + inexact = mpfr_ui_sub (u, x, y, rnd); + mpfr_sub_ui (v, u, x, rnd); + mpfr_add (w, v, y, rnd); /* as u = (x-y) + w, we should have inexact and w of same sign */ if (((inexact == 0) && mpfr_cmp_ui (w, 0)) || ((inexact > 0) && (mpfr_cmp_ui (w, 0) <= 0)) || @@ -188,10 +180,7 @@ check_two_sum (mp_prec_t p) printf ("inexact = %d\n", inexact); exit (1); } - mpfr_clear (y); - mpfr_clear (u); - mpfr_clear (v); - mpfr_clear (w); + mpfr_clears (y, u, v, w, NULL); } static void @@ -238,18 +227,22 @@ main (int argc, char *argv[]) for (k=0; k<100; k++) check_two_sum (p); - check(1196426492, 1.4218093058435347e-3, GMP_RNDN, 1.1964264919985781e9); - check(1092583421, -1.0880649218158844e9, GMP_RNDN, 2.1806483428158845901e9); - check(948002822, 1.22191250737771397120e+20, GMP_RNDN, - -1.2219125073682338611e20); - check(832100416, 4.68311314939691330000e-215, GMP_RNDD, - 8.3210041599999988079e8); - check(1976245324, 1.25296395864546893357e+232, GMP_RNDZ, - -1.2529639586454686577e232); - check(2128997392, -1.08496826129284207724e+187, GMP_RNDU, - 1.0849682612928422704e187); - check(293607738, -1.9967571564050541e-5, GMP_RNDU, 2.9360773800002003e8); - check(354270183, 2.9469161763489528e3, GMP_RNDN, 3.5426723608382362e8); + check(1196426492, "1.4218093058435347e-3", GMP_RNDN, + "1.1964264919985781e9"); + check(1092583421, "-1.0880649218158844e9", GMP_RNDN, + "2.1806483428158845901e9"); + check(948002822, "1.22191250737771397120e+20", GMP_RNDN, + "-1.2219125073682338611e20"); + check(832100416, "4.68311314939691330000e-215", GMP_RNDD, + "8.3210041599999988079e8"); + check(1976245324, "1.25296395864546893357e+232", GMP_RNDZ, + "-1.2529639586454686577e232"); + check(2128997392, "-1.08496826129284207724e+187", GMP_RNDU, + "1.0849682612928422704e187"); + check(293607738, "-1.9967571564050541e-5", GMP_RNDU, + "2.9360773800002003e8"); + check(354270183, "2.9469161763489528e3", GMP_RNDN, + "3.5426723608382362e8"); tests_end_mpfr (); return 0; |