summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2021-09-07 07:30:56 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2021-09-07 07:30:56 +0000
commit3940ef321512d588391646d35d38ef83d2478487 (patch)
tree298b6685765dee2fd899795c0842cd7c4a5558fe
parent633be2bc19b790bf3b5d83573a500594f028f687 (diff)
downloadmpfr-3940ef321512d588391646d35d38ef83d2478487.tar.gz
[tests/tests.c] Fixed bad_cases when y is ±0 (rare case).
(merged changeset r14570 from the trunk, with GMP_CHECK_RANDOMIZE value in a comment changed for the current revision in the 4.1 branch) git-svn-id: https://scm.gforge.inria.fr/anonscm/svn/mpfr/branches/4.1@14573 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 87360d35a..19afe90b6 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -1030,7 +1030,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"
@@ -1072,11 +1076,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=1630999539162100):
+ 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)