summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2016-01-21 00:52:24 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2016-01-21 00:52:24 +0000
commit78c797d8acf10f9811624bbdd005e426daaec2e8 (patch)
tree960738c19c2aafa46f689219dbf340e2c04228d5 /tests
parent6c94f4e1e21d6c5d2eee5082c53fecc774c18740 (diff)
downloadmpfr-78c797d8acf10f9811624bbdd005e426daaec2e8.tar.gz
Fixed bug in mpfr_sqrt reported by Fredrik Johansson, occurring when
the result has to be rounded up to a power of 2. (merged changesets r9857-9859 from the trunk) git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/3.1@9860 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r--tests/tsqrt.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/tsqrt.c b/tests/tsqrt.c
index bec47d9f8..1a3f59a89 100644
--- a/tests/tsqrt.c
+++ b/tests/tsqrt.c
@@ -569,6 +569,30 @@ test_property2 (mpfr_prec_t p, mpfr_rnd_t r)
mpfr_clear (y);
}
+/* bug reported by Fredrik Johansson */
+static void
+bug20160120 (void)
+{
+ mpfr_t x, y;
+
+ mpfr_init2 (x, 361);
+ mpfr_init2 (y, 64);
+
+ mpfr_set_ui (x, 1, MPFR_RNDN);
+ mpfr_nextbelow (x);
+ mpfr_sqrt (y, x, MPFR_RNDN);
+ MPFR_ASSERTN(mpfr_check (y));
+ MPFR_ASSERTN(mpfr_cmp_ui (y, 1) == 0);
+
+ mpfr_set_prec (y, 128);
+ mpfr_sqrt (y, x, MPFR_RNDN);
+ MPFR_ASSERTN(mpfr_check (y));
+ MPFR_ASSERTN(mpfr_cmp_ui (y, 1) == 0);
+
+ mpfr_clear(x);
+ mpfr_clear(y);
+}
+
#define TEST_FUNCTION test_sqrt
#define TEST_RANDOM_POS 8
#include "tgeneric.c"
@@ -704,6 +728,8 @@ main (void)
data_check ("data/sqrt", mpfr_sqrt, "mpfr_sqrt");
bad_cases (mpfr_sqrt, mpfr_sqr, "mpfr_sqrt", 8, -256, 255, 4, 128, 800, 50);
+ bug20160120 ();
+
tests_end_mpfr ();
return 0;
}