diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2016-02-22 12:46:41 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2016-02-22 12:46:41 +0000 |
commit | 06d455fd9d4aafc5c9784c0c23da27365e72ab68 (patch) | |
tree | 43fa36f8f0f1acd1cb0ccab37fc402edc9fdcb3e /tests | |
parent | 6613ecf3243a7fcf32e207baff5f8c8b20d7e151 (diff) | |
download | mpfr-06d455fd9d4aafc5c9784c0c23da27365e72ab68.tar.gz |
[src/agm.c] Fixed bug in mpfr_agm in case the two FP inputs have
the same value but the result cannot be exactly represented in
the target precision: the ternary value was wrongly set to 0.
[tests/tagm.c] Added testcase.
(merged changesets r10060,10077 from the trunk)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/3.1@10078 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tagm.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/tagm.c b/tests/tagm.c index a142d5718..81eb81894 100644 --- a/tests/tagm.c +++ b/tests/tagm.c @@ -169,6 +169,45 @@ check_large (void) } static void +check_eq (void) +{ + mpfr_t a, b, agm; + int p; + + mpfr_init2 (a, 17); + mpfr_init2 (b, 9); + + mpfr_set_str_binary (b, "0.101000000E-3"); + mpfr_set (a, b, MPFR_RNDN); + + for (p = MPFR_PREC_MIN; p <= 2; p++) + { + int inex; + + mpfr_init2 (agm, p); + inex = mpfr_agm (agm, a, b, MPFR_RNDU); + if (mpfr_cmp_ui_2exp (agm, 5 - p, -5) != 0) + { + printf ("Error in check_eq for p = %d: expected %d*2^(-5), got ", + p, 5 - p); + mpfr_dump (agm); + exit (1); + } + if (inex <= 0) + { + printf ("Wrong ternary value in check_eq for p = %d\n", p); + printf ("expected 1\n"); + printf ("got %d\n", inex); + exit (1); + } + mpfr_clear (agm); + } + + mpfr_clear (a); + mpfr_clear (b); +} + +static void check_nans (void) { mpfr_t x, y, m; @@ -260,6 +299,7 @@ main (int argc, char* argv[]) check_nans (); check_large (); + check_eq (); check4 ("2.0", "1.0", MPFR_RNDN, "1.456791031046906869", -1); check4 ("6.0", "4.0", MPFR_RNDN, "4.949360872472608925", 1); check4 ("62.0", "61.0", MPFR_RNDN, "61.498983718845075902", -1); |