From 78c797d8acf10f9811624bbdd005e426daaec2e8 Mon Sep 17 00:00:00 2001 From: vlefevre Date: Thu, 21 Jan 2016 00:52:24 +0000 Subject: 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 --- tests/tsqrt.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests') 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; } -- cgit v1.2.1