diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2018-04-06 15:02:12 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2018-04-06 15:02:12 +0000 |
commit | 56a9cb76ca0b31fa9ea179f59cb08f8e0b24fd52 (patch) | |
tree | 0ae7a810e909f1d465c8425249217e69a785e27d /tests/tcan_round.c | |
parent | e45f6f935e1ceddcc811befe913885421e909f82 (diff) | |
download | mpfr-56a9cb76ca0b31fa9ea179f59cb08f8e0b24fd52.tar.gz |
[src/round_prec.c] added comments
[src/round_raw_generic.c] removed dead code
[tests/tcan_round.c] improve coverage
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@12561 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tcan_round.c')
-rw-r--r-- | tests/tcan_round.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/tcan_round.c b/tests/tcan_round.c index fa0b1daee..3ed1a441e 100644 --- a/tests/tcan_round.c +++ b/tests/tcan_round.c @@ -276,6 +276,36 @@ check_can_round (void) mpfr_clears (x, xinf, xsup, yinf, ysup, (mpfr_ptr) 0); } +/* test of RNDNA (nearest with ties to away) */ +static void +test_rndna (void) +{ + mpfr_t x; + int inex; + + mpfr_init2 (x, 10); + mpfr_set_str_binary (x, "1111111101"); /* 1021 */ + inex = mpfr_prec_round (x, 9, MPFR_RNDNA); + MPFR_ASSERTN(inex > 0); + MPFR_ASSERTN(mpfr_cmp_ui (x, 1022) == 0); + mpfr_set_prec (x, 10); + mpfr_set_str_binary (x, "1111111101"); /* 1021 */ + inex = mpfr_prec_round (x, 9, MPFR_RNDN); + MPFR_ASSERTN(inex < 0); + MPFR_ASSERTN(mpfr_cmp_ui (x, 1020) == 0); + mpfr_set_prec (x, 10); + mpfr_set_str_binary (x, "1111111011"); /* 1019 */ + inex = mpfr_prec_round (x, 9, MPFR_RNDNA); + MPFR_ASSERTN(inex > 0); + MPFR_ASSERTN(mpfr_cmp_ui (x, 1020) == 0); + mpfr_set_prec (x, 10); + mpfr_set_str_binary (x, "1111111011"); /* 1019 */ + inex = mpfr_prec_round (x, 9, MPFR_RNDN); + MPFR_ASSERTN(inex > 0); + MPFR_ASSERTN(mpfr_cmp_ui (x, 1020) == 0); + mpfr_clear (x); +} + int main (void) { @@ -286,6 +316,7 @@ main (void) tests_start_mpfr (); + test_rndna (); test_simple (); /* checks that rounds to nearest sets the last |