diff options
author | thevenyp <thevenyp@280ebfd0-de03-0410-8827-d642c229c3f4> | 2007-09-11 13:01:54 +0000 |
---|---|---|
committer | thevenyp <thevenyp@280ebfd0-de03-0410-8827-d642c229c3f4> | 2007-09-11 13:01:54 +0000 |
commit | 5e318e2944fa3d5de3f58c4ec1ab2224d4873008 (patch) | |
tree | 684929f665eaba133e642665b1cde1fd0b04ecd3 /tests/td_sub.c | |
parent | a10a8c4f72d895d795d20749b7ba79fed4c95b17 (diff) | |
download | mpfr-5e318e2944fa3d5de3f58c4ec1ab2224d4873008.tar.gz |
add some simple test cases in tadd_d.c and friends
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@4837 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/td_sub.c')
-rw-r--r-- | tests/td_sub.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/td_sub.c b/tests/td_sub.c index 732684ea9..a51a8c632 100644 --- a/tests/td_sub.c +++ b/tests/td_sub.c @@ -63,9 +63,41 @@ check_nans (void) int main (int argc, char *argv[]) { + mpfr_t x, y, z; + double d; + int inexact; + MPFR_TEST_USE_RANDS (); tests_start_mpfr (); + /* check with enough precision */ + mpfr_init2 (x, IEEE_DBL_MANT_DIG); + mpfr_init2 (y, IEEE_DBL_MANT_DIG); + mpfr_init2 (z, IEEE_DBL_MANT_DIG); + + mpfr_set_str (y, "4096", 10, GMP_RNDN); + d = 0.125; + mpfr_clear_flags (); + inexact = mpfr_d_sub (x, d, y, GMP_RNDN); + if (inexact != 0) + { + printf ("Inexact flag error in mpfr_d_sub\n"); + exit (1); + } + mpfr_set_str (z, "-4095.875", 10, GMP_RNDN); + if (mpfr_cmp (z, x)) + { + printf ("Error in mpfr_d_sub ("); + mpfr_out_str (stdout, 10, 7, y, GMP_RNDN); + printf (" + %.20g)\nexpected ", d); + mpfr_out_str (stdout, 10, 0, z, GMP_RNDN); + printf ("\ngot "); + mpfr_out_str (stdout, 10, 0, x, GMP_RNDN); + printf ("\n"); + exit (1); + } + mpfr_clears (x, y, z, (void *)0); + check_nans (); test_generic (2, 1000, 100); |