summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2018-06-20 12:17:11 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2018-06-20 12:17:11 +0000
commitea41605991674a6117daf362c6ab521c9aadf2c9 (patch)
tree80665c62aa9023aa75d6ac13a246734e94515925
parentdad9867b60449ef9072563fc8fe7cb483ed8e6a3 (diff)
downloadmpfr-ea41605991674a6117daf362c6ab521c9aadf2c9.tar.gz
[tests/tget_set_d64.c] Tests on powers of 10: test negative numbers too.
(merged part of changeset r12792 from the trunk) git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/4.0@12793 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--tests/tget_set_d64.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/tests/tget_set_d64.c b/tests/tget_set_d64.c
index e829aab80..d43778520 100644
--- a/tests/tget_set_d64.c
+++ b/tests/tget_set_d64.c
@@ -423,25 +423,40 @@ static void
powers_of_10 (void)
{
mpfr_t x1, x2;
- int inex1, inex2;
- mpfr_flags_t flags1, flags2;
_Decimal64 d[2];
- int i, neg, rnd;
+ int i, rnd;
+ unsigned int neg;
mpfr_inits2 (200, x1, x2, (mpfr_ptr) 0);
for (i = 0, d[0] = 1, d[1] = 1; i < 150; i++, d[0] *= 10, d[1] /= 10)
- for (neg = 0; neg <= 1; neg++)
+ for (neg = 0; neg <= 3; neg++)
RND_LOOP_NO_RNDF (rnd)
{
- inex1 = mpfr_set_si (x1, neg ? -i : i, MPFR_RNDN);
+ int inex1, inex2;
+ mpfr_flags_t flags1, flags2;
+ mpfr_rnd_t rx1;
+ _Decimal64 dd;
+
+ inex1 = mpfr_set_si (x1, (neg >> 1) ? -i : i, MPFR_RNDN);
MPFR_ASSERTN (inex1 == 0);
+ rx1 = (neg & 1) ?
+ MPFR_INVERT_RND ((mpfr_rnd_t) rnd) : (mpfr_rnd_t) rnd;
mpfr_clear_flags ();
- inex1 = mpfr_exp10 (x1, x1, (mpfr_rnd_t) rnd);
+ inex1 = mpfr_exp10 (x1, x1, rx1);
flags1 = __gmpfr_flags;
+ dd = d[neg >> 1];
+
+ if (neg & 1)
+ {
+ MPFR_SET_NEG (x1);
+ inex1 = -inex1;
+ dd = -dd;
+ }
+
mpfr_clear_flags ();
- inex2 = mpfr_set_decimal64 (x2, d[neg], (mpfr_rnd_t) rnd);
+ inex2 = mpfr_set_decimal64 (x2, dd, (mpfr_rnd_t) rnd);
flags2 = __gmpfr_flags;
if (!(mpfr_equal_p (x1, x2) &&
@@ -460,7 +475,7 @@ powers_of_10 (void)
flags_out (flags2);
exit (1);
}
- }
+ }
mpfr_clears (x1, x2, (mpfr_ptr) 0);
}