diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2008-07-25 10:58:20 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2008-07-25 10:58:20 +0000 |
commit | 7e967704ea7a305f95b3bc3382ce7d478d452eba (patch) | |
tree | 41c6e4f5def03cc27a938af939183e48976b6ef8 /tests/tpow_all.c | |
parent | 7624ce48c8cf3ac10c0d146baafcf51b94f980cd (diff) | |
download | mpfr-7e967704ea7a305f95b3bc3382ce7d478d452eba.tar.gz |
tests/tpow_all.c: started to write a test of 2^(emin - i/4) with
0 <= i <= 12.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/vlefevre@5444 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tpow_all.c')
-rw-r--r-- | tests/tpow_all.c | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/tests/tpow_all.c b/tests/tpow_all.c index 452b60852..d5cc4bd30 100644 --- a/tests/tpow_all.c +++ b/tests/tpow_all.c @@ -308,7 +308,47 @@ tst (void) } static void -underflow_up (int extended_emin) +underflow_up1 (int extended_emin) +{ + mpfr_t delta, x, y, z; + mp_exp_t n; + int inex; + int i; + + n = mpfr_get_emin (); + if (n < LONG_MIN) + return; + + mpfr_init2 (delta, 2); + inex = mpfr_set_ui_2exp (delta, 1, -2, GMP_RNDN); + MPFR_ASSERTN (inex == 0); + + mpfr_init2 (x, 8); + inex = mpfr_set_ui (x, 2, GMP_RNDN); + MPFR_ASSERTN (inex == 0); + + mpfr_init2 (y, sizeof (long) * CHAR_BIT + 4); + inex = mpfr_set_si (y, n, GMP_RNDN); + MPFR_ASSERTN (inex == 0); + + mpfr_init2 (z, 32); + + for (i = 0; i <= 12; i++) + { + /* Test 2^(emin - i/4). + * --> Underflow iff i > 4. + * --> Zero iff i >= 8. + */ + + inex = mpfr_sub (y, y, delta, GMP_RNDN); + MPFR_ASSERTN (inex == 0); + } + + mpfr_clears (delta, x, y, z, (mpfr_ptr) 0); +} + +static void +underflow_up2 (int extended_emin) { mpfr_t x, y, z, z0, eps; mp_exp_t n; @@ -347,7 +387,7 @@ underflow_up (int extended_emin) inex = mpfr_pow (z, x, y, (mp_rnd_t) rnd); if (__gmpfr_flags != ufinex) { - printf ("Error in underflow_up for %s", + printf ("Error in underflow_up2 for %s", mpfr_print_rnd_mode ((mp_rnd_t) rnd)); if (extended_emin) printf (" and extended emin"); @@ -360,8 +400,8 @@ underflow_up (int extended_emin) (mpfr_nextabove (z0), 1) : -1; sprintf (sy, "%lu", (unsigned long) n); cmpres (0, x, sy, (mp_rnd_t) rnd, z0, expected_inex, z, inex, - extended_emin ? "underflow_up and extended emin" : - "underflow_up"); + extended_emin ? "underflow_up2 and extended emin" : + "underflow_up2"); test_others (NULL, sy, (mp_rnd_t) rnd, x, y, z, inex); } @@ -369,6 +409,13 @@ underflow_up (int extended_emin) } static void +underflow_up (int extended_emin) +{ + underflow_up1 (extended_emin); + underflow_up2 (extended_emin); +} + +static void underflow (void) { mp_exp_t emin; |