diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2018-02-22 10:19:52 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2018-02-22 10:19:52 +0000 |
commit | 71e960d61e7c0d7acc6dda3bd0da81dc4551d7b9 (patch) | |
tree | 0a548cbfa753f71477910bd510c346460f9326d6 /tests/tfma.c | |
parent | f092a17075a1176f5c489a8856493e292649921c (diff) | |
download | mpfr-71e960d61e7c0d7acc6dda3bd0da81dc4551d7b9.tar.gz |
[src/fma.c] added comments
[tests/tfma.c] added a test (currently failing)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@12393 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tfma.c')
-rw-r--r-- | tests/tfma.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/tfma.c b/tests/tfma.c index f3a3b30e7..b8918a192 100644 --- a/tests/tfma.c +++ b/tests/tfma.c @@ -196,6 +196,29 @@ test_overflow2 (void) } static void +test_overflow3 (void) +{ + mpfr_t x, y, z, r; + int inex; + mpfr_prec_t p = 8; + + mpfr_inits2 (p, x, y, z, (mpfr_ptr) 0); + mpfr_init2 (r, 2 * p); + mpfr_set_ui_2exp (x, 1, mpfr_get_emax () - 1, MPFR_RNDN); + mpfr_set_ui (y, 2, MPFR_RNDN); /* y = 2 */ + mpfr_set_si_2exp (z, -1, mpfr_get_emax () - 2*p - 2, MPFR_RNDN); + mpfr_nextabove (z); + mpfr_clear_flags (); + /* We have x*y = 2^emax and z = -2^(emax-2p-2)*(1-2^(-p)) thus + x*y+z = 2^emax - 2^(emax-2p-2) + 2^(emax-3p-2) should overflow, + since it is closest from 2^emax than from 2^emax - 2^(emax-2p). */ + inex = mpfr_fma (r, x, y, z, MPFR_RNDN); + MPFR_ASSERTN(inex > 0); + MPFR_ASSERTN(mpfr_inf_p (r) && mpfr_sgn (r) > 0); + mpfr_clears (x, y, z, r, (mpfr_ptr) 0); +} + +static void test_underflow1 (void) { mpfr_t x, y, z, r; @@ -833,6 +856,7 @@ main (int argc, char *argv[]) set_emax (MPFR_EMAX_MAX); test_overflow1 (); test_overflow2 (); + test_overflow3 (); test_underflow1 (); test_underflow2 (); test_underflow3 (2); |