diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-02-16 18:23:49 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-02-16 18:23:49 +0000 |
commit | e851accbfc847c26d885148c4420f322e2561cc8 (patch) | |
tree | 84e2ab86b1c3af212605529a3d8dbaa9f8031697 /tests/tsqrt.c | |
parent | b6d4dd5a15b2b0a1166c90906259cd82f41cf437 (diff) | |
download | mpfr-e851accbfc847c26d885148c4420f322e2561cc8.tar.gz |
improved error message
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2740 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tsqrt.c')
-rw-r--r-- | tests/tsqrt.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/tests/tsqrt.c b/tests/tsqrt.c index a534720c7..85a030ad0 100644 --- a/tests/tsqrt.c +++ b/tests/tsqrt.c @@ -137,11 +137,12 @@ check_float (void) static void special (void) { - mpfr_t x, z; + mpfr_t x, y, z; int inexact; mp_prec_t p; mpfr_init (x); + mpfr_init (y); mpfr_init (z); mpfr_set_prec (x, 27); @@ -247,6 +248,10 @@ special (void) /* corner case rw = 0 in rounding to nearest */ mpfr_set_prec (z, mp_bits_per_limb - 1); + mpfr_set_prec (y, mp_bits_per_limb - 1); + mpfr_set_ui (y, 1, GMP_RNDN); + mpfr_mul_2exp (y, y, mp_bits_per_limb - 1, GMP_RNDN); + mpfr_nextabove (y); for (p = 2 * mp_bits_per_limb - 1; p <= 1000; p++) { mpfr_set_prec (x, p); @@ -268,14 +273,23 @@ special (void) mpfr_nextabove (x); /* now x is just above [2^(mp_bits_per_limb - 1) + 1]^2 */ inexact = mpfr_sqrt (z, x, GMP_RNDN); - if (inexact <= 0 || mpfr_cmp_ui_2exp (z, 1, mp_bits_per_limb - 1) == 0) + if (mpfr_cmp (z, y)) { - printf ("Error in corner case for p = %lu\n", (unsigned long) p); + printf ("Error for sqrt(x) in rounding to nearest\n"); + printf ("x="); mpfr_dump (x); + printf ("Expected "); mpfr_dump (y); + printf ("Got "); mpfr_dump (z); + exit (1); + } + if (inexact <= 0) + { + printf ("Wrong inexact flag in corner case for p = %lu\n", (unsigned long) p); exit (1); } } mpfr_clear (x); + mpfr_clear (y); mpfr_clear (z); } |