diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2018-01-31 15:02:18 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2018-01-31 15:02:18 +0000 |
commit | 55349dd9f32c48707a8084d727f06091d4a29c90 (patch) | |
tree | 19e44d3e308f09b4330d4402efb8407d35ca7df1 /tests/tdiv_ui.c | |
parent | 1a3a51bb52616cbefe678e1848770f43d9df63da (diff) | |
download | mpfr-55349dd9f32c48707a8084d727f06091d4a29c90.tar.gz |
[tests/tdiv_ui.c] Updated midpoint_exact to also test the divisor
ULONG_MAX, allowing one to cover cases 3 and 4.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@12168 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tdiv_ui.c')
-rw-r--r-- | tests/tdiv_ui.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/tdiv_ui.c b/tests/tdiv_ui.c index 9dba03704..b430efbc3 100644 --- a/tests/tdiv_ui.c +++ b/tests/tdiv_ui.c @@ -397,7 +397,8 @@ static void midpoint_exact (void) { mpfr_t x, y1, y2; - int i, j, kx, ky, px, pxmin, py, pymin, r; + unsigned long j; + int i, kx, ky, px, pxmin, py, pymin, r; int inex1, inex2; pymin = 1; @@ -405,14 +406,19 @@ midpoint_exact (void) { if ((i & (i-2)) == 1) pymin++; - for (j = 1; j < 32; j++) + for (j = 1; j != 0; j++) { + if (j == 31) + j = ULONG_MAX; /* Test of (i*j) / j with various precisions. The target precisions include: large, length(i), and length(i)-1; the latter case corresponds to a midpoint. */ - mpfr_init2 (x, 64); - inex1 = mpfr_set_ui (x, i*j, MPFR_RNDN); + mpfr_init2 (x, 5 + sizeof(long) * CHAR_BIT); + inex1 = mpfr_set_ui (x, j, MPFR_RNDN); MPFR_ASSERTN (inex1 == 0); + inex1 = mpfr_mul_ui (x, x, i, MPFR_RNDN); + MPFR_ASSERTN (inex1 == 0); + /* x = (i*j) */ pxmin = mpfr_min_prec (x); if (pxmin < MPFR_PREC_MIN) pxmin = MPFR_PREC_MIN; @@ -439,7 +445,7 @@ midpoint_exact (void) ! SAME_SIGN (inex1, inex2)) { printf ("Error in midpoint_exact for " - "i=%d j=%d px=%d py=%d %s\n", i, j, px, py, + "i=%d j=%lu px=%d py=%d %s\n", i, j, px, py, mpfr_print_rnd_mode ((mpfr_rnd_t) r)); printf ("Expected "); mpfr_dump (y1); |