diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-02-16 16:34:39 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-02-16 16:34:39 +0000 |
commit | a85e66202059f9426cc9c4c27a1e6f62ddb12417 (patch) | |
tree | 806b836b417585b3295b3adde4881e74524aebad /tests/tadd.c | |
parent | c507882678500338e756e97555303f76b833c721 (diff) | |
download | mpfr-a85e66202059f9426cc9c4c27a1e6f62ddb12417.tar.gz |
Added overflow check.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2731 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tadd.c')
-rw-r--r-- | tests/tadd.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/tadd.c b/tests/tadd.c index ae4c980ab..71911ba68 100644 --- a/tests/tadd.c +++ b/tests/tadd.c @@ -592,6 +592,32 @@ check_alloc (void) mpfr_clear (a); } +static void +check_overflow (void) +{ + mpfr_t a, b, c; + + mpfr_init2 (a, 256); + mpfr_init2 (b, 256); + mpfr_init2 (c, 256); + + mpfr_clear_overflow (); + mpfr_set_ui (b, 1, GMP_RNDN); + mpfr_setmax (b, mpfr_get_emax ()); + mpfr_set_ui (c, 1, GMP_RNDN); + mpfr_set_exp (c, mpfr_get_emax () - 192); + mpfr_add (a, b, c, GMP_RNDD); + if (!mpfr_overflow_p ()) + { + printf ("No overflow in check_overflow\n"); + exit (1); + } + + mpfr_clear (a); + mpfr_clear (b); + mpfr_clear (c); +} + int main (int argc, char *argv[]) { @@ -836,6 +862,8 @@ main (int argc, char *argv[]) check53("9007199254740994.0", "-1.0", GMP_RNDN, "9007199254740992.0"); check53("9007199254740996.0", "-1.0", GMP_RNDN, "9007199254740996.0"); + check_overflow (); + tests_end_mpfr (); return 0; } |