From 82d9c355317c65cb29ea9f0dc5c20dc9ba7fac6f Mon Sep 17 00:00:00 2001 From: vlefevre Date: Fri, 3 Jun 2016 15:02:05 +0000 Subject: =?UTF-8?q?[tests/tset=5Ffloat128.c]=20Take=20into=20account=20fai?= =?UTF-8?q?lures=20in=20division=20by=200=20and=20absence=20of=20signed=20?= =?UTF-8?q?zeros.=20Also=20fixed=20the=20code=20checking=20the=20sign=20of?= =?UTF-8?q?=200=20(mpfr=5Fsgn=20cannot=20be=20used=20for=20that=20since=20?= =?UTF-8?q?it=20returns=200=20for=20=C2=B10).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@10429 280ebfd0-de03-0410-8827-d642c229c3f4 --- tests/tset_float128.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'tests/tset_float128.c') diff --git a/tests/tset_float128.c b/tests/tset_float128.c index ad50bf820..a325ceecc 100644 --- a/tests/tset_float128.c +++ b/tests/tset_float128.c @@ -40,10 +40,11 @@ check_special (void) mpfr_init2 (x, 113); +#if !defined(MPFR_ERRDIVZERO) /* check NaN */ f = 0.0 / 0.0; mpfr_set_float128 (x, f, MPFR_RNDN); - if (mpfr_nan_p (x) == 0) + if (! mpfr_nan_p (x)) { printf ("Error in mpfr_set_float128(x, NaN)\n"); exit (1); @@ -59,7 +60,7 @@ check_special (void) /* check +Inf */ f = 1.0 / 0.0; mpfr_set_float128 (x, f, MPFR_RNDN); - if (mpfr_inf_p (x) == 0 || mpfr_sgn (x) < 0) + if (! mpfr_inf_p (x) || MPFR_IS_NEG (x)) { printf ("Error in mpfr_set_float128(x, +Inf)\n"); exit (1); @@ -74,7 +75,7 @@ check_special (void) /* check -Inf */ f = -1.0 / 0.0; mpfr_set_float128 (x, f, MPFR_RNDN); - if (mpfr_inf_p (x) == 0 || mpfr_sgn (x) > 0) + if (! mpfr_inf_p (x) || MPFR_IS_POS (x)) { printf ("Error in mpfr_set_float128(x, -Inf)\n"); exit (1); @@ -85,36 +86,58 @@ check_special (void) printf ("Error in mpfr_get_float128(-Inf)\n"); exit (1); } +#endif /* check +0 */ f = 0.0; mpfr_set_float128 (x, f, MPFR_RNDN); - if (mpfr_zero_p (x) == 0 || mpfr_sgn (x) < 0) + if (! mpfr_zero_p (x) || MPFR_IS_NEG (x)) { printf ("Error in mpfr_set_float128(x, +0)\n"); exit (1); } f = mpfr_get_float128 (x, MPFR_RNDN); - if (f != 0.0 || 1 / f != 1 / 0.0) + if (f != 0.0) /* the sign is not checked */ + { + printf ("Error in mpfr_get_float128(+0.0)\n"); + exit (1); + } +#if !defined(MPFR_ERRDIVZERO) && defined(HAVE_SIGNEDZ) + if (1 / f != 1 / 0.0) /* check the sign */ { printf ("Error in mpfr_get_float128(+0.0)\n"); exit (1); } +#endif /* check -0 */ f = -0.0; mpfr_set_float128 (x, f, MPFR_RNDN); - if (mpfr_zero_p (x) == 0 || mpfr_sgn (x) > 0) + if (! mpfr_zero_p (x)) + { + printf ("Error in mpfr_set_float128(x, -0)\n"); + exit (1); + } +#if defined(HAVE_SIGNEDZ) + if (MPFR_IS_POS (x)) { printf ("Error in mpfr_set_float128(x, -0)\n"); exit (1); } +#endif f = mpfr_get_float128 (x, MPFR_RNDN); - if (f != -0.0 || 1 / f != 1 / -0.0) + if (f != -0.0) /* the sign is not checked */ + { + printf ("Error in mpfr_get_float128(-0.0)\n"); + exit (1); + } +#if !defined(MPFR_ERRDIVZERO) && defined(HAVE_SIGNEDZ) + if (1 / f != 1 / -0.0) /* check the sign */ { printf ("Error in mpfr_get_float128(-0.0)\n"); exit (1); } +#endif mpfr_clear (x); } -- cgit v1.2.1