From 01f4af66d75182258d758d47ce92b1541d5d8857 Mon Sep 17 00:00:00 2001 From: vlefevre Date: Wed, 25 Mar 2020 17:52:01 +0000 Subject: [tests/tsub.c] Completed tests for UBF (currently fail). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13811 280ebfd0-de03-0410-8827-d642c229c3f4 --- tests/tsub.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/tests/tsub.c b/tests/tsub.c index f4af55130..2016d5da4 100644 --- a/tests/tsub.c +++ b/tests/tsub.c @@ -1325,16 +1325,44 @@ static void test_ubf_aux (void) RND_LOOP (rnd) for (i = 0; i <= 10; i += 2) { - mpfr_exp_t e0 = MPFR_UBF_GET_EXP (x[0]); + mpfr_exp_t e0; mpfr_flags_t flags, flags_y; int inex_y; if (i >= 8) { + int d; + + e0 = MPFR_UBF_GET_EXP (x[i]); + if (e0 < MPFR_EXP_MIN + 3) + e0 += 3; + + if (rnd == MPFR_RNDN) + d = i == 8 ? (e0 == __gmpfr_emin ? 3 : 4) : 6; + else if (MPFR_IS_LIKE_RNDZ (rnd, neg)) + d = i == 8 ? 3 : 6; + else + d = i == 8 ? 6 : 8; + + mpfr_clear_flags (); + inex_y = mpfr_set_si_2exp (w, sign * d, e0 - 3, + (mpfr_rnd_t) rnd); + flags_y = __gmpfr_flags | MPFR_FLAGS_INEXACT; + if (inex_y == 0) + inex_y = rnd == MPFR_RNDN ? (i == 8 ? 1 : -1) : + MPFR_IS_LIKE_RNDD ((mpfr_rnd_t) rnd, sign) ? + -1 : 1; + mpfr_set (y, w, MPFR_RNDN); + mpfr_clear_flags (); inexact = mpfr_sub (w, p[i], p[9], (mpfr_rnd_t) rnd); flags = __gmpfr_flags; - continue; /* TODO: check the result */ + + /* For MPFR_RNDF, only do a basic test. */ + MPFR_ASSERTN (mpfr_check (w)); + if (rnd == MPFR_RNDF) + continue; + goto testw; } @@ -1342,6 +1370,13 @@ static void test_ubf_aux (void) inexact = mpfr_sub (z, p[i], p[i+1], (mpfr_rnd_t) rnd); flags = __gmpfr_flags; + /* For MPFR_RNDF, only do a basic test. */ + MPFR_ASSERTN (mpfr_check (z)); + if (rnd == MPFR_RNDF) + continue; + + e0 = MPFR_UBF_GET_EXP (x[0]); + if (e0 < __gmpfr_emin) { mpfr_rnd_t r = @@ -1432,7 +1467,7 @@ static void test_ubf_aux (void) printf ("b = "); mpfr_dump (p[i]); printf ("c = "); - mpfr_dump (p[i+1]); + mpfr_dump (p[i <= 8 ? i+1 : 9]); printf ("Expected "); /* Set y to a 2-bit precision just for the output. Since we exit, this will have no other effect. */ -- cgit v1.2.1