diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2009-02-27 15:46:06 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2009-02-27 15:46:06 +0000 |
commit | a309d05a47c66b6b6f389d128cbd8f0da0a2b560 (patch) | |
tree | 3ec96a320edcf8957b3327f21acf2e98f15c8516 | |
parent | 23ec16237536cf5b55267a3e7112b111c94d4a6f (diff) | |
download | mpfr-a309d05a47c66b6b6f389d128cbd8f0da0a2b560.tar.gz |
Untabified and deleted trailing spaces (for patches).
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@6043 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | add.c | 6 | ||||
-rw-r--r-- | div_ui.c | 90 | ||||
-rw-r--r-- | exp.c | 2 | ||||
-rw-r--r-- | mpfr-impl.h | 12 | ||||
-rw-r--r-- | mpfr.h | 2 | ||||
-rw-r--r-- | rem1.c | 2 | ||||
-rw-r--r-- | round_near_x.c | 2 | ||||
-rw-r--r-- | set_z.c | 5 | ||||
-rw-r--r-- | tests/taway.c | 44 | ||||
-rw-r--r-- | tests/tcoth.c | 4 | ||||
-rw-r--r-- | tests/texceptions.c | 8 | ||||
-rw-r--r-- | tests/texp.c | 2 | ||||
-rw-r--r-- | tests/tget_sj.c | 12 | ||||
-rw-r--r-- | tests/tinternals.c | 2 | ||||
-rw-r--r-- | tests/tpow_all.c | 14 | ||||
-rw-r--r-- | zeta.c | 2 | ||||
-rw-r--r-- | zeta_ui.c | 2 |
17 files changed, 105 insertions, 106 deletions
@@ -61,9 +61,9 @@ mpfr_add (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) { if (MPFR_IS_ZERO(c)) { - /* for round away, we take the same convention for 0 + 0 - as for round to zero or to nearest: it always gives +0, - except (-0) + (-0) = -0. */ + /* for round away, we take the same convention for 0 + 0 + as for round to zero or to nearest: it always gives +0, + except (-0) + (-0) = -0. */ MPFR_SET_SIGN(a, (rnd_mode != GMP_RNDD ? ((MPFR_IS_NEG(b) && MPFR_IS_NEG(c)) ? -1 : 1) : @@ -194,51 +194,51 @@ mpfr_div_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mp_rnd_t rnd_mode) { MPFR_UPDATE2_RND_MODE(rnd_mode, MPFR_SIGN (y)); switch (rnd_mode) - { - case GMP_RNDZ: - inexact = - MPFR_INT_SIGN (y); /* result is inexact */ - nexttoinf = 0; - break; - - case GMP_RNDA: - inexact = MPFR_INT_SIGN (y); - nexttoinf = 1; - break; - - default: /* should be GMP_RNDN */ - MPFR_ASSERTD (rnd_mode == GMP_RNDN); - /* We have one more significant bit in yn. */ - if (sh && d < (MPFR_LIMB_ONE << (sh - 1))) - { - inexact = - MPFR_INT_SIGN (y); - nexttoinf = 0; - } - else if (sh && d > (MPFR_LIMB_ONE << (sh - 1))) - { - inexact = MPFR_INT_SIGN (y); - nexttoinf = 1; - } - else /* sh = 0 or d = 1 << (sh-1) */ - { - /* The first case is "false" even rounding (significant bits - indicate even rounding, but the result is inexact, so up) ; - The second case is the case where middle should be used to - decide the direction of rounding (no further bit computed) ; - The third is the true even rounding. - */ - if ((sh && inexact) || (!sh && middle > 0) || - (!inexact && *yp & (MPFR_LIMB_ONE << sh))) - { - inexact = MPFR_INT_SIGN (y); - nexttoinf = 1; - } - else - { - inexact = - MPFR_INT_SIGN (y); - nexttoinf = 0; - } - } - } + { + case GMP_RNDZ: + inexact = - MPFR_INT_SIGN (y); /* result is inexact */ + nexttoinf = 0; + break; + + case GMP_RNDA: + inexact = MPFR_INT_SIGN (y); + nexttoinf = 1; + break; + + default: /* should be GMP_RNDN */ + MPFR_ASSERTD (rnd_mode == GMP_RNDN); + /* We have one more significant bit in yn. */ + if (sh && d < (MPFR_LIMB_ONE << (sh - 1))) + { + inexact = - MPFR_INT_SIGN (y); + nexttoinf = 0; + } + else if (sh && d > (MPFR_LIMB_ONE << (sh - 1))) + { + inexact = MPFR_INT_SIGN (y); + nexttoinf = 1; + } + else /* sh = 0 or d = 1 << (sh-1) */ + { + /* The first case is "false" even rounding (significant bits + indicate even rounding, but the result is inexact, so up) ; + The second case is the case where middle should be used to + decide the direction of rounding (no further bit computed) ; + The third is the true even rounding. + */ + if ((sh && inexact) || (!sh && middle > 0) || + (!inexact && *yp & (MPFR_LIMB_ONE << sh))) + { + inexact = MPFR_INT_SIGN (y); + nexttoinf = 1; + } + else + { + inexact = - MPFR_INT_SIGN (y); + nexttoinf = 0; + } + } + } } if (nexttoinf && @@ -128,7 +128,7 @@ mpfr_exp (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) __gmpfr_emax = 1; mpfr_setmin (y, 1); /* y = 1 */ if (MPFR_IS_POS_SIGN (signx) && (rnd_mode == GMP_RNDU || - rnd_mode == GMP_RNDA)) + rnd_mode == GMP_RNDA)) { mp_size_t yn; int sh; diff --git a/mpfr-impl.h b/mpfr-impl.h index c60f829f9..360c56386 100644 --- a/mpfr-impl.h +++ b/mpfr-impl.h @@ -752,12 +752,12 @@ typedef intmax_t mpfr_eexp_t; /* Transform RNDU and RNDD to RNDZ or RNDA according to sign, leave the other modes unchanged */ -#define MPFR_UPDATE2_RND_MODE(rnd, sign) \ - do { \ - if (rnd == GMP_RNDU) \ - rnd = (sign > 0) ? GMP_RNDA : GMP_RNDZ; \ - else if (rnd == GMP_RNDD) \ - rnd = (sign < 0) ? GMP_RNDA : GMP_RNDZ; \ +#define MPFR_UPDATE2_RND_MODE(rnd, sign) \ + do { \ + if (rnd == GMP_RNDU) \ + rnd = (sign > 0) ? GMP_RNDA : GMP_RNDZ; \ + else if (rnd == GMP_RNDD) \ + rnd = (sign < 0) ? GMP_RNDA : GMP_RNDZ; \ } while (0) @@ -72,7 +72,7 @@ typedef enum { GMP_RNDD, /* round toward -Inf */ GMP_RNDA, /* round away from zero */ GMP_RND_MAX, /* gives number of supported rounding modes, those after are - only supported by some functions */ + only supported by some functions */ GMP_RNDNA=-1 /* round to nearest, with ties away from zero (mpfr_round) */ } mpfr_rnd_t; @@ -197,7 +197,7 @@ mpfr_rem1 (mpfr_ptr rem, long *quo, mp_rnd_t rnd_q, } /* take into account sign of x */ if (signx < 0) - mpz_neg (r, r); + mpz_neg (r, r); inex = mpfr_set_z (rem, r, rnd); /* if ex > ey, rem should be multiplied by 2^ey, else by 2^ex */ MPFR_EXP (rem) += (ex > ey) ? ey : ex; diff --git a/round_near_x.c b/round_near_x.c index 03d423e77..09095c8de 100644 --- a/round_near_x.c +++ b/round_near_x.c @@ -214,7 +214,7 @@ mpfr_round_near_x (mpfr_ptr y, mpfr_srcptr v, mpfr_uexp_t err, int dir, { inexact = -sign; /* Round Away */ - if (rnd != GMP_RNDN && !MPFR_IS_LIKE_RNDZ (rnd, MPFR_IS_NEG_SIGN(sign))) + if (rnd != GMP_RNDN && !MPFR_IS_LIKE_RNDZ (rnd, MPFR_IS_NEG_SIGN(sign))) { /* case nexttoinf */ /* The overflow flag should be set if the result is infinity */ @@ -65,7 +65,7 @@ mpfr_set_z (mpfr_ptr f, mpz_srcptr z, mp_rnd_t rnd_mode) return mpfr_overflow (f, rnd_mode, sign_z); if (MPFR_UNLIKELY (exp + 1 < __gmpfr_emin)) return mpfr_underflow (f, rnd_mode == GMP_RNDN ? GMP_RNDZ : rnd_mode, - sign_z); + sign_z); if (MPFR_LIKELY (dif >= 0)) { @@ -131,7 +131,7 @@ mpfr_set_z (mpfr_ptr f, mpz_srcptr z, mp_rnd_t rnd_mode) || MPFR_UNLIKELY ( (sb | rb) == 0 )) goto trunc; else - goto addoneulp; + goto addoneulp; } trunc: @@ -173,4 +173,3 @@ mpfr_set_z (mpfr_ptr f, mpz_srcptr z, mp_rnd_t rnd_mode) MPFR_SET_SIGN (f, sign_z); MPFR_RET (inex*sign_z); } - diff --git a/tests/taway.c b/tests/taway.c index 3fb4b5619..10bf20663 100644 --- a/tests/taway.c +++ b/tests/taway.c @@ -119,14 +119,14 @@ test3 (int (*testfunc)(mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t), inexd = testfunc (ref1, ref2, ref3, r); if (mpfr_compare (res1, ref1) || inexa != inexd) - { - printf ("Error with RNDA for %s with ", foo); - DISP("x=",ref2); DISP2(", y=",ref3); - printf ("inexa=%d inexd=%d\n", inexa, inexd); - printf ("expected "); mpfr_print_binary (ref1); puts (""); - printf ("got "); mpfr_print_binary (res1); puts (""); - exit (1); - } + { + printf ("Error with RNDA for %s with ", foo); + DISP("x=",ref2); DISP2(", y=",ref3); + printf ("inexa=%d inexd=%d\n", inexa, inexd); + printf ("expected "); mpfr_print_binary (ref1); puts (""); + printf ("got "); mpfr_print_binary (res1); puts (""); + exit (1); + } } mpfr_clear (ref1); @@ -170,14 +170,14 @@ test4 (int (*testfunc)(mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr, set_special (op3, k); inexa = testfunc (res, op1, op2, op3, GMP_RNDA); - r = MPFR_SIGN(res) > 0 ? GMP_RNDU : GMP_RNDD; + r = MPFR_SIGN(res) > 0 ? GMP_RNDU : GMP_RNDD; inexd = testfunc (ref, op1, op2, op3, r); if (mpfr_compare (res, ref) || inexa != inexd) { printf ("Error with RNDA for %s with ", foo); DISP("a=", op1); DISP(", b=", op2); DISP2(", c=", op3); - printf ("inexa=%d inexd=%d\n", inexa, inexd); + printf ("inexa=%d inexd=%d\n", inexa, inexd); DISP("expected ", ref); DISP2(", got ", res); exit (1); } @@ -225,7 +225,7 @@ test2ui (int (*testfunc)(mpfr_ptr, mpfr_srcptr, unsigned long int, mp_rnd_t), { printf ("Error with RNDA for %s for c=%u\n", foo, ref3); DISP2("a=",ref2); - printf ("inexa=%d inexd=%d\n", inexa, inexd); + printf ("inexa=%d inexd=%d\n", inexa, inexd); printf ("expected "); mpfr_print_binary (ref1); puts (""); printf ("got "); mpfr_print_binary (res1); puts (""); exit (1); @@ -265,13 +265,13 @@ testui2 (int (*testfunc)(mpfr_ptr, unsigned long int, mpfr_srcptr, mp_rnd_t), inexd = testfunc (ref1, ref2, ref3, r); if (mpfr_compare (res1, ref1) || inexa != inexd) - { - printf ("Error with RNDA for %s for b=%u\n", foo, ref2); - DISP2("a=", ref3); + { + printf ("Error with RNDA for %s for b=%u\n", foo, ref2); + DISP2("a=", ref3); printf ("inexa=%d inexd=%d\n", inexa, inexd); - DISP("expected ", ref1); DISP2(", got ", res1); - exit (1); - } + DISP("expected ", ref1); DISP2(", got ", res1); + exit (1); + } } mpfr_clear (ref1); @@ -309,7 +309,7 @@ test2 (int (*testfunc)(mpfr_ptr, mpfr_srcptr, mp_rnd_t), char *foo) { printf ("Error with RNDA for %s with ", foo); DISP2("x=", ref2); - printf ("inexa=%d inexd=%d\n", inexa, inexd); + printf ("inexa=%d inexd=%d\n", inexa, inexd); DISP("expected ", ref1); DISP2(", got ", res1); exit (1); } @@ -391,7 +391,7 @@ main (void) while (N--) { /* no need to test mpfr_round, mpfr_ceil, mpfr_floor, mpfr_trunc since - they take no rounding mode */ + they take no rounding mode */ test2ui (mpfr_add_ui, "mpfr_add_ui"); test2ui (mpfr_div_2exp, "mpfr_div_2exp"); @@ -457,7 +457,7 @@ main (void) test2 (mpfr_rint_round, "mpfr_rint_round"); test2 (mpfr_rint_trunc, "mpfr_rint_trunc"); test2 (mpfr_frac, "mpfr_frac"); - + test3 (mpfr_add, "mpfr_add"); test3 (mpfr_sub, "mpfr_sub"); test3 (mpfr_mul, "mpfr_mul"); @@ -468,7 +468,7 @@ main (void) test3 (mpfr_max, "mpfr_max"); /* we don't test reldiff since it does not guarantee correct rounding, - thus we can get different results with RNDA and RNDU or RNDD. */ + thus we can get different results with RNDA and RNDU or RNDD. */ test3 (mpfr_dim, "mpfr_dim"); test3 (mpfr_remainder, "mpfr_remainder"); @@ -477,7 +477,7 @@ main (void) test3 (mpfr_hypot, "mpfr_hypot"); test3a (mpfr_sin_cos, "mpfr_sin_cos"); - + test4 (mpfr_fma, "mpfr_fma"); test4 (mpfr_fms, "mpfr_fms"); diff --git a/tests/tcoth.c b/tests/tcoth.c index c413b5b97..e7ca68336 100644 --- a/tests/tcoth.c +++ b/tests/tcoth.c @@ -159,8 +159,8 @@ underflowed_cothinf (void) err = 1; } mpfr_set_si (y, (i < 0 && (rnd == GMP_RNDD || rnd == GMP_RNDA)) || - (i > 0 && (rnd == GMP_RNDU || rnd == GMP_RNDA)) - ? 2 : 0, GMP_RNDN); + (i > 0 && (rnd == GMP_RNDU || rnd == GMP_RNDA)) + ? 2 : 0, GMP_RNDN); if (i < 0) mpfr_neg (y, y, GMP_RNDN); if (! (mpfr_equal_p (x, y) && diff --git a/tests/texceptions.c b/tests/texceptions.c index b8dba2cfd..51224ae58 100644 --- a/tests/texceptions.c +++ b/tests/texceptions.c @@ -52,10 +52,10 @@ check_default_rnd (void) mpfr_set_default_rounding_mode ((mp_rnd_t) r); t = (mpfr_get_default_rounding_mode) (); if ((mp_rnd_t) r != t) - { - printf ("%s %s\n", mpfr_print_rnd_mode (r), mpfr_print_rnd_mode (t)); - ERROR("ERROR in setting / getting default rounding mode (1)"); - } + { + printf ("%s %s\n", mpfr_print_rnd_mode (r), mpfr_print_rnd_mode (t)); + ERROR("ERROR in setting / getting default rounding mode (1)"); + } } mpfr_set_default_rounding_mode ((mp_rnd_t) GMP_RND_MAX); if (mpfr_get_default_rounding_mode() != GMP_RNDA) diff --git a/tests/texp.c b/tests/texp.c index ca6ddd539..1f63c538b 100644 --- a/tests/texp.c +++ b/tests/texp.c @@ -817,7 +817,7 @@ underflow_up (int extended_emin) flags = MPFR_FLAGS_INEXACT | (((rnd == GMP_RNDU || rnd == GMP_RNDA) - && (i == 1 || j == 0)) || + && (i == 1 || j == 0)) || (rnd == GMP_RNDN && (i == 1 && j == 0)) ? 0 : MPFR_FLAGS_UNDERFLOW); mpfr_clear_flags (); diff --git a/tests/tget_sj.c b/tests/tget_sj.c index 40de1b601..1a7d4a92d 100644 --- a/tests/tget_sj.c +++ b/tests/tget_sj.c @@ -79,9 +79,9 @@ check_sj (intmax_t s, mpfr_ptr x) continue; if (rnd == GMP_RNDU && i > 0) continue; - if (rnd == GMP_RNDA && ((MPFR_IS_POS(y) && i > 0) || - (MPFR_IS_NEG(y) && i < 0))) - continue; + if (rnd == GMP_RNDA && ((MPFR_IS_POS(y) && i > 0) || + (MPFR_IS_NEG(y) && i < 0))) + continue; /* rint (y) == x == s */ r = mpfr_get_sj (y, (mp_rnd_t) rnd); if (r != s) @@ -122,9 +122,9 @@ check_uj (uintmax_t u, mpfr_ptr x) continue; if (rnd == GMP_RNDU && i > 0) continue; - if (rnd == GMP_RNDA && ((MPFR_IS_POS(y) && i > 0) || - (MPFR_IS_NEG(y) && i < 0))) - continue; + if (rnd == GMP_RNDA && ((MPFR_IS_POS(y) && i > 0) || + (MPFR_IS_NEG(y) && i < 0))) + continue; /* rint (y) == x == u */ r = mpfr_get_uj (y, (mp_rnd_t) rnd); if (r != u) diff --git a/tests/tinternals.c b/tests/tinternals.c index a1908086b..f055ad45d 100644 --- a/tests/tinternals.c +++ b/tests/tinternals.c @@ -80,7 +80,7 @@ test_round_near_x (void) So, no failure in this case. */ continue; } - + inex2 = ((dir ^ neg) ? mpfr_add : mpfr_sub) (z, x, eps, (mp_rnd_t) r); if (inex * inex2 <= 0) diff --git a/tests/tpow_all.c b/tests/tpow_all.c index 969e62929..cfb70d727 100644 --- a/tests/tpow_all.c +++ b/tests/tpow_all.c @@ -630,7 +630,7 @@ underflow_up3 (void) /* x = 2 + i * eps, y = emin - 2, x^y ~= 2^(emin - 2) */ expected_inex = rnd == GMP_RNDU || rnd == GMP_RNDA - || (rnd == GMP_RNDN && i < 0) ? 1 : -1; + || (rnd == GMP_RNDN && i < 0) ? 1 : -1; mpfr_set_ui (z0, 0, GMP_RNDN); if (expected_inex > 0) @@ -696,12 +696,12 @@ overflow_inv (void) RND_LOOP (rnd) { int inf, overflow; - mp_rnd_t rnd2; - - if (rnd == GMP_RNDA) - rnd2 = s < 0 ? GMP_RNDD : GMP_RNDU; - else - rnd2 = rnd; + mp_rnd_t rnd2; + + if (rnd == GMP_RNDA) + rnd2 = s < 0 ? GMP_RNDD : GMP_RNDU; + else + rnd2 = rnd; overflow = t == 0 || ((mp_rnd_t) rnd == GMP_RNDN && (precx > 10 || t == 1)) || @@ -346,7 +346,7 @@ mpfr_zeta (mpfr_t z, mpfr_srcptr s, mp_rnd_t rnd_mode) int signs = MPFR_SIGN(s); mpfr_set_si_2exp (z, -1, -1, rnd_mode); /* -1/2 */ if (rnd_mode == GMP_RNDA) - rnd_mode = GMP_RNDD; /* the result is around -1/2, thus negative */ + rnd_mode = GMP_RNDD; /* the result is around -1/2, thus negative */ if ((rnd_mode == GMP_RNDU || rnd_mode == GMP_RNDZ) && signs < 0) { mpfr_nextabove (z); /* z = -1/2 + epsilon */ @@ -50,7 +50,7 @@ mpfr_zeta_ui (mpfr_ptr z, unsigned long m, mp_rnd_t r) int inex; if (r == GMP_RNDA) - r = GMP_RNDU; /* since the result is always positive */ + r = GMP_RNDU; /* since the result is always positive */ if (m >= p) /* 2^(-m) < ulp(1) = 2^(1-p). This means that 2^(-m) <= 1/2*ulp(1). We have 3^(-m)+4^(-m)+... < 2^(-m) |