diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2018-02-18 12:48:51 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2018-02-18 12:48:51 +0000 |
commit | f92193ce0ccd5a7c265ff29a7d7016e4fd59ab47 (patch) | |
tree | da1f03bd7c023d72be360af6723ab5271e11b9a5 /tests/tsqrt.c | |
parent | e6cc16d1a60f2797f80ff28736aa2a506c15d349 (diff) | |
download | mpfr-f92193ce0ccd5a7c265ff29a7d7016e4fd59ab47.tar.gz |
[tests/tsqrt.c] improve coverage
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@12296 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tsqrt.c')
-rw-r--r-- | tests/tsqrt.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/tsqrt.c b/tests/tsqrt.c index b1841415a..83e1a5e15 100644 --- a/tests/tsqrt.c +++ b/tests/tsqrt.c @@ -698,15 +698,16 @@ check_overflow (void) int inex; emax = mpfr_get_emax (); - mpfr_set_emax (-1); for (p = MPFR_PREC_MIN; p <= 1024; p++) { mpfr_init2 (r, p); mpfr_init2 (u, p); + + mpfr_set_emax (-1); mpfr_set_ui_2exp (u, 1, mpfr_get_emax () - 1, MPFR_RNDN); mpfr_nextbelow (u); mpfr_mul_2exp (u, u, 1, MPFR_RNDN); - /* now u = 1/2 - 2^(-p-1) is the largest number < +Inf, + /* now u = (1 - 2^(-p))*2^emax is the largest number < +Inf, it square root is near 0.707 and has exponent 0 > emax */ /* for RNDN, the result should be +Inf */ inex = mpfr_sqrt (r, u, MPFR_RNDN); @@ -720,6 +721,17 @@ check_overflow (void) inex = mpfr_sqrt (r, u, MPFR_RNDZ); MPFR_ASSERTN(inex < 0); MPFR_ASSERTN(mpfr_equal_p (r, u)); + + mpfr_set_emax (0); + mpfr_set_ui_2exp (u, 1, mpfr_get_emax () - 1, MPFR_RNDN); + mpfr_nextbelow (u); + mpfr_mul_2exp (u, u, 1, MPFR_RNDN); + /* u = 1-2^(-p), its square root is > u, and should thus give +Inf when + rounding away */ + inex = mpfr_sqrt (r, u, MPFR_RNDA); + MPFR_ASSERTN(inex > 0); + MPFR_ASSERTN(mpfr_inf_p (r) && mpfr_sgn (r) > 0); + mpfr_clear (r); mpfr_clear (u); } |