summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2021-09-07 00:51:30 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2021-09-07 00:51:30 +0000
commitc6d7cc483915e6a36b1f50d9b1104367fc95b418 (patch)
tree98545d812b450dcbdccfbc9a65b274666a776829
parent777da4af51c8dc6515d16b8395bb1a11b061e250 (diff)
downloadmpfr-c6d7cc483915e6a36b1f50d9b1104367fc95b418.tar.gz
[tests/tests.c] Fixed bad_cases when y is ±0 (rare case).
git-svn-id: https://scm.gforge.inria.fr/anonscm/svn/mpfr/trunk@14570 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--tests/tests.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/tests/tests.c b/tests/tests.c
index b358b7a64..c58b3fa43 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -1040,7 +1040,11 @@ bad_cases (int (*fct)(FLIST), int (*inv)(FLIST), const char *name,
if (!sb)
{
if (dbg)
- printf ("bad_cases: exact case\n");
+ {
+ printf ("bad_cases: exact case z = ");
+ mpfr_out_str (stdout, 16, 0, z, MPFR_RNDN);
+ printf ("\n");
+ }
if (inex_inv)
{
printf ("bad_cases: f exact while f^(-1) inexact,\n"
@@ -1082,11 +1086,28 @@ bad_cases (int (*fct)(FLIST), int (*inv)(FLIST), const char *name,
}
}
while (inex == 0);
- /* We really have a bad case. */
- do
- py--;
- while (py >= MPFR_PREC_MIN && mpfr_prec_round (z, py, MPFR_RNDZ) == 0);
- py++;
+ /* We really have a bad case (or some special case). */
+ if (mpfr_zero_p (z))
+ {
+ /* This can occur on tlog (GMP_CHECK_RANDOMIZE=1630879377004032):
+ y = -0, giving x = 1 and z = 0. We have y = z, but here,
+ y and z have different signs. Since test5rm will test f(x)
+ and its sign (in particular for 0), we need to take the
+ sign of f(x), i.e. of z.
+ Note: To avoid this special case, one might want to detect and
+ ignore y = 0 (of any sign) when taking the random number above,
+ as this case should be redundant with some other tests. */
+ mpfr_set (y, z, MPFR_RNDN);
+ py = MPFR_PREC_MIN;
+ }
+ else
+ {
+ do
+ py--;
+ while (py >= MPFR_PREC_MIN &&
+ mpfr_prec_round (z, py, MPFR_RNDZ) == 0);
+ py++;
+ }
/* py is now the smallest output precision such that we have
a bad case in the directed rounding modes. */
if (mpfr_prec_round (y, py, MPFR_RNDZ) != 0)