summaryrefslogtreecommitdiff
path: root/tests/tcos.c
diff options
context:
space:
mode:
authorPhilippe Theveny <philippe.theveny@laposte.net>2009-01-05 13:33:50 +0000
committerPhilippe Theveny <philippe.theveny@laposte.net>2009-01-05 13:33:50 +0000
commit6734fd6ca8508954351a2fd6f9bbeb0402c15ec7 (patch)
tree4e89be7f526bae3eaeb0b6c4e3f61adb7aefd659 /tests/tcos.c
parentf1a9764949ee20dede9bdf43ceb5f195d0c9d7d8 (diff)
downloadmpc-git-6734fd6ca8508954351a2fd6f9bbeb0402c15ec7.tar.gz
src/cos.c: complete the changes done in revision 380: the rounding mode in mpfr_can_round must be a directed one when the 'prec+(rnd==GMP_RNDN)' trick is used.
tests/tcos.c: add a test with values that revealed this bug. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/mpc/trunk@407 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'tests/tcos.c')
-rw-r--r--tests/tcos.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/tests/tcos.c b/tests/tcos.c
index 047c53b..96cb416 100644
--- a/tests/tcos.c
+++ b/tests/tcos.c
@@ -1,6 +1,6 @@
/* test file for mpc_cos.
-Copyright (C) 2008 Andreas Enge, Philippe Th\'eveny
+Copyright (C) 2008 2009 Andreas Enge, Philippe Th\'eveny
This file is part of the MPC Library.
@@ -20,6 +20,42 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include "mpc-tests.h"
+#include "mpc-impl.h"
+
+static void
+bug20090105 (void)
+{
+ /* this bug appeared on 32-bits machines */
+ mpc_t op, expected, got;
+ mpc_init2 (op, 324);
+ mpc_init2 (expected, 324);
+ mpc_init2 (got, 324);
+
+ mpfr_set_str (MPC_RE(op), "-3.f1813b1487372434fea4414a520f65a343a16d0ec1ffb"
+ "b2b880154db8d63377ce788fc4215c450300@1", 16, GMP_RNDN);
+ mpfr_set_str (MPC_IM(op), "-2.b7a0c80bcacf1ccbbac614bf53a58b672b1b503161bee"
+ "59a82e46a23570b652f7ba5f01ef766d1c50", 16,GMP_RNDN);
+ mpfr_set_str (MPC_RE(expected), "7.57c5b08a2b11b660d906a354289b0724b9c4b237"
+ "95abe33424e8d9858e534bd5d776ddd18e34b0240", 16, GMP_RNDN);
+ mpfr_set_str (MPC_IM(expected), "-1.f41a389646d068e0263561cb3c5d1df763945ad"
+ "ed9339f2a98387a3c4f97dbfd8a08b7d0af2f11b46", 16,GMP_RNDN);
+
+ mpc_cos (got, op, MPC_RNDNN);
+ if (mpc_cmp (got, expected) != 0)
+ {
+ printf ("Error in bug20090105: cos(op) with rounding mode MPC_RNDNN\n");
+ OUT (op);
+ OUT (expected);
+ printf(" ");
+ OUT (got);
+
+ exit (1);
+ }
+
+ mpc_clear (got);
+ mpc_clear(expected);
+ mpc_clear (op);
+}
int
main (void)
@@ -31,6 +67,8 @@ main (void)
data_check (f, "cos.dat");
tgeneric (f, 2, 512, 7, 7);
+ bug20090105 ();
+
test_end ();
return 0;