summaryrefslogtreecommitdiff
path: root/tests/tsqrt.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2016-01-21 09:13:26 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2016-01-21 09:13:26 +0000
commitb35ba982f34df6e9a9eb3ab82ea99bf4257fc2a7 (patch)
tree11848f9efc1ae99e6de1b98112d904995a0b137e /tests/tsqrt.c
parent8195f1d216c38486a792be65202031a53f6aa23f (diff)
downloadmpfr-b35ba982f34df6e9a9eb3ab82ea99bf4257fc2a7.tar.gz
[tests/tsqrt.c] Improved bug20160120.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@9861 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tsqrt.c')
-rw-r--r--tests/tsqrt.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/tsqrt.c b/tests/tsqrt.c
index 72625d94e..613649895 100644
--- a/tests/tsqrt.c
+++ b/tests/tsqrt.c
@@ -568,14 +568,19 @@ test_property2 (mpfr_prec_t p, mpfr_rnd_t r)
mpfr_clear (y);
}
-/* bug reported by Fredrik Johansson */
+/* Bug reported by Fredrik Johansson, occurring when:
+ - the precision of the result is a multiple of the number of bits
+ per word (GMP_NUMB_BITS),
+ - the rounding mode is to nearest (MPFR_RNDN),
+ - internally, the result has to be rounded up to a power of 2.
+*/
static void
bug20160120 (void)
{
mpfr_t x, y;
- mpfr_init2 (x, 361);
- mpfr_init2 (y, 64);
+ mpfr_init2 (x, 4 * GMP_NUMB_BITS);
+ mpfr_init2 (y, GMP_NUMB_BITS);
mpfr_set_ui (x, 1, MPFR_RNDN);
mpfr_nextbelow (x);
@@ -583,7 +588,7 @@ bug20160120 (void)
MPFR_ASSERTN(mpfr_check (y));
MPFR_ASSERTN(mpfr_cmp_ui (y, 1) == 0);
- mpfr_set_prec (y, 128);
+ mpfr_set_prec (y, 2 * GMP_NUMB_BITS);
mpfr_sqrt (y, x, MPFR_RNDN);
MPFR_ASSERTN(mpfr_check (y));
MPFR_ASSERTN(mpfr_cmp_ui (y, 1) == 0);