summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2016-05-30 07:53:27 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2016-05-30 07:53:27 +0000
commitc6e03b485fbe43e89d3fd050d5349507a82a73c5 (patch)
treeea436d9a468bd974aeb4ce5c019dcac9f662b59e
parent37a105598391079b86237a5ce5ca0176a60bbf1f (diff)
downloadmpfr-c6e03b485fbe43e89d3fd050d5349507a82a73c5.tar.gz
[tests/tsub.c] Added comments for check_max_almosteven (latest
test case, added in r10383). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@10386 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--tests/tsub.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/tsub.c b/tests/tsub.c
index e462b780e..7ad321e5a 100644
--- a/tests/tsub.c
+++ b/tests/tsub.c
@@ -629,6 +629,26 @@ check_rounding (void)
}
}
+/* Check a = b - c, where the significand of b has all 1's, c is small
+ compared to b, and PREC(a) = PREC(b) - 1. Thus b is a midpoint for
+ the precision of the result a. The test is done with the extended
+ exponent range and with some reduced exponent range. Two choices
+ are made for the exponent of b: the maximum exponent - 1 (similar
+ to some normal case) and the maximum exponent (overflow case or
+ near overflow case, depending on the rounding mode).
+ This test is useful to trigger a bug in r10382: Since c is small,
+ the computation in sub1.c was done by first rounding b in the
+ precision of a, then correcting the result if b was a breakpoint
+ for this precision (exactly representable number for the directed
+ rounding modes, or midpoint for the round-to-nearest mode). The
+ problem was that for a midpoint in the round-to-nearest mode, the
+ rounding of b gave a spurious overflow; not only the overflow flag
+ was incorrect, but the result could not be corrected, since due to
+ this overflow, the "even rounding" information was lost.
+ In the case of reduced exponent range, an additional test is done
+ for consistency checks: the subtraction is done in the extended
+ exponent range (no overflow), then the result is converted to the
+ initial exponent range with mpfr_check_range. */
static void
check_max_almosteven (void)
{
@@ -668,6 +688,7 @@ check_max_almosteven (void)
mpfr_flags_t flags1, flags2;
int inex1, inex2;
+ /* Expected result. */
flags1 = MPFR_FLAGS_INEXACT;
if (rnd == MPFR_RNDN || MPFR_IS_LIKE_RNDZ (rnd, neg))
{
@@ -689,6 +710,7 @@ check_max_almosteven (void)
}
MPFR_SET_SIGN (a1, neg ? -1 : 1);
+ /* Computed result. */
mpfr_clear_flags ();
inex2 = mpfr_sub (a2, b, c, (mpfr_rnd_t) rnd);
flags2 = __gmpfr_flags;
@@ -716,6 +738,7 @@ check_max_almosteven (void)
if (i == 0)
break;
+ /* Additional test for the reduced exponent range. */
mpfr_clear_flags ();
set_emin (MPFR_EMIN_MIN);
set_emax (MPFR_EMAX_MAX);