diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2018-09-11 12:01:25 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2018-09-11 12:01:25 +0000 |
commit | b55e59e1d750efa6ed336f3f191c7bedac90a7ba (patch) | |
tree | 7a655b26d02f41235888a9577a373ce0747425a0 | |
parent | 1f5e11d025166d5ff55829dce06979034ab3bdcd (diff) | |
download | mpfr-b55e59e1d750efa6ed336f3f191c7bedac90a7ba.tar.gz |
[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
-rw-r--r-- | tests/tcan_round.c | 9 |
1 files changed, 8 insertions, 1 deletions
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); |