diff options
author | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-05-06 12:37:21 +0000 |
---|---|---|
committer | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-05-06 12:37:21 +0000 |
commit | 192543932ca7ce494da0f1956475996bdd09e107 (patch) | |
tree | f18814d29b14a45058def73e1f97a2dcba103d9f /tests | |
parent | 4a3ec96bc477f258f2fab8bac31a7ec5059b09ce (diff) | |
download | mpfr-192543932ca7ce494da0f1956475996bdd09e107.tar.gz |
Fix overflow and add corresponding tests.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2908 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tacos.c | 25 | ||||
-rw-r--r-- | tests/tasin.c | 25 | ||||
-rw-r--r-- | tests/tatan.c | 25 | ||||
-rw-r--r-- | tests/texp2.c | 28 | ||||
-rw-r--r-- | tests/ttanh.c | 3 |
5 files changed, 103 insertions, 3 deletions
diff --git a/tests/tacos.c b/tests/tacos.c index 2bbe6ebbb..e1df1cb9b 100644 --- a/tests/tacos.c +++ b/tests/tacos.c @@ -70,6 +70,30 @@ special (void) mpfr_clear (x); } +static void +special_overflow (void) +{ + mpfr_t x, y; + + mpfr_set_emin (-125); + mpfr_set_emax (128); + mpfr_init2 (x, 24); + mpfr_init2 (y, 48); + mpfr_set_str_binary (x, "0.101100100000000000110100E0"); + mpfr_acos (y, x, GMP_RNDN); + if (mpfr_cmp_str (y, "0.110011010100101111000100111010111011010000001001E0", + 2, GMP_RNDN)) + { + printf("Special Overflow error.\n"); + mpfr_dump (y); + exit (1); + } + mpfr_clear (y); + mpfr_clear (x); + mpfr_set_emin (MPFR_EMIN_MIN); + mpfr_set_emax (MPFR_EMAX_MAX); +} + int main (void) { @@ -78,6 +102,7 @@ main (void) tests_start_mpfr (); + special_overflow (); special (); mpfr_init (x); diff --git a/tests/tasin.c b/tests/tasin.c index 12f5037d8..12bdaf579 100644 --- a/tests/tasin.c +++ b/tests/tasin.c @@ -152,12 +152,37 @@ special (void) mpfr_clear (y); } +static void +special_overflow (void) +{ + mpfr_t x, y; + + mpfr_set_emin (-125); + mpfr_set_emax (128); + mpfr_init2 (x, 24); + mpfr_init2 (y, 48); + mpfr_set_str_binary (x, "0.101100100000000000110100E0"); + mpfr_asin (y, x, GMP_RNDN); + if (mpfr_cmp_str (y, "0.110001001101001111110000010110001000111011001000E0", + 2, GMP_RNDN)) + { + printf("Special Overflow error.\n"); + mpfr_dump (y); + exit (1); + } + mpfr_clear (y); + mpfr_clear (x); + mpfr_set_emin (MPFR_EMIN_MIN); + mpfr_set_emax (MPFR_EMAX_MAX); +} + int main (void) { tests_start_mpfr (); special (); + special_overflow (); test_generic (2, 100, 7); diff --git a/tests/tatan.c b/tests/tatan.c index 4967205f5..f0f146ad7 100644 --- a/tests/tatan.c +++ b/tests/tatan.c @@ -152,11 +152,36 @@ special (void) #define TEST_FUNCTION mpfr_atan #include "tgeneric.c" +static void +special_overflow (void) +{ + mpfr_t x, y; + + mpfr_set_emin (-125); + mpfr_set_emax (128); + mpfr_init2 (x, 24); + mpfr_init2 (y, 48); + mpfr_set_str_binary (x, "0.101101010001001101111010E0"); + mpfr_atan (y, x, GMP_RNDN); + if (mpfr_cmp_str (y, "0.100111011001100111000010111101000111010101011110E0", + 2, GMP_RNDN)) + { + printf("Special Overflow error.\n"); + mpfr_dump (y); + exit (1); + } + mpfr_clear (y); + mpfr_clear (x); + mpfr_set_emin (MPFR_EMIN_MIN); + mpfr_set_emax (MPFR_EMAX_MAX); +} + int main (int argc, char *argv[]) { tests_start_mpfr (); + special_overflow (); special (); test_generic (2, 100, 7); diff --git a/tests/texp2.c b/tests/texp2.c index f705b5f48..e304f85d6 100644 --- a/tests/texp2.c +++ b/tests/texp2.c @@ -28,6 +28,32 @@ MA 02111-1307, USA. */ #define TEST_FUNCTION mpfr_exp2 #include "tgeneric.c" +static void +special_overflow (void) +{ + mpfr_t x, y; + + mpfr_set_emin (-125); + mpfr_set_emax (128); + + mpfr_init2 (x, 24); + mpfr_init2 (y, 24); + + mpfr_set_str_binary (x, "0.101100100000000000110100E15"); + mpfr_exp2 (y, x, GMP_RNDN); + if (!mpfr_inf_p(y)) + { + printf("Overflow error.\n"); + mpfr_dump (y); + exit (1); + } + + mpfr_clear (y); + mpfr_clear (x); + mpfr_set_emin (MPFR_EMIN_MIN); + mpfr_set_emax (MPFR_EMAX_MAX); +} + int main (int argc, char *argv[]) { @@ -36,6 +62,8 @@ main (int argc, char *argv[]) tests_start_mpfr (); + special_overflow (); + mpfr_init (x); mpfr_init (y); diff --git a/tests/ttanh.c b/tests/ttanh.c index f8bed846f..c99c8331c 100644 --- a/tests/ttanh.c +++ b/tests/ttanh.c @@ -62,10 +62,8 @@ special_overflow (void) mpfr_set_emin (-125); mpfr_set_emax (128); - mpfr_init2 (x, 24); mpfr_init2 (y, 24); - mpfr_set_str_binary (x, "0.101100100000000000110100E7"); mpfr_tanh (y, x, GMP_RNDN); if (mpfr_cmp_ui (y, 1)) @@ -74,7 +72,6 @@ special_overflow (void) mpfr_dump (y); exit (1); } - mpfr_clear (y); mpfr_clear (x); mpfr_set_emin (MPFR_EMIN_MIN); |