summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Zimmermann <Paul.Zimmermann@inria.fr>2020-02-12 13:15:46 +0100
committerPaul Zimmermann <Paul.Zimmermann@inria.fr>2020-02-12 13:15:46 +0100
commit60ba154b0b7d24a8274b0f48426e48ba22523383 (patch)
tree0b63b7d947a4f3fdf2cc913fd0e4df452d60ced5
parent51ca498d80781402d84c744aab7c8625fec96a1b (diff)
downloadmpc-git-60ba154b0b7d24a8274b0f48426e48ba22523383.tar.gz
added test
-rw-r--r--tests/ttan.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/ttan.c b/tests/ttan.c
index db2d3f9..1b0b714 100644
--- a/tests/ttan.c
+++ b/tests/ttan.c
@@ -197,6 +197,37 @@ pure_imaginary_argument (void)
mpfr_clear (y);
}
+/* test with reduced exponent range */
+static void
+bug20200211 (void)
+{
+ mpfr_exp_t emin = mpfr_get_emin ();
+ mpc_t x, z, zr;
+
+ mpfr_set_emin (-148);
+ mpc_init2 (x, 24);
+ mpc_init2 (z, 24);
+ mpc_init2 (zr, 24);
+ mpfr_set_flt (mpc_realref (x), 0x3.b32d48p24, MPFR_RNDN);
+ mpfr_set_flt (mpc_imagref (x), -0x48.08bd0p0, MPFR_RNDN);
+ mpc_tan (z, x, MPC_RNDNN);
+ /* the real part should be 1.8638349976774607754968796608e-63,
+ but since that underflows, we should get +0 */
+ mpfr_set_flt (mpc_realref (zr), +0.0f, MPFR_RNDN);
+ mpfr_set_flt (mpc_imagref (zr), -1.0f, MPFR_RNDN);
+ if (mpc_cmp (z, zr))
+ {
+ printf ("Incorrect tangent with reduced exponent range:\n");
+ mpfr_printf ("Expected (%Re,%Re)\n", mpc_realref (zr), mpc_imagref (zr));
+ mpfr_printf ("Got (%Re,%Re)\n", mpc_realref (z), mpc_imagref (z));
+ exit (1);
+ }
+ mpc_clear (x);
+ mpc_clear (z);
+ mpc_clear (zr);
+ mpfr_set_emin (emin);
+}
+
#define MPC_FUNCTION_CALL \
P[0].mpc_inex = mpc_tan (P[1].mpc, P[2].mpc, P[3].mpc_rnd)
#define MPC_FUNCTION_CALL_REUSE_OP1 \
@@ -210,6 +241,8 @@ main (void)
{
test_start ();
+ bug20200211 ();
+
data_check_template ("tan.dsc", "tan.dat");
tgeneric_template ("tan.dsc", 2, 512, 7, 4);