From b55e59e1d750efa6ed336f3f191c7bedac90a7ba Mon Sep 17 00:00:00 2001 From: zimmerma Date: Tue, 11 Sep 2018 12:01:25 +0000 Subject: [tests/tcan_round.c] fixed test for small value of GMP_NUMB_BITS git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13171 280ebfd0-de03-0410-8827-d642c229c3f4 --- tests/tcan_round.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/tcan_round.c b/tests/tcan_round.c index a514d2aca..4a046b1f7 100644 --- a/tests/tcan_round.c +++ b/tests/tcan_round.c @@ -212,6 +212,7 @@ check_can_round (void) int i, u[3] = { 0, 1, 256 }; int inex; int expected, got; + int maxerr; mpfr_inits2 (4 * GMP_NUMB_BITS, x, xinf, xsup, yinf, ysup, (mpfr_ptr) 0); @@ -239,10 +240,16 @@ check_can_round (void) } MPFR_ASSERTN (mpfr_get_exp (x) == precx); - for (err = precy; err <= precy + 3; err++) + maxerr = precy + 3; + if (4 * GMP_NUMB_BITS < maxerr) + maxerr = 4 * GMP_NUMB_BITS; + for (err = precy; err <= maxerr; err++) { mpfr_set_ui_2exp (xinf, 1, precx - err, MPFR_RNDN); inex = mpfr_add (xsup, x, xinf, MPFR_RNDN); + /* Since EXP(x) = precx, and xinf = 2^(precx-err), + x + xinf is exactly representable on 4 * GMP_NUMB_BITS + nbits as long as err <= 4 * GMP_NUMB_BITS */ MPFR_ASSERTN (inex == 0); inex = mpfr_sub (xinf, x, xinf, MPFR_RNDN); MPFR_ASSERTN (inex == 0); -- cgit v1.2.1