summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2021-02-04 15:12:03 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2021-02-04 15:12:03 +0000
commit078acf91467648474a80fb888f1d2bc6d8507c05 (patch)
tree9d3ccd658e228d9bd66a132da1308968917c6907 /tests
parent830a678f69eb0bf6f8b0696231fc769c4538e89d (diff)
downloadmpfr-078acf91467648474a80fb888f1d2bc6d8507c05.tar.gz
[src/compound.c] fixed case n < 0 and underflow
[tests/tcompound.c] added corresponding non-regression tests git-svn-id: https://scm.gforge.inria.fr/anonscm/svn/mpfr/trunk@14360 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r--tests/tcompound.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/tcompound.c b/tests/tcompound.c
index 7c41af0aa..5580ed043 100644
--- a/tests/tcompound.c
+++ b/tests/tcompound.c
@@ -174,6 +174,40 @@ check_ieee754 (void)
exit (1);
}
+ /* test for negative n */
+ i = -1;
+ while (1)
+ {
+ mpfr_set_si_2exp (x, -1, -1, MPFR_RNDN); /* x = -0.5 */
+ mpfr_compound (y, x, i, MPFR_RNDN);
+ mpfr_set_ui_2exp (x, 1, -i, MPFR_RNDN);
+ if (!mpfr_equal_p (y, x))
+ {
+ printf ("Error for compound(-0.5,%ld)\n", i);
+ printf ("expected "); mpfr_dump (x);
+ printf ("got "); mpfr_dump (y);
+ exit (1);
+ }
+ if (i == -2147483647) /* largest possible value on 32-bit machine */
+ break;
+ i = 2 * i - 1;
+ }
+
+#if GMP_NUMB_BITS >= 64 || MPFR_PREC_BITS >= 64
+ /* then 64-bit constants are supported */
+ i = 4994322635099777669L;
+ mpfr_set_ui (x, 1, MPFR_RNDN);
+ mpfr_compound (y, x, -i, MPFR_RNDN);
+ mpfr_set_si_2exp (x, 1, -i, MPFR_RNDN);
+ if (!mpfr_equal_p (y, x))
+ {
+ printf ("Error for compound(1,%ld)\n", i);
+ printf ("expected "); mpfr_dump (x);
+ printf ("got "); mpfr_dump (y);
+ exit (1);
+ }
+#endif
+
mpfr_clear (x);
mpfr_clear (y);
}