diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-06-07 21:54:01 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-06-07 21:54:01 +0000 |
commit | d708627d6959f296c30362db15b72e830397c82c (patch) | |
tree | 85689b5deabbbccce1650804bb9e9865f576f68a /tests | |
parent | cb809ea1cb721e03b022a223db55326a27967e7b (diff) | |
download | mpfr-d708627d6959f296c30362db15b72e830397c82c.tar.gz |
[src/zeta_ui.c] Fixed zeta(0) in reduced exponent range.
[tests/tzeta_ui.c] Added testcase.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@9518 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tzeta_ui.c | 58 |
1 files changed, 55 insertions, 3 deletions
diff --git a/tests/tzeta_ui.c b/tests/tzeta_ui.c index fbbbf287e..589227c97 100644 --- a/tests/tzeta_ui.c +++ b/tests/tzeta_ui.c @@ -33,9 +33,15 @@ main (int argc, char *argv[]) mpfr_t x, y, z, t; unsigned long n; int inex; + mpfr_exp_t emin, emax; + mpfr_flags_t flags, ex_flags; + int i; tests_start_mpfr (); + emin = mpfr_get_emin (); + emax = mpfr_get_emax (); + mpfr_init (x); mpfr_init (y); mpfr_init (z); @@ -63,10 +69,56 @@ main (int argc, char *argv[]) exit (1); } - mpfr_clear_divby0 (); + mpfr_clear_flags (); inex = mpfr_zeta_ui (x, 0, MPFR_RNDN); - MPFR_ASSERTN (inex == 0 && mpfr_cmp_si_2exp (x, -1, -1) == 0 - && !mpfr_divby0_p ()); + flags = __gmpfr_flags; + MPFR_ASSERTN (inex == 0 && mpfr_cmp_si_2exp (x, -1, -1) == 0 && flags == 0); + + for (i = -2; i <= 2; i += 2) + { + int ex_inex, err; + char *s; + + set_emin (i); + set_emax (i); + mpfr_clear_flags (); + inex = mpfr_zeta_ui (x, 0, MPFR_RNDN); + flags = __gmpfr_flags; + set_emin (emin); + set_emax (emax); + if (i < 0) + { + s = "-@Inf@"; + ex_inex = -1; + ex_flags = MPFR_FLAGS_OVERFLOW | MPFR_FLAGS_INEXACT; + err = !(mpfr_inf_p (x) && MPFR_IS_NEG (x)); + } + else if (i > 0) + { + s = "-0"; + ex_inex = 1; + ex_flags = MPFR_FLAGS_UNDERFLOW | MPFR_FLAGS_INEXACT; + err = !(mpfr_zero_p (x) && MPFR_IS_NEG (x)); + } + else + { + s = "-1/2"; + ex_inex = 0; + ex_flags = 0; + err = mpfr_cmp_si_2exp (x, -1, -1) != 0; + } + if (err || ! SAME_SIGN (inex, ex_inex) || flags != ex_flags) + { + printf ("Failure for zeta(0) in exponent range [%d,%d]\n", i, i); + printf ("Expected %s, sign(inex) = %d, flags =", s, ex_inex); + flags_out (ex_flags); + printf ("Got "); + mpfr_dump (x); + printf ("with inex = %d, flags =", inex); + flags_out (flags); + exit (1); + } + } mpfr_clear_divby0 (); inex = mpfr_zeta_ui (x, 1, MPFR_RNDN); |