summaryrefslogtreecommitdiff
path: root/tests/tsub.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2016-02-04 18:24:16 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2016-02-04 18:24:16 +0000
commit3834afd4d3a6fcae9177e8e2598b6853e8b3d6de (patch)
treea0c9791f5c2b7cb01da1613ef1718b668312bcec /tests/tsub.c
parent2f72db3b57460a61fadd6c48573c719352d214e8 (diff)
downloadmpfr-3834afd4d3a6fcae9177e8e2598b6853e8b3d6de.tar.gz
fixed to correctly check prec=1
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@9950 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tsub.c')
-rw-r--r--tests/tsub.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/tests/tsub.c b/tests/tsub.c
index eab1f4393..89a75b9a3 100644
--- a/tests/tsub.c
+++ b/tests/tsub.c
@@ -572,8 +572,10 @@ check_rounding (void)
mpfr_set_ui_2exp (c, 1, -l, MPFR_RNDN);
i = mpfr_sub (a, b, c, MPFR_RNDN);
/* b - c = 2^p + 1 + 2^(-k) - 2^(-l), should be rounded to
- 2^p for l <= k, and 2^p+2 for l < k */
- if (l <= k)
+ 2^p for l <= k, and 2^p+2 for l < k, except when p=1 and
+ k=l, in which case b - c = 3, and the round-away rule implies
+ a = 4 = 2^p+2 = 2^(p+1) */
+ if (l < k || (l == k && p > 1))
{
if (mpfr_cmp_ui_2exp (a, 1, p) != 0)
{
@@ -596,7 +598,7 @@ check_rounding (void)
exit (1);
}
}
- else /* l < k */
+ else /* l < k or (l = k and p = 1) */
{
mpfr_set_ui_2exp (res, 1, p, MPFR_RNDN);
mpfr_add_ui (res, res, 2, MPFR_RNDN);