diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2002-03-17 17:49:08 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2002-03-17 17:49:08 +0000 |
commit | dd4eb0882052970d2004da9e59c5e145993168ca (patch) | |
tree | d15d6a0504b3ed2a412ba9996fc1d4e4b3f8bdab /tests/ttan.c | |
parent | af45f62b875a1aacf98b28be8d0299e4ef6c665f (diff) | |
download | mpfr-dd4eb0882052970d2004da9e59c5e145993168ca.tar.gz |
added tests for tan(3*Pi/4) and tan(7*Pi/4)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1742 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/ttan.c')
-rw-r--r-- | tests/ttan.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/ttan.c b/tests/ttan.c index 9b7b4c435..b14683dd0 100644 --- a/tests/ttan.c +++ b/tests/ttan.c @@ -55,20 +55,56 @@ int main(int argc, char *argv[]) { mpfr_t x; + unsigned int i; + unsigned int prec[10] = {14, 15, 19, 22, 23, 24, 25, 40, 41, 52}; + unsigned int prec2[10] = {4, 5, 6, 19, 70, 95, 100, 106, 107, 108}; check53(0.0/0.0, 0.0/0.0, GMP_RNDN); check53(1.0/0.0, 0.0/0.0, GMP_RNDN); check53(-1.0/0.0, 0.0/0.0, GMP_RNDN); mpfr_init (x); + mpfr_set_prec (x, 2); mpfr_set_d (x, 0.5, GMP_RNDN); mpfr_tan (x, x, GMP_RNDD); - if (mpfr_get_d(x) != 0.5) + if (mpfr_get_d (x) != 0.5) { fprintf (stderr, "mpfr_tan(0.5, GMP_RNDD) failed\n"); + fprintf (stderr, "expected 0.5, got %f\n", mpfr_get_d (x)); exit (1); } + + /* check that tan(3*Pi/4) ~ -1 */ + for (i=0; i<10; i++) + { + mpfr_set_prec (x, prec[i]); + mpfr_const_pi (x, GMP_RNDN); + mpfr_mul_ui (x, x, 3, GMP_RNDN); + mpfr_div_ui (x, x, 4, GMP_RNDN); + mpfr_tan (x, x, GMP_RNDN); + if (mpfr_cmp_si (x, -1)) + { + fprintf (stderr, "tan(3*Pi/4) fails for prec=%u\n", prec[i]); + exit (1); + } + } + + /* check that tan(7*Pi/4) ~ -1 */ + for (i=0; i<10; i++) + { + mpfr_set_prec (x, prec2[i]); + mpfr_const_pi (x, GMP_RNDN); + mpfr_mul_ui (x, x, 7, GMP_RNDN); + mpfr_div_ui (x, x, 4, GMP_RNDN); + mpfr_tan (x, x, GMP_RNDN); + if (mpfr_cmp_si (x, -1)) + { + fprintf (stderr, "tan(3*Pi/4) fails for prec=%u\n", prec2[i]); + exit (1); + } + } + mpfr_clear (x); test_generic (2, 100, 100); |