diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2007-05-22 08:41:00 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2007-05-22 08:41:00 +0000 |
commit | 1524be6e95fdf4fb8d0995de59d4830899bd3fe6 (patch) | |
tree | d352e9e8eca97b1b947454f9182d188e56fadfe3 /tests/tsin.c | |
parent | c6c2a346df7af468a296b9df63ffc5f8f93822b6 (diff) | |
download | mpfr-1524be6e95fdf4fb8d0995de59d4830899bd3fe6.tar.gz |
tsin.c: check sin on +/- 2^(emin-1) (test by Christopher Creutzig).
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@4459 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tsin.c')
-rw-r--r-- | tests/tsin.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/tsin.c b/tests/tsin.c index fd64e5bbe..e7a80e154 100644 --- a/tests/tsin.c +++ b/tests/tsin.c @@ -225,6 +225,52 @@ check_regression () mpfr_clears (x, y, NULL); } +/* Test provided by Christopher Creutzig, 2007-05-21. */ +static void +check_tiny (void) +{ + mpfr_t x, y; + + mpfr_init2 (x, 53); + mpfr_init2 (y, 53); + + mpfr_set_ui (x, 1, GMP_RNDN); + mpfr_set_exp (x, mpfr_get_emin ()); + mpfr_sin (y, x, GMP_RNDD); + if (mpfr_cmp (x, y) < 0) + { + printf ("Error in check_tiny: got sin(x) > x for x = 2^(emin-1)\n"); + exit (1); + } + + mpfr_sin (y, x, GMP_RNDU); + mpfr_mul_2ui (y, y, 1, GMP_RNDU); + if (mpfr_cmp (x, y) > 0) + { + printf ("Error in check_tiny: got sin(x) < x/2 for x = 2^(emin-1)\n"); + exit (1); + } + + mpfr_neg (x, x, GMP_RNDN); + mpfr_sin (y, x, GMP_RNDU); + if (mpfr_cmp (x, y) > 0) + { + printf ("Error in check_tiny: got sin(x) < x for x = -2^(emin-1)\n"); + exit (1); + } + + mpfr_sin (y, x, GMP_RNDD); + mpfr_mul_2ui (y, y, 1, GMP_RNDD); + if (mpfr_cmp (x, y) < 0) + { + printf ("Error in check_tiny: got sin(x) > x/2 for x = -2^(emin-1)\n"); + exit (1); + } + + mpfr_clear (y); + mpfr_clear (x); +} + int main (int argc, char *argv[]) { @@ -311,6 +357,7 @@ main (int argc, char *argv[]) test_generic (2, 100, 15); test_sign (); + check_tiny (); tests_end_mpfr (); return 0; |