From 893d693deec8385835c1886bac11ea96ece1d608 Mon Sep 17 00:00:00 2001 From: vlefevre Date: Fri, 8 Mar 2013 00:28:01 +0000 Subject: [examples] Replaced the old rounding mode macros (GMP_RNDN, etc.) by the new ones (MPFR_RNDN, etc.) in the *.c files; updated ReadMe file. (merged changeset r8461 from the trunk) git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/3.1@8464 280ebfd0-de03-0410-8827-d642c229c3f4 --- examples/ReadMe | 3 --- examples/divworst.c | 10 +++++----- examples/rndo-add.c | 16 ++++++++-------- examples/sample.c | 14 +++++++------- examples/version.c | 2 +- 5 files changed, 21 insertions(+), 24 deletions(-) (limited to 'examples') diff --git a/examples/ReadMe b/examples/ReadMe index 734f27574..2e2af32c5 100644 --- a/examples/ReadMe +++ b/examples/ReadMe @@ -1,4 +1 @@ This directory contains simple examples. - -These examples currently use the old rounding mode macros (GMP_RNDN, etc.) -instead of the new ones, which are not compatible with MPFR 2.x. diff --git a/examples/divworst.c b/examples/divworst.c index 39e3895a0..dccfdb541 100644 --- a/examples/divworst.c +++ b/examples/divworst.c @@ -73,19 +73,19 @@ int main (int argc, char *argv[]) mpfr_inits2 (n, PRECN, (mpfr_ptr) 0); mpfr_init2 (t, p); - for (mpfr_set_ui_2exp (x, 1, -1, GMP_RNDN); + for (mpfr_set_ui_2exp (x, 1, -1, MPFR_RNDN); mpfr_get_exp (x) <= dmax; mpfr_nextabove (x)) - for (mpfr_set_ui_2exp (y, 1, -1, GMP_RNDN); + for (mpfr_set_ui_2exp (y, 1, -1, MPFR_RNDN); mpfr_get_exp (y) == 0; mpfr_nextabove (y)) { unsigned long rz, rn; - if (mpfr_sub (z, x, y, GMP_RNDZ) != 0) + if (mpfr_sub (z, x, y, MPFR_RNDZ) != 0) continue; /* x - y is not representable in precision n */ - rz = eval (x, y, z, t, GMP_RNDZ); - rn = eval (x, y, z, t, GMP_RNDN); + rz = eval (x, y, z, t, MPFR_RNDZ); + rn = eval (x, y, z, t, MPFR_RNDN); if (rz == rn) continue; mpfr_printf ("x = %.*Rb ; y = %.*Rb ; Z: %lu ; N: %lu\n", diff --git a/examples/rndo-add.c b/examples/rndo-add.c index 6ac74c954..2852c3b41 100644 --- a/examples/rndo-add.c +++ b/examples/rndo-add.c @@ -58,32 +58,32 @@ int main (int argc, char **argv) mpfr_inits2 (prec, LIST, (mpfr_ptr) 0); - if (mpfr_set_str (x, argv[2], 0, GMP_RNDN)) + if (mpfr_set_str (x, argv[2], 0, MPFR_RNDN)) { fprintf (stderr, "rndo-add: bad x value\n"); exit (1); } mpfr_printf ("x = %.*Rb\n", pprec, x); - if (mpfr_set_str (y, argv[3], 0, GMP_RNDN)) + if (mpfr_set_str (y, argv[3], 0, MPFR_RNDN)) { fprintf (stderr, "rndo-add: bad y value\n"); exit (1); } mpfr_printf ("y = %.*Rb\n", pprec, y); - mpfr_add (d, x, y, GMP_RNDD); + mpfr_add (d, x, y, MPFR_RNDD); mpfr_printf ("d = %.*Rb\n", pprec, d); - mpfr_add (u, x, y, GMP_RNDU); + mpfr_add (u, x, y, MPFR_RNDU); mpfr_printf ("u = %.*Rb\n", pprec, u); - mpfr_add (e, d, u, GMP_RNDN); - mpfr_div_2ui (e, e, 1, GMP_RNDN); + mpfr_add (e, d, u, MPFR_RNDN); + mpfr_div_2ui (e, e, 1, MPFR_RNDN); mpfr_printf ("e = %.*Rb\n", pprec, e); - mpfr_sub (z, u, e, GMP_RNDN); - mpfr_add (z, z, d, GMP_RNDN); + mpfr_sub (z, u, e, MPFR_RNDN); + mpfr_add (z, z, d, MPFR_RNDN); mpfr_printf ("z = %.*Rb\n", pprec, z); mpfr_clears (LIST, (mpfr_ptr) 0); diff --git a/examples/sample.c b/examples/sample.c index a349a2f6b..8201b2f00 100644 --- a/examples/sample.c +++ b/examples/sample.c @@ -35,19 +35,19 @@ int main (void) mpfr_t s, t, u; mpfr_init2 (t, 200); - mpfr_set_d (t, 1.0, GMP_RNDD); + mpfr_set_d (t, 1.0, MPFR_RNDD); mpfr_init2 (s, 200); - mpfr_set_d (s, 1.0, GMP_RNDD); + mpfr_set_d (s, 1.0, MPFR_RNDD); mpfr_init2 (u, 200); for (i = 1; i <= 100; i++) { - mpfr_mul_ui (t, t, i, GMP_RNDU); - mpfr_set_d (u, 1.0, GMP_RNDD); - mpfr_div (u, u, t, GMP_RNDD); - mpfr_add (s, s, u, GMP_RNDD); + mpfr_mul_ui (t, t, i, MPFR_RNDU); + mpfr_set_d (u, 1.0, MPFR_RNDD); + mpfr_div (u, u, t, MPFR_RNDD); + mpfr_add (s, s, u, MPFR_RNDD); } printf ("Sum is "); - mpfr_out_str (stdout, 10, 0, s, GMP_RNDD); + mpfr_out_str (stdout, 10, 0, s, MPFR_RNDD); putchar ('\n'); mpfr_clear (s); mpfr_clear (t); diff --git a/examples/version.c b/examples/version.c index 71febfe5d..4f3ffc733 100644 --- a/examples/version.c +++ b/examples/version.c @@ -40,7 +40,7 @@ static void failure_test (void) mpfr_t x; mpfr_init2 (x, 128); - mpfr_set_str (x, "17", 0, GMP_RNDN); + mpfr_set_str (x, "17", 0, MPFR_RNDN); if (mpfr_cmp_ui (x, 17) != 0) printf ("\nFailure in mpfr_set_str! Probably an unmatched ABI!\n"); mpfr_clear (x); -- cgit v1.2.1