diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2005-08-18 17:03:17 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2005-08-18 17:03:17 +0000 |
commit | d8782b82c961338b15ef888f0bc152566644a964 (patch) | |
tree | 6972f3706c8251eb2b814fb636519519b73bb1f5 | |
parent | bab5aab404897a12fe1c87734ebf2aa270b9b73b (diff) | |
download | mpfr-d8782b82c961338b15ef888f0bc152566644a964.tar.gz |
Removed trailing spaces (better for future patches, as such spaces
are sometimes stripped).
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3726 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | acos.c | 2 | ||||
-rw-r--r-- | acosh.c | 18 | ||||
-rw-r--r-- | add.c | 2 | ||||
-rw-r--r-- | add1sp.c | 28 | ||||
-rw-r--r-- | agm.c | 6 | ||||
-rw-r--r-- | asin.c | 4 | ||||
-rw-r--r-- | asinh.c | 12 | ||||
-rw-r--r-- | atan2.c | 18 | ||||
-rw-r--r-- | atanh.c | 14 | ||||
-rw-r--r-- | cbrt.c | 2 | ||||
-rw-r--r-- | check.c | 6 | ||||
-rw-r--r-- | cmp2.c | 4 | ||||
-rw-r--r-- | cmp_d.c | 12 | ||||
-rw-r--r-- | cmp_si.c | 2 | ||||
-rw-r--r-- | cmp_ui.c | 2 | ||||
-rw-r--r-- | const_euler.c | 2 | ||||
-rw-r--r-- | const_log2.c | 4 | ||||
-rw-r--r-- | const_pi.c | 12 | ||||
-rw-r--r-- | copysign.c | 2 | ||||
-rw-r--r-- | cos.c | 4 | ||||
-rw-r--r-- | coth.c | 2 | ||||
-rw-r--r-- | div-short.c | 12 | ||||
-rw-r--r-- | div.c | 10 | ||||
-rw-r--r-- | dump.c | 2 | ||||
-rw-r--r-- | eint.c | 4 | ||||
-rw-r--r-- | eq.c | 4 | ||||
-rw-r--r-- | erf.c | 4 | ||||
-rw-r--r-- | erfc.c | 4 | ||||
-rw-r--r-- | exceptions.c | 4 | ||||
-rw-r--r-- | exp.c | 6 | ||||
-rw-r--r-- | exp2.c | 26 | ||||
-rw-r--r-- | expm1.c | 4 | ||||
-rw-r--r-- | factorial.c | 24 | ||||
-rw-r--r-- | fits_intmax.c | 4 | ||||
-rw-r--r-- | fits_u.h | 2 | ||||
-rw-r--r-- | fits_uintmax.c | 4 | ||||
-rw-r--r-- | fma.c | 2 | ||||
-rw-r--r-- | frac.c | 2 | ||||
-rw-r--r-- | gamma.c | 2 | ||||
-rw-r--r-- | generic.c | 24 | ||||
-rw-r--r-- | get_d.c | 28 | ||||
-rw-r--r-- | get_str.c | 6 | ||||
-rw-r--r-- | get_uj.c | 4 | ||||
-rw-r--r-- | get_z.c | 4 | ||||
-rw-r--r-- | gmp_op.c | 18 | ||||
-rw-r--r-- | inp_str.c | 2 | ||||
-rw-r--r-- | isinteger.c | 2 | ||||
-rw-r--r-- | log.c | 14 | ||||
-rw-r--r-- | log10.c | 2 | ||||
-rw-r--r-- | log1p.c | 8 | ||||
-rw-r--r-- | log2.c | 4 | ||||
-rw-r--r-- | log_b2.h | 2 | ||||
-rw-r--r-- | minmax.c | 10 | ||||
-rw-r--r-- | mp_clz_tab.c | 2 | ||||
-rw-r--r-- | mpfr-gmp.c | 10 | ||||
-rw-r--r-- | mpfr-gmp.h | 18 | ||||
-rw-r--r-- | mpfr-impl.h | 28 | ||||
-rw-r--r-- | mpfr-test.h | 2 | ||||
-rw-r--r-- | mpn_exp.c | 2 | ||||
-rw-r--r-- | mul.c | 36 | ||||
-rw-r--r-- | mul_ui.c | 6 | ||||
-rw-r--r-- | mulders.c | 6 | ||||
-rw-r--r-- | out_str.c | 6 | ||||
-rw-r--r-- | pow_si.c | 4 | ||||
-rw-r--r-- | pow_ui.c | 2 | ||||
-rw-r--r-- | print_raw.c | 6 | ||||
-rw-r--r-- | random2.c | 2 | ||||
-rw-r--r-- | reldiff.c | 10 | ||||
-rw-r--r-- | root.c | 2 | ||||
-rw-r--r-- | round_p.c | 4 | ||||
-rw-r--r-- | round_prec.c | 8 | ||||
-rw-r--r-- | round_raw_generic.c | 18 | ||||
-rw-r--r-- | set.c | 8 | ||||
-rw-r--r-- | set_d.c | 6 | ||||
-rw-r--r-- | set_q.c | 4 | ||||
-rw-r--r-- | set_si.c | 2 | ||||
-rw-r--r-- | set_ui_2exp.c | 2 | ||||
-rw-r--r-- | set_z.c | 14 | ||||
-rw-r--r-- | sin.c | 16 | ||||
-rw-r--r-- | sin_cos.c | 10 | ||||
-rw-r--r-- | sqrt.c | 2 | ||||
-rw-r--r-- | sub_one_ulp.c | 4 | ||||
-rw-r--r-- | swap.c | 2 | ||||
-rw-r--r-- | tanh.c | 4 | ||||
-rw-r--r-- | tests/memory.c | 2 | ||||
-rw-r--r-- | tests/reuse.c | 8 | ||||
-rw-r--r-- | tests/tabs.c | 4 | ||||
-rw-r--r-- | tests/tacos.c | 6 | ||||
-rw-r--r-- | tests/tadd_ui.c | 4 | ||||
-rw-r--r-- | tests/tagm.c | 6 | ||||
-rw-r--r-- | tests/tasin.c | 2 | ||||
-rw-r--r-- | tests/tatan.c | 12 | ||||
-rw-r--r-- | tests/tcan_round.c | 4 | ||||
-rw-r--r-- | tests/tcheck.c | 2 | ||||
-rw-r--r-- | tests/tcmp.c | 10 | ||||
-rw-r--r-- | tests/tcmp_ld.c | 2 | ||||
-rw-r--r-- | tests/tcmp_ui.c | 8 | ||||
-rw-r--r-- | tests/tcmpabs.c | 12 | ||||
-rw-r--r-- | tests/tconst_log2.c | 6 | ||||
-rw-r--r-- | tests/tcos.c | 8 | ||||
-rw-r--r-- | tests/tcosh.c | 6 | ||||
-rw-r--r-- | tests/tdiv.c | 12 | ||||
-rw-r--r-- | tests/teq.c | 2 | ||||
-rw-r--r-- | tests/terf.c | 8 | ||||
-rw-r--r-- | tests/tests.c | 2 | ||||
-rw-r--r-- | tests/texceptions.c | 6 | ||||
-rw-r--r-- | tests/texp.c | 6 | ||||
-rw-r--r-- | tests/tfits.c | 4 | ||||
-rw-r--r-- | tests/tfma.c | 2 | ||||
-rw-r--r-- | tests/tgamma.c | 6 | ||||
-rw-r--r-- | tests/tgeneric.c | 2 | ||||
-rw-r--r-- | tests/tgeneric_ui.c | 2 | ||||
-rw-r--r-- | tests/tget_sj.c | 6 | ||||
-rw-r--r-- | tests/tget_str.c | 16 | ||||
-rw-r--r-- | tests/tget_z.c | 6 | ||||
-rw-r--r-- | tests/tgmpop.c | 14 | ||||
-rw-r--r-- | tests/tinp_str.c | 2 | ||||
-rw-r--r-- | tests/tlog.c | 12 | ||||
-rw-r--r-- | tests/tlog10.c | 2 | ||||
-rw-r--r-- | tests/tlog1p.c | 2 | ||||
-rw-r--r-- | tests/tlog2.c | 2 | ||||
-rw-r--r-- | tests/tminmax.c | 2 | ||||
-rw-r--r-- | tests/tmul.c | 24 | ||||
-rw-r--r-- | tests/tmul_ui.c | 2 | ||||
-rw-r--r-- | tests/tout_str.c | 2 | ||||
-rw-r--r-- | tests/toutimpl.c | 8 | ||||
-rw-r--r-- | tests/tpow_z.c | 10 | ||||
-rw-r--r-- | tests/trandom.c | 46 | ||||
-rw-r--r-- | tests/trint.c | 4 | ||||
-rw-r--r-- | tests/tset_si.c | 10 | ||||
-rw-r--r-- | tests/tset_sj.c | 16 | ||||
-rw-r--r-- | tests/tset_str.c | 6 | ||||
-rw-r--r-- | tests/tset_z.c | 2 | ||||
-rw-r--r-- | tests/tsi_op.c | 6 | ||||
-rw-r--r-- | tests/tsin.c | 2 | ||||
-rw-r--r-- | tests/tsin_cos.c | 6 | ||||
-rw-r--r-- | tests/tsqr.c | 10 | ||||
-rw-r--r-- | tests/tsqrt.c | 4 | ||||
-rw-r--r-- | tests/tstrtofr.c | 64 | ||||
-rw-r--r-- | tests/tsub_ui.c | 2 | ||||
-rw-r--r-- | tests/ttan.c | 2 | ||||
-rw-r--r-- | tests/ttanh.c | 2 | ||||
-rw-r--r-- | tests/ttrunc.c | 2 | ||||
-rw-r--r-- | tests/tzeta.c | 2 | ||||
-rw-r--r-- | tuneup.c | 54 | ||||
-rw-r--r-- | uceil_log2.c | 2 | ||||
-rw-r--r-- | ufloor_log2.c | 4 | ||||
-rw-r--r-- | ui_pow_ui.c | 2 | ||||
-rw-r--r-- | urandomb.c | 2 |
149 files changed, 583 insertions, 583 deletions
@@ -67,7 +67,7 @@ mpfr_acos (mpfr_ptr acos, mpfr_srcptr x, mp_rnd_t rnd_mode) MPFR_SET_NAN(acos); MPFR_RET_NAN; } - else + else { if (MPFR_IS_POS_SIGN (sign)) /* acos(+1) = 0 */ return mpfr_set_ui (acos, 0, rnd_mode); @@ -26,7 +26,7 @@ MA 02110-1301, USA. */ * acosh= ln(x + sqrt(x^2-1)) */ int -mpfr_acosh (mpfr_ptr y, mpfr_srcptr x , mp_rnd_t rnd_mode) +mpfr_acosh (mpfr_ptr y, mpfr_srcptr x , mp_rnd_t rnd_mode) { MPFR_SAVE_EXPO_DECL (expo); int inexact; @@ -40,23 +40,23 @@ mpfr_acosh (mpfr_ptr y, mpfr_srcptr x , mp_rnd_t rnd_mode) { /* Nan, or zero or -Inf */ if (MPFR_IS_INF (x) && MPFR_IS_POS (x)) - { + { MPFR_SET_INF (y); MPFR_SET_POS (y); MPFR_RET (0); } else /* Nan, or zero or -Inf */ { - MPFR_SET_NAN (y); + MPFR_SET_NAN (y); MPFR_RET_NAN; - } + } } comp = mpfr_cmp_ui (x, 1); if (MPFR_UNLIKELY (comp < 0)) { - MPFR_SET_NAN (y); + MPFR_SET_NAN (y); MPFR_RET_NAN; - } + } else if (MPFR_UNLIKELY (comp == 0)) { MPFR_SET_ZERO (y); /* acosh(1) = 0 */ @@ -64,7 +64,7 @@ mpfr_acosh (mpfr_ptr y, mpfr_srcptr x , mp_rnd_t rnd_mode) MPFR_RET (0); } MPFR_SAVE_EXPO_MARK (expo); - + /* General case */ { /* Declaration of the intermediary variables */ @@ -74,7 +74,7 @@ mpfr_acosh (mpfr_ptr y, mpfr_srcptr x , mp_rnd_t rnd_mode) mp_prec_t Nt; /* Precision of the intermediary variable */ mp_exp_t err, exp_te, exp_ti; /* Precision of error */ MPFR_ZIV_DECL (loop); - + /* compute the precision of intermediary variable */ /* the optimal number of bits : see algorithms.tex */ Nt = Ny + 4 + MPFR_INT_CEIL_LOG2 (Ny); @@ -107,7 +107,7 @@ mpfr_acosh (mpfr_ptr y, mpfr_srcptr x , mp_rnd_t rnd_mode) mpfr_set_prec (t, Nt); } MPFR_ZIV_FREE (loop); - + inexact = mpfr_set (y, t, rnd_mode); mpfr_clear (t); @@ -79,7 +79,7 @@ mpfr_add (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) if (MPFR_UNLIKELY(MPFR_SIGN(b) != MPFR_SIGN(c))) { /* signs differ, it's a subtraction */ - if (MPFR_LIKELY(MPFR_PREC(a) == MPFR_PREC(b) + if (MPFR_LIKELY(MPFR_PREC(a) == MPFR_PREC(b) && MPFR_PREC(b) == MPFR_PREC(c))) return mpfr_sub1sp(a,b,c,rnd_mode); else @@ -102,7 +102,7 @@ mpfr_add1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) MPFR_UNSIGNED_MINUS_MODULO(sh, p); bx = MPFR_GET_EXP(b); d = (mpfr_uexp_t) (bx - MPFR_GET_EXP(c)); - + DEBUG( printf("New add1sp with diff=%lu\n", d) ); if (MPFR_UNLIKELY(d == 0)) @@ -151,8 +151,8 @@ mpfr_add1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) copy_set_exponent: ap = MPFR_MANT (a); MPN_COPY (ap, MPFR_MANT(b), n); - inexact = -1; - goto set_exponent; + inexact = -1; + goto set_exponent; } else { @@ -166,7 +166,7 @@ mpfr_add1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) { /* d==p : Copy B in A */ /* Away: Add 1 - Nearest: Even Rule if C is a power of 2, else Add 1 + Nearest: Even Rule if C is a power of 2, else Add 1 Zero: Trunc */ if (MPFR_LIKELY(rnd_mode==GMP_RNDN)) { @@ -199,7 +199,7 @@ mpfr_add1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) /* General case: 1 <= d < p */ cp = (mp_limb_t*) MPFR_TMP_ALLOC(n * BYTES_PER_MP_LIMB); - + /* Shift c in temporary allocated place */ { mp_exp_unsigned_t dm; @@ -227,7 +227,7 @@ mpfr_add1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) MPN_ZERO(cp+n-m, m); } } - + DEBUG( mpfr_print_mant_binary("Before", MPFR_MANT(c), p) ); DEBUG( mpfr_print_mant_binary("B= ", MPFR_MANT(b), p) ); DEBUG( mpfr_print_mant_binary("After ", cp, p) ); @@ -291,16 +291,16 @@ mpfr_add1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) } } DEBUG( printf("sh=%lu Cp=%lu C'p+1=%lu\n", sh, bcp, bcp1) ); - + /* Clean shifted C' */ mask = ~MPFR_LIMB_MASK(sh); cp[0] &= mask; - + /* Add the mantissa c from b in a */ ap = MPFR_MANT(a); limb = mpn_add_n (ap, MPFR_MANT(b), cp, n); DEBUG( mpfr_print_mant_binary("Add= ", ap, p) ); - + /* Check for overflow */ if (MPFR_UNLIKELY (limb)) { @@ -314,7 +314,7 @@ mpfr_add1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) DEBUG( printf("(Overflow) Cp=%lu C'p+1=%lu\n", bcp, bcp1) ); DEBUG( mpfr_print_mant_binary("Add= ", ap, p) ); } - + /* Round: Zero: Truncate but could be exact. Away: Add 1 if Cp or C'p+1 !=0 @@ -345,8 +345,8 @@ mpfr_add1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) } } MPFR_ASSERTN(0); - - add_one_ulp: + + add_one_ulp: /* add one unit in last place to a */ DEBUG( printf("AddOneUlp\n") ); if (MPFR_UNLIKELY( mpn_add_1(ap, ap, n, MPFR_LIMB_ONE<<sh) )) @@ -357,7 +357,7 @@ mpfr_add1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) ap[n-1] = MPFR_LIMB_HIGHBIT; } inexact = 1; - + set_exponent: if (MPFR_UNLIKELY(bx > __gmpfr_emax)) /* Check for overflow */ { @@ -368,7 +368,7 @@ mpfr_add1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) } MPFR_SET_EXP (a, bx); MPFR_SET_SAME_SIGN(a,b); - + MPFR_TMP_FREE(marker); return inexact*MPFR_INT_SIGN(a); } @@ -126,7 +126,7 @@ mpfr_agm (mpfr_ptr r, mpfr_srcptr op2, mpfr_srcptr op1, mp_rnd_t rnd_mode) { mpfr_div_2ui (tmp, tmp, 1, GMP_RNDN); mpfr_swap (v, tmp); - break; + break; } #elif 1 if (4*eq > p) @@ -148,7 +148,7 @@ mpfr_agm (mpfr_ptr r, mpfr_srcptr op2, mpfr_srcptr op1, mp_rnd_t rnd_mode) /* Roundability of the result */ if (MPFR_LIKELY (MPFR_CAN_ROUND (v, p - 4 - 3, q, rnd_mode))) break; /* Stop the loop */ - + /* Next iteration */ MPFR_ZIV_NEXT (loop, p); s = (p - 1) / BITS_PER_MP_LIMB + 1; @@ -157,7 +157,7 @@ mpfr_agm (mpfr_ptr r, mpfr_srcptr op2, mpfr_srcptr op1, mp_rnd_t rnd_mode) /* Setting of the result */ inexact = mpfr_set (r, v, rnd_mode); - + /* Let's clean */ MPFR_TMP_FREE(marker); @@ -55,7 +55,7 @@ mpfr_asin (mpfr_ptr asin, mpfr_srcptr x, mp_rnd_t rnd_mode) /* Set x_p=|x| (x is a normal number) */ mpfr_init2 (xp, MPFR_PREC (x)); - inexact = mpfr_abs (xp, x, GMP_RNDN); + inexact = mpfr_abs (xp, x, GMP_RNDN); MPFR_ASSERTD (inexact == 0); compared = mpfr_cmp_ui (xp, 1); @@ -88,7 +88,7 @@ mpfr_asin (mpfr_ptr asin, mpfr_srcptr x, mp_rnd_t rnd_mode) mpfr_ui_sub (xp, 1, xp, GMP_RNDD); MPFR_ASSERTD (MPFR_GET_EXP (xp) <= 0); MPFR_ASSERTD (MPFR_GET_EXP (x) <= 0); - xp_exp = 2 - MPFR_GET_EXP (xp); + xp_exp = 2 - MPFR_GET_EXP (xp); /* Set up initial prec */ prec = MPFR_PREC (asin) + 10 + xp_exp; @@ -42,12 +42,12 @@ mpfr_asinh (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) { if (MPFR_IS_NAN (x)) - { - MPFR_SET_NAN (y); + { + MPFR_SET_NAN (y); MPFR_RET_NAN; } else if (MPFR_IS_INF (x)) - { + { MPFR_SET_INF (y); MPFR_SET_SAME_SIGN (y, x); MPFR_RET (0); @@ -70,7 +70,7 @@ mpfr_asinh (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) neg = MPFR_IS_NEG (x); /* General case */ - + /* compute the precision of intermediary variable */ /* the optimal number of bits : see algorithms.tex */ Nt = Ny + 4 + MPFR_INT_CEIL_LOG2 (Ny); @@ -94,7 +94,7 @@ mpfr_asinh (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) /* error estimate -- see algorithms.ps */ err = Nt - (MAX (3 - MPFR_GET_EXP (t), 0) + 1); - if (MPFR_LIKELY (MPFR_IS_ZERO (t) + if (MPFR_LIKELY (MPFR_IS_ZERO (t) || MPFR_CAN_ROUND (t, err, Ny, rnd_mode))) break; @@ -103,7 +103,7 @@ mpfr_asinh (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) mpfr_set_prec (t, Nt); } MPFR_ZIV_FREE (loop); - + inexact = mpfr_set4 (y, t, rnd_mode, signx); mpfr_clear (t); @@ -102,8 +102,8 @@ mpfr_atan2 (mpfr_ptr dest, mpfr_srcptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) if (!MPFR_IS_INF (x)) /* +/- PI/2 */ goto set_pi_2; else if (MPFR_IS_POS (x)) /* +/- PI/4 */ - { - if (MPFR_IS_NEG (y)) + { + if (MPFR_IS_NEG (y)) { rnd_mode = MPFR_INVERT_RND (rnd_mode); inexact = mpfr_const_pi (dest, rnd_mode); @@ -111,7 +111,7 @@ mpfr_atan2 (mpfr_ptr dest, mpfr_srcptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) mpfr_div_2ui (dest, dest, 2, rnd_mode); return -inexact; } - else + else { inexact = mpfr_const_pi (dest, rnd_mode); mpfr_div_2ui (dest, dest, 2, rnd_mode); @@ -119,7 +119,7 @@ mpfr_atan2 (mpfr_ptr dest, mpfr_srcptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) } } else /* +/- 3*PI/4: Ugly since we have to round properly */ - { + { mpfr_t tmp; MPFR_ZIV_DECL (loop); mp_prec_t prec = MPFR_PREC (dest) + BITS_PER_MP_LIMB; @@ -132,12 +132,12 @@ mpfr_atan2 (mpfr_ptr dest, mpfr_srcptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) mpfr_mul_ui (tmp, tmp, 3, GMP_RNDN); /* Error <= 2 */ mpfr_div_2ui (tmp, tmp, 2, GMP_RNDN); if (mpfr_round_p (MPFR_MANT (tmp), MPFR_LIMB_SIZE (tmp), - MPFR_PREC (tmp)-2, + MPFR_PREC (tmp)-2, MPFR_PREC (dest) + (rnd_mode == GMP_RNDN))) break; MPFR_ZIV_NEXT (loop, prec); mpfr_set_prec (tmp, prec); - } + } MPFR_ZIV_FREE (loop); if (MPFR_IS_NEG (y)) MPFR_CHANGE_SIGN (tmp); @@ -149,7 +149,7 @@ mpfr_atan2 (mpfr_ptr dest, mpfr_srcptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) MPFR_ASSERTD (MPFR_IS_INF (x)); if (MPFR_IS_NEG (x)) goto set_pi; - else + else goto set_zero; } MPFR_SAVE_EXPO_MARK (expo); @@ -189,7 +189,7 @@ mpfr_atan2 (mpfr_ptr dest, mpfr_srcptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) if (MPFR_IS_NEG (y)) MPFR_CHANGE_SIGN (tmp); /* Error(tmp) <= (1/2+2^(EXP(pi)-EXP(tmp)-1)+2^(e-EXP(tmp)+1))*ulp - <= 2^(MAX (MAX (EXP(PI)-EXP(tmp)-1, e-EXP(tmp)+1), + <= 2^(MAX (MAX (EXP(PI)-EXP(tmp)-1, e-EXP(tmp)+1), -1)+2)*ulp(tmp) */ e = MAX (MAX (MPFR_GET_EXP (pi)-MPFR_GET_EXP (tmp) - 1, e - MPFR_GET_EXP (tmp) + 1), -1) + 2; @@ -203,7 +203,7 @@ mpfr_atan2 (mpfr_ptr dest, mpfr_srcptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) mpfr_clear (pi); } MPFR_ZIV_FREE (loop); - + inexact = mpfr_set (dest, tmp, rnd_mode); mpfr_clear (tmp); MPFR_SAVE_EXPO_FREE (expo); @@ -26,7 +26,7 @@ MA 02110-1301, USA. */ atanh= 1/2*ln(x+1)-1/2*ln(1-x) */ int -mpfr_atanh (mpfr_ptr y, mpfr_srcptr xt , mp_rnd_t rnd_mode) +mpfr_atanh (mpfr_ptr y, mpfr_srcptr xt , mp_rnd_t rnd_mode) { int inexact; mpfr_t x, t, te; @@ -44,7 +44,7 @@ mpfr_atanh (mpfr_ptr y, mpfr_srcptr xt , mp_rnd_t rnd_mode) /* atanh(NaN) = NaN, and atanh(+/-Inf) = NaN since tanh gives a result between -1 and 1 */ if (MPFR_IS_NAN (xt) || MPFR_IS_INF (xt)) - { + { MPFR_SET_NAN (y); MPFR_RET_NAN; } @@ -90,31 +90,31 @@ mpfr_atanh (mpfr_ptr y, mpfr_srcptr xt , mp_rnd_t rnd_mode) /* First computation of cosh */ MPFR_ZIV_INIT (loop, Nt); for (;;) - { + { /* compute atanh */ mpfr_ui_sub (te, 1, x, GMP_RNDU); /* (1-xt)*/ mpfr_add_ui (t, x, 1, GMP_RNDD); /* (xt+1)*/ mpfr_div (t, t, te, GMP_RNDN); /* (1+xt)/(1-xt)*/ mpfr_log (t, t, GMP_RNDN); /* ln((1+xt)/(1-xt))*/ mpfr_div_2ui (t, t, 1, GMP_RNDN); /* (1/2)*ln((1+xt)/(1-xt))*/ - + /* error estimate see- algorithms.ps*/ /* err=Nt-__gmpfr_ceil_log2(1+5*pow(2,1-MPFR_EXP(t)));*/ err = Nt - (MAX (4 - MPFR_GET_EXP (t), 0) + 1); - + if (MPFR_LIKELY (MPFR_IS_ZERO (t) || MPFR_CAN_ROUND (t, err, Ny, rnd_mode))) break; /* reactualisation of the precision */ MPFR_ZIV_NEXT (loop, Nt); - mpfr_set_prec (t, Nt); + mpfr_set_prec (t, Nt); mpfr_set_prec (te, Nt); } MPFR_ZIV_FREE (loop); inexact = mpfr_set4 (y, t, rnd_mode, MPFR_SIGN (xt)); - + mpfr_clear(t); mpfr_clear(te); @@ -123,7 +123,7 @@ mpfr_cbrt (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) { if (negative) rnd_mode = MPFR_INVERT_RND (rnd_mode); - if (rnd_mode == GMP_RNDU + if (rnd_mode == GMP_RNDU || (rnd_mode == GMP_RNDN && mpz_tstbit (m, 0))) inexact = 1, mpz_add_ui (m, m, 1); else @@ -23,7 +23,7 @@ MA 02110-1301, USA. */ /* * Check if x is a valid mpfr_t initializes by mpfr_init - * Returns 0 if isn't valid + * Returns 0 if isn't valid */ int mpfr_check (mpfr_srcptr x) @@ -45,7 +45,7 @@ mpfr_check (mpfr_srcptr x) return 0; /* Check size of mantissa */ s = MPFR_GET_ALLOC_SIZE(x); - if (s<=0 || s > MP_SIZE_T_MAX || + if (s<=0 || s > MP_SIZE_T_MAX || MPFR_PREC(x) > ((mp_prec_t)s*BITS_PER_MP_LIMB)) return 0; /* Acces all the mp_limb of the mantissa: may do a seg fault */ @@ -69,7 +69,7 @@ mpfr_check (mpfr_srcptr x) if ((MPFR_EXP (x) < __gmpfr_emin) || (MPFR_EXP (x) > __gmpfr_emax)) return 0; } - else + else { /* Singular value is zero, inf or nan */ MPFR_ASSERTD(MPFR_IS_ZERO(x) || MPFR_IS_NAN(x) || MPFR_IS_INF(x)); @@ -46,7 +46,7 @@ mpfr_cmp2 (mpfr_srcptr b, mpfr_srcptr c, mp_prec_t *cancel) sub1sp would be called instead */ MPFR_ASSERTD (b != c); - /* the cases b=0 or c=0 are also treated apart in agm and sub + /* the cases b=0 or c=0 are also treated apart in agm and sub (which calls sub1) */ MPFR_ASSERTD (MPFR_IS_PURE_FP(b)); MPFR_ASSERTD (MPFR_IS_PURE_FP(c)); @@ -144,7 +144,7 @@ mpfr_cmp2 (mpfr_srcptr b, mpfr_srcptr c, mp_prec_t *cancel) dif = bp[bn--] - cc; /* necessarily dif >= 1 */ - while (MPFR_UNLIKELY ((cn >= 0 || lastc != 0) + while (MPFR_UNLIKELY ((cn >= 0 || lastc != 0) && (high_dif == 0) && (dif == 1))) { /* dif=1 implies diff_exp = 0 or 1 */ bb = (bn >= 0) ? bp[bn] : 0; @@ -21,17 +21,17 @@ MA 02110-1301, USA. */ #include "mpfr-impl.h" -int +int mpfr_cmp_d (mpfr_srcptr b, double d) { - mpfr_t tmp; - int res; + mpfr_t tmp; + int res; mpfr_init2 (tmp, IEEE_DBL_MANT_DIG); res = mpfr_set_d (tmp, d, GMP_RNDN); MPFR_ASSERTD (res == 0); - res = mpfr_cmp (b, tmp); - mpfr_clear (tmp); + res = mpfr_cmp (b, tmp); + mpfr_clear (tmp); - return res; + return res; } @@ -29,7 +29,7 @@ MA 02110-1301, USA. */ b must not be NaN. */ -int +int mpfr_cmp_si_2exp (mpfr_srcptr b, long int i, mp_exp_t f) { int si; @@ -29,7 +29,7 @@ MA 02110-1301, USA. */ b must not be NaN */ -int +int mpfr_cmp_ui_2exp (mpfr_srcptr b, unsigned long int i, mp_exp_t f) { if (MPFR_UNLIKELY( MPFR_IS_SINGULAR(b) )) diff --git a/const_euler.c b/const_euler.c index 794afcbe9..d43314819 100644 --- a/const_euler.c +++ b/const_euler.c @@ -82,7 +82,7 @@ mpfr_const_euler_internal (mpfr_t x, mp_rnd_t rnd) break; MPFR_ZIV_NEXT (loop, m); mpfr_set_prec (y, m); - mpfr_set_prec (z, m); + mpfr_set_prec (z, m); } MPFR_ZIV_FREE (loop); diff --git a/const_log2.c b/const_log2.c index d5532381a..ead718e53 100644 --- a/const_log2.c +++ b/const_log2.c @@ -32,7 +32,7 @@ mpfr_const_log2 (mpfr_ptr x, mp_rnd_t rnd_mode) { return mpfr_cache (x, __gmpfr_cache_const_log2, rnd_mode); } -/* Auxiliary function: Compute the terms from n1 to n2 (excluded) +/* Auxiliary function: Compute the terms from n1 to n2 (excluded) 3/4*sum((-1)^n*n!^2/2^n/(2*n+1)!, n = n1..n2-1). Numerator is T[0], denominator is Q[0], Compute P[0] only when need_P is non-zero. @@ -174,7 +174,7 @@ mpfr_const_log2_internal (mpfr_ptr x, mp_rnd_t rnd_mode) } (*__gmp_free_func) (T, 3 * lgN * sizeof (mpz_t)); - if (MPFR_LIKELY (ok != 0 + if (MPFR_LIKELY (ok != 0 || mpfr_can_round (t, w - 2, GMP_RNDN, rnd_mode, n))) break; diff --git a/const_pi.c b/const_pi.c index 3dc0292b9..093a7dc87 100644 --- a/const_pi.c +++ b/const_pi.c @@ -48,20 +48,20 @@ mpfr_const_pi_internal (mpfr_ptr x, mp_rnd_t rnd_mode) for (kmax = 2; ((px + 2 * kmax + 12) / 9) >> kmax; kmax ++); p = px + 3 * kmax + 14; /* guarantees no recomputation for px <= 10000 */ - + mpfr_init2 (a, p); mpfr_init2 (A, p); mpfr_init2 (B, p); mpfr_init2 (D, p); mpfr_init2 (S, p); - + MPFR_ZIV_INIT (loop, p); - for (;;) { + for (;;) { mpfr_set_ui (a, 1, GMP_RNDN); /* a = 1 */ mpfr_set_ui (A, 1, GMP_RNDN); /* A = a^2 = 1 */ mpfr_set_ui_2exp (B, 1, -1, GMP_RNDN); /* B = b^2 = 1/2 */ mpfr_set_ui_2exp (D, 1, -2, GMP_RNDN); /* D = 1/4 */ - + #define b B #define ap a #define Ap A @@ -97,7 +97,7 @@ mpfr_const_pi_internal (mpfr_ptr x, mp_rnd_t rnd_mode) /* MPFR_ASSERTN(p >= 2 * k + 8); */ if (MPFR_LIKELY (MPFR_CAN_ROUND (A, p - 2 * k - 8, px, rnd_mode))) break; - + p += kmax; MPFR_ZIV_NEXT (loop, p); mpfr_set_prec (a, p); @@ -105,7 +105,7 @@ mpfr_const_pi_internal (mpfr_ptr x, mp_rnd_t rnd_mode) mpfr_set_prec (B, p); mpfr_set_prec (D, p); mpfr_set_prec (S, p); - } + } MPFR_ZIV_FREE (loop); inex = mpfr_set (x, A, rnd_mode); diff --git a/copysign.c b/copysign.c index fdec323e7..fe417a08d 100644 --- a/copysign.c +++ b/copysign.c @@ -22,7 +22,7 @@ MA 02110-1301, USA. */ #include "mpfr-impl.h" /* - The computation of z with magnitude of x and sign of y + The computation of z with magnitude of x and sign of y z = sign(y) * abs(x) */ @@ -108,7 +108,7 @@ mpfr_cos (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) /* Compute initial precision */ precy = MPFR_PREC (y); /* We can choose everything we want for K0. - This formula has been created by trying many things... + This formula has been created by trying many things... and is far from perfect */ K0 = (MPFR_GET_EXP (x) > 0) ? (MPFR_GET_EXP (x)) : 0 ; K0 = __gmpfr_isqrt (precy / (2+2*K0+MPFR_INT_CEIL_LOG2 (precy)/4) ); @@ -137,7 +137,7 @@ mpfr_cos (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) { mpfr_mul (s, s, s, GMP_RNDU); /* err <= 2*olderr */ MPFR_SET_EXP (s, MPFR_GET_EXP (s)+1); /* Can't overflow */ - mpfr_sub (s, s, r, GMP_RNDN); /* err <= 4*olderr */ + mpfr_sub (s, s, r, GMP_RNDN); /* err <= 4*olderr */ MPFR_ASSERTD (MPFR_GET_EXP (s) <= 1); } @@ -19,7 +19,7 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Place, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* the hyperbolic cotangent is defined by coth(x) = 1/tanh(x) +/* the hyperbolic cotangent is defined by coth(x) = 1/tanh(x) coth (NaN) = NaN. coth (+Inf) = 1 coth (-Inf) = -1 diff --git a/div-short.c b/div-short.c index 110a9cdf3..2a4c0abcc 100644 --- a/div-short.c +++ b/div-short.c @@ -50,10 +50,10 @@ mpn_dc_divrem_n_new (mp_ptr qp, mp_ptr np, mp_srcptr dp, mp_size_t n) ql -= mpn_sub_1 (qp, qp, l, (mp_limb_t) 1); cc -= mpn_add_n (np, np, dp, n); } - + /* propagate ql */ qh += mpn_add_1 (qp + l, qp + l, m, ql); - + return qh; } @@ -92,10 +92,10 @@ mpn_dc_divrem_n_high (mp_ptr qp, mp_ptr np, mp_srcptr dp, mp_size_t n) } ql = DIVREM_HIGH (qp, np + m, dp + m, l); - + /* propagate ql */ qh += mpn_add_1 (qp + l, qp + l, m, ql); - + return qh; } @@ -151,7 +151,7 @@ void bench (int argc, const char *argv[]) if (i >= 0) printf ("limbs %d differ: %lu %lu %ld\n", i, qp[i], q2p[i], - (long) q2p[i]-qp[i]); + (long) q2p[i]-qp[i]); } void @@ -238,5 +238,5 @@ main (int argc, const char *argv[]) check (argc-1, argv+1); else bench (argc, argv); - return 0; + return 0; } @@ -281,7 +281,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode) sticky_u = sticky_u || mpn_cmpzero (up, k); } low_u = sticky_u; - + /* now sticky_u is non-zero iff the truncated part of u is non-zero */ /* prepare the divisor */ @@ -426,7 +426,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode) printf ("cmp(q*v0,r+u0)=%d\n", cmp_s_r); #endif /* now cmp_s_r > 0 if {sp, vsize} > {ap, qsize} + low(u) - cmp_s_r = 0 if {sp, vsize} = {ap, qsize} + low(u) + cmp_s_r = 0 if {sp, vsize} = {ap, qsize} + low(u) cmp_s_r < 0 if {sp, vsize} < {ap, qsize} + low(u) */ if (cmp_s_r <= 0) /* quotient is in [q1, q1+1) */ { @@ -564,7 +564,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode) case_1: /* quotient is in [q1, q1+1), round_bit is the round_bit (0 for directed rounding), sticky the sticky bit */ - if (rnd_mode == GMP_RNDZ || rnd_mode == GMP_RNDD || + if (rnd_mode == GMP_RNDZ || rnd_mode == GMP_RNDD || (round_bit == MPFR_LIMB_ZERO && sticky == MPFR_LIMB_ZERO)) { inex = (round_bit == MPFR_LIMB_ZERO && sticky == MPFR_LIMB_ZERO) ? 0 : -1; @@ -587,7 +587,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode) goto add_one_ulp; /* with inex=1 */ sub_two_ulp: - /* we cannot subtract MPFR_LIMB_MPFR_LIMB_ONE << (sh+1) since this is + /* we cannot subtract MPFR_LIMB_MPFR_LIMB_ONE << (sh+1) since this is undefined for sh = BITS_PER_MP_LIMB */ qh -= mpn_sub_1 (q0p, q0p, q0size, MPFR_LIMB_ONE << sh); /* go through */ @@ -617,7 +617,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode) qexp ++; q0p[q0size - 1] = MPFR_LIMB_HIGHBIT; } - + truncate: /* inex already set */ MPFR_TMP_FREE(marker); @@ -28,6 +28,6 @@ MA 02110-1301, USA. */ void mpfr_dump (mpfr_srcptr u) { - mpfr_print_binary(u); + mpfr_print_binary(u); putchar('\n'); } @@ -142,7 +142,7 @@ mpfr_eint_aux (mpfr_t y, mpfr_srcptr x) return e; } -int +int mpfr_eint (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd) { int inex; @@ -186,7 +186,7 @@ mpfr_eint (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd) } /* Init stuff */ - MPFR_SAVE_EXPO_MARK (expo); + MPFR_SAVE_EXPO_MARK (expo); prec = MPFR_PREC (y) + 2 * MPFR_INT_CEIL_LOG2 (MPFR_PREC (y)) + 6; mpfr_init2 (tmp, prec); mpfr_init2 (ump, prec); @@ -92,7 +92,7 @@ mpfr_eq (mpfr_srcptr u, mpfr_srcptr v, unsigned long int n_bits) /* now either k < 0: all low bits from u are zero or remains < BITS_PER_MP_LIMB: check high bits from up[k] or up[k] <> 0: different */ - if (k >= 0 && (((remains < BITS_PER_MP_LIMB) && + if (k >= 0 && (((remains < BITS_PER_MP_LIMB) && (up[k] >> (BITS_PER_MP_LIMB - remains))) || (remains >= BITS_PER_MP_LIMB && up[k]))) return 0; /* surely too different */ @@ -109,7 +109,7 @@ mpfr_eq (mpfr_srcptr u, mpfr_srcptr v, unsigned long int n_bits) /* If size is too large wrt n_bits, reduce it to look only at the high n_bits bits. Otherwise, if n_bits > size * BITS_PER_MP_LIMB, reduce n_bits to - size * BITS_PER_MP_LIMB, since the extra low bits of one of the + size * BITS_PER_MP_LIMB, since the extra low bits of one of the operands have already been check above. */ if ((unsigned long) size > 1 + (n_bits - 1) / BITS_PER_MP_LIMB) size = 1 + (n_bits - 1) / BITS_PER_MP_LIMB; @@ -64,7 +64,7 @@ mpfr_erf (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) otherwise use asymptotic expansion */ MPFR_SAVE_EXPO_MARK (expo); - if (MPFR_UNLIKELY (xf > LOG2 * ((double) MPFR_PREC (y)))) + if (MPFR_UNLIKELY (xf > LOG2 * ((double) MPFR_PREC (y)))) /* |erf x| = 1 or 1- */ { mp_rnd_t rnd2 = MPFR_IS_POS (x) ? rnd_mode : MPFR_INVERT_RND(rnd_mode); @@ -88,7 +88,7 @@ mpfr_erf (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) } /* return x*2^e */ -static double +static double mul_2exp (double x, mp_exp_t e) { if (e > 0) @@ -24,7 +24,7 @@ MA 02110-1301, USA. */ /* erfc(x) = 1 - erf(x) */ -int +int mpfr_erfc (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd) { int inex; @@ -47,7 +47,7 @@ mpfr_erfc (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd) /* erfc(+inf) = 0+, erfc(-inf) = 2 erfc (0) = 1 */ else if (MPFR_IS_INF (x)) return mpfr_set_ui (y, MPFR_IS_POS (x) ? 0 : 2, rnd); - else + else return mpfr_set_ui (y, 1, rnd); } diff --git a/exceptions.c b/exceptions.c index a42aec3ee..914a15664 100644 --- a/exceptions.c +++ b/exceptions.c @@ -50,13 +50,13 @@ mpfr_set_emin (mp_exp_t exponent) } } -mp_exp_t +mp_exp_t mpfr_get_emin_min (void) { return MPFR_EMIN_MIN; } -mp_exp_t +mp_exp_t mpfr_get_emin_max (void) { return MPFR_EMIN_MAX; @@ -102,7 +102,7 @@ mpfr_exp (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) { mp_size_t yn; int sh; - + yn = 1 + (MPFR_PREC(y) - 1) / BITS_PER_MP_LIMB; sh = (mp_prec_t) yn * BITS_PER_MP_LIMB - MPFR_PREC(y); MPFR_MANT(y)[0] += MPFR_LIMB_ONE << sh; @@ -114,11 +114,11 @@ mpfr_exp (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) } /* General case */ - else + else { MPFR_SAVE_EXPO_MARK (expo); __gmpfr_emin -= 3; /* So that we can check for underflow properly */ - + if (MPFR_UNLIKELY (precy > MPFR_EXP_THRESHOLD)) inexact = mpfr_exp_3 (y, x, rnd_mode); /* O(M(n) log(n)^2) */ else @@ -1,4 +1,4 @@ -/* mpfr_exp2 -- power of 2 function 2^y +/* mpfr_exp2 -- power of 2 function 2^y Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation. @@ -28,8 +28,8 @@ MA 02110-1301, USA. */ * y = exp(z*log(2)). The result is exact iff z is an integer. */ int -mpfr_exp2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) -{ +mpfr_exp2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) +{ int inexact; MPFR_SAVE_EXPO_DECL (expo); @@ -55,7 +55,7 @@ mpfr_exp2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) return mpfr_set_ui (y, 1, rnd_mode); } } - + /* since the smallest representable non-zero float is 1/2*2^__gmpfr_emin, if x < __gmpfr_emin - 1, the result is either 1/2*2^__gmpfr_emin or 0 */ MPFR_ASSERTD (MPFR_EMIN_MIN - 2 >= LONG_MIN); @@ -73,13 +73,13 @@ mpfr_exp2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) if (mpfr_integer_p (x)) /* we know that x >= 2^(emin-1) */ { long xd; - + MPFR_ASSERTD (MPFR_EMAX_MAX <= LONG_MAX); if (mpfr_cmp_si_2exp (x, __gmpfr_emax, 0) > 0) return mpfr_overflow (y, rnd_mode, 1); - + xd = mpfr_get_si (x, GMP_RNDN); - + mpfr_set_ui (y, 1, GMP_RNDZ); return mpfr_mul_2si (y, y, xd, rnd_mode); } @@ -90,7 +90,7 @@ mpfr_exp2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) { /* Declaration of the intermediary variable */ mpfr_t t; - + /* Declaration of the size variable */ mp_prec_t Ny = MPFR_PREC(y); /* target precision */ mp_prec_t Nt; /* working precision */ @@ -100,10 +100,10 @@ mpfr_exp2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) /* compute the precision of intermediary variable */ /* the optimal number of bits : see algorithms.tex */ Nt = Ny + 5 + MPFR_INT_CEIL_LOG2 (Ny); - + /* initialise of intermediary variable */ mpfr_init2 (t, Nt); - + /* First computation */ MPFR_ZIV_INIT (loop, Nt); for (;;) @@ -113,10 +113,10 @@ mpfr_exp2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) mpfr_mul (t, x, t, GMP_RNDU); /* x*ln(2) */ err = Nt - (MPFR_GET_EXP (t) + 2); /* Estimate of the error */ mpfr_exp (t, t, GMP_RNDN); /* exp(x*ln(2))*/ - + if (MPFR_LIKELY (MPFR_CAN_ROUND (t, err, Ny, rnd_mode))) break; - + /* Actualisation of the precision */ MPFR_ZIV_NEXT (loop, Nt); mpfr_set_prec (t, Nt); @@ -124,7 +124,7 @@ mpfr_exp2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) MPFR_ZIV_FREE (loop); inexact = mpfr_set (y, t, rnd_mode); - + mpfr_clear (t); } MPFR_SAVE_EXPO_FREE (expo); @@ -27,7 +27,7 @@ MA 02110-1301, USA. */ */ int -mpfr_expm1 (mpfr_ptr y, mpfr_srcptr x , mp_rnd_t rnd_mode) +mpfr_expm1 (mpfr_ptr y, mpfr_srcptr x , mp_rnd_t rnd_mode) { int inexact; MPFR_SAVE_EXPO_DECL (expo); @@ -41,7 +41,7 @@ mpfr_expm1 (mpfr_ptr y, mpfr_srcptr x , mp_rnd_t rnd_mode) } /* check for inf or -inf (expm1(-inf)=-1) */ else if (MPFR_IS_INF (x)) - { + { if (MPFR_IS_POS (x)) { MPFR_SET_INF (y); diff --git a/factorial.c b/factorial.c index 682ee732d..dd146a397 100644 --- a/factorial.c +++ b/factorial.c @@ -28,21 +28,21 @@ MA 02110-1301, USA. */ */ int -mpfr_fac_ui (mpfr_ptr y, unsigned long int x, mp_rnd_t rnd_mode) +mpfr_fac_ui (mpfr_ptr y, unsigned long int x, mp_rnd_t rnd_mode) { mpfr_t t; /* Variable of Intermediary Calculation*/ unsigned long i; int round, inexact; - + mp_prec_t Ny; /* Precision of output variable */ mp_prec_t Nt; /* Precision of Intermediary Calculation variable */ mp_prec_t err; /* Precision of error */ - + mp_rnd_t rnd; MPFR_SAVE_EXPO_DECL (expo); MPFR_ZIV_DECL (loop); - /***** test x = 0 and x == 1******/ + /***** test x = 0 and x == 1******/ if (MPFR_UNLIKELY (x <= 1)) return mpfr_set_ui (y, 1, GMP_RNDN); /* 0! = 1 and 1! = 1 */ @@ -50,18 +50,18 @@ mpfr_fac_ui (mpfr_ptr y, unsigned long int x, mp_rnd_t rnd_mode) /* Initialisation of the Precision */ Ny = MPFR_PREC (y); - + /* compute the size of intermediary variable */ Nt = Ny + 2 * MPFR_INT_CEIL_LOG2 (x) + 7; - + mpfr_init2 (t, Nt); /* initialise of intermediary variable */ - + rnd = GMP_RNDZ; MPFR_ZIV_INIT (loop, Nt); for (;;) { /* compute factorial */ - inexact = mpfr_set_ui (t, 1, rnd); + inexact = mpfr_set_ui (t, 1, rnd); for (i = 2 ; i <= x ; i++) { round = mpfr_mul_ui (t, t, i, rnd); @@ -70,12 +70,12 @@ mpfr_fac_ui (mpfr_ptr y, unsigned long int x, mp_rnd_t rnd_mode) if (inexact == 0) inexact = round; } - + err = Nt - 1 - MPFR_INT_CEIL_LOG2 (Nt); round = !inexact || mpfr_can_round (t, err, rnd, GMP_RNDZ, Ny + (rnd_mode == GMP_RNDN)); - + if (MPFR_LIKELY (round)) { /* If inexact = 0, then t is exactly x!, so round is the @@ -87,11 +87,11 @@ mpfr_fac_ui (mpfr_ptr y, unsigned long int x, mp_rnd_t rnd_mode) inexact = round; break; } - else if ((inexact < 0 && round <= 0) + else if ((inexact < 0 && round <= 0) || (inexact > 0 && round >= 0)) break; else /* inexact and round have opposite signs: we cannot - compute the inexact flag. Restart using the + compute the inexact flag. Restart using the symmetric rounding. */ rnd = (rnd == GMP_RNDZ) ? GMP_RNDU : GMP_RNDZ; } diff --git a/fits_intmax.c b/fits_intmax.c index 5bf644ec2..786071d9a 100644 --- a/fits_intmax.c +++ b/fits_intmax.c @@ -93,8 +93,8 @@ mpfr_fits_intmax_p (mpfr_srcptr f, mp_rnd_t rnd) mpfr_set (x, f, rnd); mpfr_set_sj (y, neg ? INTMAX_MIN : INTMAX_MAX, GMP_RNDN); - - res = (neg + + res = (neg ? (mpfr_cmp (x, y) >= 0) : (mpfr_cmp (x, y) <= 0)); @@ -37,7 +37,7 @@ FUNCTION (mpfr_srcptr f, mp_rnd_t rnd) else if (MPFR_IS_NEG (f)) /* Negative numbers doesn't fit */ return 0; - /* now it fits if + /* now it fits if (a) f <= MAXIMUM (b) round(f, prec(slong), rnd) <= MAXIMUM */ diff --git a/fits_uintmax.c b/fits_uintmax.c index ee4353848..090b3294c 100644 --- a/fits_uintmax.c +++ b/fits_uintmax.c @@ -50,7 +50,7 @@ mpfr_fits_uintmax_p (mpfr_srcptr f, mp_rnd_t rnd) mp_prec_t prec; uintmax_t s; mpfr_t x, y; - int res; + int res; if (MPFR_IS_NAN(f) || MPFR_IS_INF(f) || MPFR_SIGN(f) < 0) return 0; /* does not fit */ @@ -58,7 +58,7 @@ mpfr_fits_uintmax_p (mpfr_srcptr f, mp_rnd_t rnd) if (MPFR_IS_ZERO(f)) return 1; /* zero always fits */ - /* now it fits if + /* now it fits if (a) f <= MAXIMUM (b) round(f, prec(slong), rnd) <= MAXIMUM */ @@ -50,7 +50,7 @@ mpfr_fma (mpfr_ptr s, mpfr_srcptr x, mpfr_srcptr y, mpfr_srcptr z, /* cases Inf*0+z, 0*Inf+z, Inf-Inf */ if ((MPFR_IS_ZERO(y)) || (MPFR_IS_ZERO(x)) || - (MPFR_IS_INF(z) && + (MPFR_IS_INF(z) && ((MPFR_MULT_SIGN(MPFR_SIGN(x), MPFR_SIGN(y))) != MPFR_SIGN(z)))) { MPFR_SET_NAN(s); @@ -95,7 +95,7 @@ mpfr_frac (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode) fq = uq - ue; /* number of bits of the fractional part of u */ /* Temporary fix */ - t = /* fq > MPFR_PREC(r) */ + t = /* fq > MPFR_PREC(r) */ (mp_size_t) (MPFR_PREC(r) - 1) / BITS_PER_MP_LIMB < un ? (mpfr_init2 (tmp, (un + 1) * BITS_PER_MP_LIMB), tmp) : r; /* t has enough precision to contain the fractional part of u */ @@ -29,7 +29,7 @@ MA 02110-1301, USA. */ #define MPFR_NEED_LONGLONG_H #include "mpfr-impl.h" -/* We use the reflection formula +/* We use the reflection formula Gamma(1+t) Gamma(1-t) = - Pi t / sin(Pi (1 + t)) in order to treat the case x <= 1, i.e. with x = 1-t, then Gamma(x) = -Pi*(1-x)/sin(Pi*(2-x))/GAMMA(2-x) @@ -20,7 +20,7 @@ the Free Software Foundation, Inc., 51 Franklin Place, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef GENERIC - # error You should specify a name + # error You should specify a name #endif #ifdef B @@ -50,7 +50,7 @@ GENERIC (mpfr_ptr y, mpz_srcptr p, long r, int m) MPFR_TMP_DECL(marker); MPFR_TMP_MARK(marker); - MPFR_CLEAR_FLAGS(y); + MPFR_CLEAR_FLAGS(y); n = 1UL << m; P = (mpz_t*) MPFR_TMP_ALLOC ((m+1) * sizeof(mpz_t)); S = (mpz_t*) MPFR_TMP_ALLOC ((m+1) * sizeof(mpz_t)); @@ -87,8 +87,8 @@ GENERIC (mpfr_ptr y, mpz_srcptr p, long r, int m) mpz_set_ui (T[0], A1); # endif #endif - if (!is_p_one) - for (i = 1 ; i < m ; i++) + if (!is_p_one) + for (i = 1 ; i < m ; i++) mpz_mul (ptoj[i], ptoj[i-1], ptoj[i-1]); #ifdef R_IS_RATIONAL mpz_set_si (qtoj[0], r); @@ -101,15 +101,15 @@ GENERIC (mpfr_ptr y, mpz_srcptr p, long r, int m) k = 0; for (i = 1 ; i < n ; i++) { k++; - + #ifdef A -# ifdef B +# ifdef B mpz_set_ui (T[k], (A1 + A2*i)*(B1+B2*i)); # else mpz_set_ui (T[k], A1 + A2*i); # endif #endif - + #ifdef C # ifdef NO_FACTORIAL mpz_set_ui (P[k], (C1 + C2 * (i-1))); @@ -128,7 +128,7 @@ GENERIC (mpfr_ptr y, mpz_srcptr p, long r, int m) #endif for (j = i+1, l = 0 ; (j & 1) == 0 ; l++, j>>=1, k--) { - if (!is_p_one) + if (!is_p_one) mpz_mul (S[k], S[k], ptoj[l]); #ifdef A # ifdef B @@ -136,7 +136,7 @@ GENERIC (mpfr_ptr y, mpz_srcptr p, long r, int m) mpz_mul_ui (P[k], P[k], A2*B2); # endif # else -# if A2 != 1 +# if A2 != 1 mpz_mul_ui (P[k], P[k], A2); # endif #endif @@ -155,12 +155,12 @@ GENERIC (mpfr_ptr y, mpz_srcptr p, long r, int m) #endif } } - + diff = mpz_sizeinbase(S[0],2) - 2*precy; expo = diff; if (diff >= 0) mpz_div_2exp(S[0],S[0],diff); - else + else mpz_mul_2exp(S[0],S[0],-diff); diff = mpz_sizeinbase(P[0],2) - precy; expo -= diff; @@ -187,7 +187,7 @@ GENERIC (mpfr_ptr y, mpz_srcptr p, long r, int m) { mpz_clear (P[i]); mpz_clear (S[i]); - mpz_clear (ptoj[i]); + mpz_clear (ptoj[i]); #ifdef R_IS_RATIONAL mpz_clear (qtoj[i]); #endif @@ -48,27 +48,27 @@ struct dbl_bytes { #define MPFR_DBL_NAN (* (const double *) dbl_nan.b) #if HAVE_DOUBLE_IEEE_LITTLE_ENDIAN -static const struct dbl_bytes dbl_infp = +static const struct dbl_bytes dbl_infp = { { 0, 0, 0, 0, 0, 0, 0xF0, 0x7F }, 0.0 }; -static const struct dbl_bytes dbl_infm = +static const struct dbl_bytes dbl_infm = { { 0, 0, 0, 0, 0, 0, 0xF0, 0xFF }, 0.0 }; -static const struct dbl_bytes dbl_nan = +static const struct dbl_bytes dbl_nan = { { 0, 0, 0, 0, 0, 0, 0xF8, 0x7F }, 0.0 }; #endif #if HAVE_DOUBLE_IEEE_LITTLE_SWAPPED -static const struct dbl_bytes dbl_infp = +static const struct dbl_bytes dbl_infp = { { 0, 0, 0xF0, 0x7F, 0, 0, 0, 0 }, 0.0 }; -static const struct dbl_bytes dbl_infm = +static const struct dbl_bytes dbl_infm = { { 0, 0, 0xF0, 0xFF, 0, 0, 0, 0 }, 0.0 }; -static const struct dbl_bytes dbl_nan = +static const struct dbl_bytes dbl_nan = { { 0, 0, 0xF8, 0x7F, 0, 0, 0, 0 }, 0.0 }; #endif #if HAVE_DOUBLE_IEEE_BIG_ENDIAN -static const struct dbl_bytes dbl_infp = +static const struct dbl_bytes dbl_infp = { { 0x7F, 0xF0, 0, 0, 0, 0, 0, 0 }, 0.0 }; -static const struct dbl_bytes dbl_infm = +static const struct dbl_bytes dbl_infm = { { 0xFF, 0xF0, 0, 0, 0, 0, 0, 0 }, 0.0 }; -static const struct dbl_bytes dbl_nan = +static const struct dbl_bytes dbl_nan = { { 0x7F, 0xF8, 0, 0, 0, 0, 0, 0 }, 0.0 }; #endif @@ -80,7 +80,7 @@ static const struct dbl_bytes dbl_nan = #endif /* _GMP_IEEE_FLOATS */ - + /* multiplies 1/2 <= d <= 1 by 2^exp */ static double mpfr_scale2 (double d, int exp) @@ -162,17 +162,17 @@ mpfr_get_d (mpfr_srcptr src, mp_rnd_t rnd_mode) return MPFR_DBL_NAN; negative = MPFR_IS_NEG (src); - + if (MPFR_IS_INF (src)) return negative ? MPFR_DBL_INFM : MPFR_DBL_INFP; - + MPFR_ASSERTD (MPFR_IS_ZERO(src)); return negative ? -0.0 : 0.0; } - + e = MPFR_GET_EXP (src); negative = MPFR_IS_NEG (src); - + /* the smallest normalized number is 2^(-1022)=0.1e-1021, and the smallest subnormal is 2^(-1074)=0.1e-1073 */ if (MPFR_UNLIKELY (e < -1073)) @@ -209,7 +209,7 @@ mpfr_ceil_double (double x) */ static int mpfr_get_str_aux (char *const str, mp_exp_t *const exp, mp_limb_t *const r, - mp_size_t n, mp_exp_t f, long e, int b, size_t m, + mp_size_t n, mp_exp_t f, long e, int b, size_t m, mp_rnd_t rnd) { int dir; /* direction of the rounded result */ @@ -257,7 +257,7 @@ mpfr_get_str_aux (char *const str, mp_exp_t *const exp, mp_limb_t *const r, n * BITS_PER_MP_LIMB + f, rnd, &dir); MPFR_ASSERTD(dir != MPFR_ROUND_FAILED); - /* warning: mpfr_round_raw_generic returns MPFR_EVEN_INEX (2) or + /* warning: mpfr_round_raw_generic returns MPFR_EVEN_INEX (2) or -MPFR_EVEN_INEX (-2) in case of even rounding */ if (ret) /* Y is a power of 2 */ @@ -695,7 +695,7 @@ mpfr_get_str (char *s, mp_exp_t *e, int b, size_t m, mpfr_srcptr x, mp_rnd_t rnd exp ++; } } - else + else break; MPFR_TMP_FREE(marker); @@ -62,7 +62,7 @@ mpfr_get_uj (mpfr_srcptr f, mpfr_rnd_t rnd) { } /* Now, r = 0. */ - + mpfr_init2 (x, prec); mpfr_rint (x, f, rnd); MPFR_ASSERTN (MPFR_IS_FP (x)); @@ -79,7 +79,7 @@ mpfr_get_uj (mpfr_srcptr f, mpfr_rnd_t rnd) for (n = MPFR_LIMB_SIZE(x) - 1; n >= 0; n--) { sh -= BITS_PER_MP_LIMB; - r += (sh >= 0 + r += (sh >= 0 ? (uintmax_t) xp[n] << sh : (uintmax_t) xp[n] >> (- sh)); } @@ -1,4 +1,4 @@ -/* mpfr_get_z_exp -- get a multiple-precision integer from +/* mpfr_get_z_exp -- get a multiple-precision integer from a floating-point number Copyright 2004 Free Software Foundation, Inc. @@ -27,7 +27,7 @@ mpfr_get_z (mpz_ptr z, mpfr_srcptr f, mp_rnd_t rnd) { mpfr_t r; mp_exp_t exp = MPFR_EXP (f); - + /* if exp <= 0, then |f|<1, thus |o(f)|<=1 */ MPFR_ASSERTD (MPFR_PREC_MIN == 2); mpfr_init2 (r, (exp <= 0) ? MPFR_PREC_MIN : exp + 1); @@ -40,8 +40,8 @@ init_set_z (mpfr_ptr t, mpz_srcptr z) MPFR_ASSERTD (i == 0); } -/* Init, set a mpfr_t with enought precision to store a mpz_t without round, - call the function, and clear the allocated mpfr_t */ +/* Init, set a mpfr_t with enought precision to store a mpz_t without round, + call the function, and clear the allocated mpfr_t */ static int foo (mpfr_ptr x, mpfr_srcptr y, mpz_srcptr z, mp_rnd_t r, int (*f)(mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t)) @@ -94,7 +94,7 @@ mpfr_cmp_z (mpfr_srcptr x, mpz_srcptr z) init_set_z (t, z); res = mpfr_cmp (x, t); mpfr_clear (t); - return res; + return res; } int @@ -175,13 +175,13 @@ mpfr_add_q (mpfr_ptr y, mpfr_srcptr x, mpq_srcptr z, mp_rnd_t rnd_mode) p = MPFR_PREC (y) + 10; mpfr_init2 (t, p); mpfr_init2 (q, p); - + MPFR_ZIV_INIT (loop, p); for (;;) { res = mpfr_set_q (q, z, GMP_RNDN); /* Error <= 1/2 ulp(q) */ /* If z if @INF@ (1/0), res = 0, so it quits immediately */ - if (MPFR_UNLIKELY (res == 0)) + if (MPFR_UNLIKELY (res == 0)) /* Result is exact so we can add it directly! */ { res = mpfr_add (y, x, q, rnd_mode); @@ -198,14 +198,14 @@ mpfr_add_q (mpfr_ptr y, mpfr_srcptr x, mpq_srcptr z, mp_rnd_t rnd_mode) err = (mp_exp_t) p - 1 - MAX (MPFR_GET_EXP(q)-MPFR_GET_EXP(t), 0); if (MPFR_LIKELY (MPFR_CAN_ROUND (t, err, MPFR_PREC (y), rnd_mode))) { - res = mpfr_set (y, t, rnd_mode); + res = mpfr_set (y, t, rnd_mode); break; } } MPFR_ZIV_NEXT (loop, p); mpfr_set_prec (t, p); mpfr_set_prec (q, p); - } + } MPFR_ZIV_FREE (loop); mpfr_clear (t); mpfr_clear (q); @@ -238,7 +238,7 @@ mpfr_sub_q (mpfr_ptr y, mpfr_srcptr x, mpq_srcptr z,mp_rnd_t rnd_mode) else { MPFR_ASSERTD (MPFR_IS_ZERO (x)); - + if (MPFR_UNLIKELY (mpq_sgn (z) == 0)) return mpfr_set (y, x, rnd_mode); /* signed 0 - Unsigned 0 */ else @@ -253,7 +253,7 @@ mpfr_sub_q (mpfr_ptr y, mpfr_srcptr x, mpq_srcptr z,mp_rnd_t rnd_mode) p = MPFR_PREC (y) + 10; mpfr_init2 (t, p); mpfr_init2 (q, p); - + MPFR_ZIV_INIT (loop, p); for(;;) { @@ -35,7 +35,7 @@ mpfr_inp_str (mpfr_ptr rop, FILE *stream, int base, mp_rnd_t rnd_mode) int retval; size_t nread; - MPFR_CLEAR_FLAGS(rop); + MPFR_CLEAR_FLAGS(rop); if (stream == NULL) stream = stdin; diff --git a/isinteger.c b/isinteger.c index 008e3e7c3..0e7e27f31 100644 --- a/isinteger.c +++ b/isinteger.c @@ -22,7 +22,7 @@ MA 02110-1301, USA. */ #include "mpfr-impl.h" -int +int mpfr_integer_p (mpfr_srcptr x) { mp_exp_t expo; @@ -42,11 +42,11 @@ mpfr_log (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode) { int inexact; mp_prec_t p, q; - mpfr_t tmp1, tmp2; + mpfr_t tmp1, tmp2; mp_limb_t *tmp1p, *tmp2p; MPFR_ZIV_DECL (loop); MPFR_TMP_DECL(marker); - + MPFR_LOG_FUNC (("a[%#R]=%R rnd=%d", a, a, rnd_mode), ("r[%#R]=%R inexact=%d", r, r, inexact)); @@ -105,11 +105,11 @@ mpfr_log (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode) m=q; while (m) { p++; m >>= 1; } */ /* if (MPFR_LIKELY(p % BITS_PER_MP_LIMB != 0)) p += BITS_PER_MP_LIMB - (p%BITS_PER_MP_LIMB); */ - + MPFR_TMP_MARK(marker); MPFR_ZIV_INIT (loop, p); - for (;;) + for (;;) { mp_size_t size; long m; @@ -117,9 +117,9 @@ mpfr_log (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode) /* Calculus of m (depends on p) */ m = (p + 1) / 2 - MPFR_GET_EXP (a) + 1; - + /* All the mpfr_t needed have a precision of p */ - size = (p-1)/BITS_PER_MP_LIMB+1; + size = (p-1)/BITS_PER_MP_LIMB+1; MPFR_TMP_INIT (tmp1p, tmp1, p, size); MPFR_TMP_INIT (tmp2p, tmp2, p, size); @@ -139,7 +139,7 @@ mpfr_log (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode) if (MPFR_UNLIKELY (cancel < 0)) cancel = 0; - + /* we have 7 ulps of error from the above roundings, 4 ulps from the 4/s^2 second order term, plus the canceled bits */ @@ -117,7 +117,7 @@ mpfr_log10 (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode) /* log10(10^n) is exact: FIXME: Can we have 10^n exactly representable as a mpfr_t but n can't fit an unsigned long? */ - if (MPFR_IS_POS (t) + if (MPFR_IS_POS (t) && mpfr_integer_p (t) && mpfr_fits_ulong_p (t, GMP_RNDN) && !mpfr_ui_pow_ui (tt, 10, mpfr_get_ui (t, GMP_RNDN), GMP_RNDN) && mpfr_cmp (a, tt) == 0) @@ -33,9 +33,9 @@ mpfr_log1p (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) { - if (MPFR_IS_NAN (x)) + if (MPFR_IS_NAN (x)) { - MPFR_SET_NAN (y); + MPFR_SET_NAN (y); MPFR_RET_NAN; } /* check for inf or -inf (result is not defined) */ @@ -67,7 +67,7 @@ mpfr_log1p (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) comp = mpfr_cmp_si (x, -1); /* log1p(x) is undefined for x < -1 */ - if (MPFR_UNLIKELY(comp <= 0)) + if (MPFR_UNLIKELY(comp <= 0)) { if (comp == 0) /* x=0: log1p(-1)=-inf (division by zero) */ @@ -87,7 +87,7 @@ mpfr_log1p (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) /* Declaration of the intermediary variable */ mpfr_t t; /* Declaration of the size variable */ - mp_prec_t Ny = MPFR_PREC(y); /* target precision */ + mp_prec_t Ny = MPFR_PREC(y); /* target precision */ mp_prec_t Nt; /* working precision */ mp_exp_t err; /* error */ MPFR_ZIV_DECL (loop); @@ -111,12 +111,12 @@ mpfr_log2 (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode) mpfr_const_log2(t,GMP_RNDD); /* log(2) */ mpfr_log(tt,a,GMP_RNDN); /* log(a) */ mpfr_div(t,tt,t,GMP_RNDN); /* log(a)/log(2) */ - + /* estimation of the error */ err = Nt-3; if (MPFR_LIKELY (MPFR_CAN_ROUND (t, err, Ny, rnd_mode))) break; - + /* actualisation of the precision */ MPFR_ZIV_NEXT (loop, Nt); mpfr_set_prec (t, Nt); @@ -1,6 +1,6 @@ /* used by mpfr_get_str and mpfr_set_str */ -/* for 2 <= b <= 36, log_b2[b-2] + log_b2_low[b-2] is a 76-bit upper +/* for 2 <= b <= 36, log_b2[b-2] + log_b2_low[b-2] is a 76-bit upper approximation of log(2)/log(b), with log_b2[b-2] having 23 significative bits only. These approximations were computed with the following program. @@ -1,4 +1,4 @@ -/* mpfr_min -- min and max of x, y +/* mpfr_min -- min and max of x, y Copyright 2001, 2003, 2004 Free Software Foundation, Inc. @@ -34,8 +34,8 @@ mpfr_min (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, mp_rnd_t rnd_mode) if (MPFR_ARE_SINGULAR(x,y)) { if (MPFR_IS_NAN(x) && MPFR_IS_NAN(y) ) - { - MPFR_SET_NAN(z); + { + MPFR_SET_NAN(z); MPFR_RET_NAN; } else if (MPFR_IS_NAN(x)) @@ -67,8 +67,8 @@ mpfr_max (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, mp_rnd_t rnd_mode) { if (MPFR_ARE_SINGULAR(x,y)) { - if (MPFR_IS_NAN(x) && MPFR_IS_NAN(y) ) - { + if (MPFR_IS_NAN(x) && MPFR_IS_NAN(y) ) + { MPFR_SET_NAN(z); MPFR_RET_NAN; } diff --git a/mp_clz_tab.c b/mp_clz_tab.c index c681892b5..2ae238990 100644 --- a/mp_clz_tab.c +++ b/mp_clz_tab.c @@ -3,7 +3,7 @@ THE CONTENTS OF THIS FILE ARE FOR INTERNAL USE AND MAY CHANGE INCOMPATIBLY OR DISAPPEAR IN A FUTURE GNU MP RELEASE. -Copyright 1991, 1993, 1994, 1996, 1997, 2000, 2001, 2004 Free Software +Copyright 1991, 1993, 1994, 1996, 1997, 2000, 2001, 2004 Free Software Foundation,Inc. This file is part of the GNU MP Library. diff --git a/mpfr-gmp.c b/mpfr-gmp.c index cfbcbe50b..e1ce60410 100644 --- a/mpfr-gmp.c +++ b/mpfr-gmp.c @@ -321,7 +321,7 @@ mpfr_init_gmp_rand () { /* Since we don't use __gmp_rands, but mpfr_rands, we need to init __gmp_rands before setting the memory functions so that the tests - don't report an error. + don't report an error. Only the tests which call mpn_random2 can do that: trandom, tset_f and reuse. So we just have to call mpn_random before. */ @@ -344,7 +344,7 @@ mpfr_default_allocate (size_t size) ret = malloc (size); if (ret == NULL) { - fprintf (stderr, "MPFR: Can't allocate memory (size=%lu)\n", + fprintf (stderr, "MPFR: Can't allocate memory (size=%lu)\n", (unsigned long) size); abort (); } @@ -358,7 +358,7 @@ mpfr_default_reallocate (void *oldptr, size_t old_size, size_t new_size) ret = realloc (oldptr, new_size); if (ret == NULL) { - fprintf (stderr, + fprintf (stderr, "MPFR: Can't reallocate memory (old_size=%lu new_size=%lu)\n", (unsigned long) old_size, (unsigned long) new_size); abort (); @@ -375,8 +375,8 @@ mpfr_default_free (void *blk_ptr, size_t blk_size) #endif /* Have gmp-impl.h */ #ifndef MPFR_HAVE_MPN_SUB_NC -mp_limb_t -mpfr_sub_nc (mp_ptr dest, mp_srcptr op1, mp_srcptr op2, mp_size_t s, +mp_limb_t +mpfr_sub_nc (mp_ptr dest, mp_srcptr op1, mp_srcptr op2, mp_size_t s, mp_limb_t c) { mp_limb_t c2; diff --git a/mpfr-gmp.h b/mpfr-gmp.h index 98175ba66..f68c5d5f7 100644 --- a/mpfr-gmp.h +++ b/mpfr-gmp.h @@ -61,13 +61,13 @@ extern "C" { # define GMP_NUMB_BITS BITS_PER_MP_LIMB # ifndef GMP_NAIL_BITS # define GMP_NAIL_BITS 0 -# endif +# endif #else # error "Could not detect BITS_PER_MP_LIMB. Try with gmp internal files." #endif /* Define some macros */ -#define BYTES_PER_MP_LIMB (BITS_PER_MP_LIMB/CHAR_BIT) +#define BYTES_PER_MP_LIMB (BITS_PER_MP_LIMB/CHAR_BIT) #define MP_LIMB_T_MAX (~(mp_limb_t)0) @@ -139,7 +139,7 @@ extern "C" { #endif /* ASSERT */ -__MPFR_DECLSPEC void mpfr_assert_fail _MPFR_PROTO((const char *, int, +__MPFR_DECLSPEC void mpfr_assert_fail _MPFR_PROTO((const char *, int, const char *)); #define ASSERT_FAIL(expr) mpfr_assert_fail (__FILE__, __LINE__, #expr) @@ -194,7 +194,7 @@ typedef unsigned int UHWtype; /* Use (4.0 * ...) instead of (2.0 * ...) to work around buggy compilers that don't convert ulong->double correctly (eg. SunOS 4 native cc). */ -#undef MP_BASE_AS_DOUBLE +#undef MP_BASE_AS_DOUBLE #define MP_BASE_AS_DOUBLE (4.0 * ((mp_limb_t) 1 << (GMP_NUMB_BITS - 2))) /* Structure for conversion between internal binary format and @@ -251,7 +251,7 @@ typedef __gmp_randstate_struct *gmp_randstate_ptr; __MPFR_DECLSPEC void mpfr_rand_raw _MPFR_PROTO((mp_ptr, gmp_randstate_t, unsigned long)); -/* To be called BEFORE tests_start_mpfr () if the tests used +/* To be called BEFORE tests_start_mpfr () if the tests used mpfr_random, mpfr_random2 or any functions which uses the macro RANDS */ __MPFR_DECLSPEC void mpfr_init_gmp_rand _MPFR_PROTO((void)); #define MPFR_TEST_USE_RANDS() mpfr_init_gmp_rand (); @@ -264,9 +264,9 @@ __MPFR_DECLSPEC void mpfr_init_gmp_rand _MPFR_PROTO((void)); Just getting the correct value by calling mp_get_memory_functions */ #ifdef mp_get_memory_functions -#undef __gmp_allocate_func -#undef __gmp_reallocate_func -#undef __gmp_free_func +#undef __gmp_allocate_func +#undef __gmp_reallocate_func +#undef __gmp_free_func #define MPFR_GET_MEMFUNC mp_get_memory_functions(&mpfr_allocate_func, &mpfr_reallocate_func, &mpfr_free_func) #define __gmp_allocate_func (MPFR_GET_MEMFUNC, mpfr_allocate_func) #define __gmp_reallocate_func (MPFR_GET_MEMFUNC, mpfr_reallocate_func) @@ -286,7 +286,7 @@ __MPFR_DECLSPEC extern void (*mpfr_free_func) _MPFR_PROTO ((void *, #define __gmp_default_reallocate mpfr_default_reallocate #define __gmp_default_free mpfr_default_free __MPFR_DECLSPEC void *__gmp_default_allocate _MPFR_PROTO ((size_t)); -__MPFR_DECLSPEC void *__gmp_default_reallocate _MPFR_PROTO ((void *, size_t, +__MPFR_DECLSPEC void *__gmp_default_reallocate _MPFR_PROTO ((void *, size_t, size_t)); __MPFR_DECLSPEC void __gmp_default_free _MPFR_PROTO ((void *, size_t)); diff --git a/mpfr-impl.h b/mpfr-impl.h index 45ef19c16..d236e511d 100644 --- a/mpfr-impl.h +++ b/mpfr-impl.h @@ -243,7 +243,7 @@ __MPFR_DECLSPEC extern MPFR_THREAD_ATTR const mpfr_t __gmpfr_four; ((int) (__gmpfr_flags & MPFR_FLAGS_INEXACT)) #define mpfr_erangeflag_p() \ ((int) (__gmpfr_flags & MPFR_FLAGS_ERANGE)) - + /****************************************************** ******************** Assertions ********************** @@ -1236,7 +1236,7 @@ typedef struct { /* Check if we can support this feature */ # ifdef MPFR_USE_THREAD_SAFE # error "Enable either `Logging' or `thread-safe', not both" -# endif +# endif # if !__MPFR_GNUC(3,0) # error "Logging not supported (GCC >= 3.0)" # endif @@ -1423,15 +1423,15 @@ extern "C" { __MPFR_DECLSPEC int mpfr_underflow _MPFR_PROTO ((mpfr_ptr, mp_rnd_t, int)); __MPFR_DECLSPEC int mpfr_overflow _MPFR_PROTO ((mpfr_ptr, mp_rnd_t, int)); -__MPFR_DECLSPEC int mpfr_add1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, +__MPFR_DECLSPEC int mpfr_add1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t)); -__MPFR_DECLSPEC int mpfr_sub1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, +__MPFR_DECLSPEC int mpfr_sub1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t)); -__MPFR_DECLSPEC int mpfr_add1sp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, +__MPFR_DECLSPEC int mpfr_add1sp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t)); -__MPFR_DECLSPEC int mpfr_sub1sp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, +__MPFR_DECLSPEC int mpfr_sub1sp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t)); -__MPFR_DECLSPEC int mpfr_can_round_raw _MPFR_PROTO ((const mp_limb_t *, +__MPFR_DECLSPEC int mpfr_can_round_raw _MPFR_PROTO ((const mp_limb_t *, mp_size_t, int, mp_exp_t, mp_rnd_t, mp_rnd_t, mp_prec_t)); __MPFR_DECLSPEC int mpfr_cmp2 _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr, @@ -1459,13 +1459,13 @@ __MPFR_DECLSPEC void mpfr_print_mant_binary _MPFR_PROTO ((const char*, const mp_limb_t*, mp_prec_t)); __MPFR_DECLSPEC void mpfr_set_str_binary _MPFR_PROTO((mpfr_ptr, const char*)); -__MPFR_DECLSPEC int mpfr_round_raw _MPFR_PROTO ((mp_limb_t *, +__MPFR_DECLSPEC int mpfr_round_raw _MPFR_PROTO ((mp_limb_t *, const mp_limb_t *, mp_prec_t, int, mp_prec_t, mp_rnd_t, int *)); -__MPFR_DECLSPEC int mpfr_round_raw_2 _MPFR_PROTO ((const mp_limb_t *, +__MPFR_DECLSPEC int mpfr_round_raw_2 _MPFR_PROTO ((const mp_limb_t *, mp_prec_t, int, mp_prec_t, mp_rnd_t)); __MPFR_DECLSPEC int mpfr_round_raw_3 _MPFR_PROTO ((const mp_limb_t *, mp_prec_t, int, mp_prec_t, mp_rnd_t, int *)); -__MPFR_DECLSPEC int mpfr_round_raw_4 _MPFR_PROTO ((mp_limb_t *, +__MPFR_DECLSPEC int mpfr_round_raw_4 _MPFR_PROTO ((mp_limb_t *, const mp_limb_t *, mp_prec_t, int, mp_prec_t, mp_rnd_t)); #define mpfr_round_raw2(xp, xn, neg, r, prec) \ @@ -1485,17 +1485,17 @@ __MPFR_DECLSPEC int mpfr_const_pi_internal _MPFR_PROTO ((mpfr_ptr,mp_rnd_t)); __MPFR_DECLSPEC int mpfr_const_log2_internal _MPFR_PROTO((mpfr_ptr,mp_rnd_t)); __MPFR_DECLSPEC int mpfr_const_euler_internal _MPFR_PROTO((mpfr_ptr, mp_rnd_t)); __MPFR_DECLSPEC int mpfr_const_catalan_internal _MPFR_PROTO((mpfr_ptr, mp_rnd_t)); -__MPFR_DECLSPEC void mpfr_mulhigh_n _MPFR_PROTO ((mp_ptr, mp_srcptr, +__MPFR_DECLSPEC void mpfr_mulhigh_n _MPFR_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t)); -__MPFR_DECLSPEC int mpfr_round_p _MPFR_PROTO ((mp_limb_t *, mp_size_t, +__MPFR_DECLSPEC int mpfr_round_p _MPFR_PROTO ((mp_limb_t *, mp_size_t, mp_exp_t, mp_prec_t)); -__MPFR_DECLSPEC void mpfr_dump_mant _MPFR_PROTO ((const mp_limb_t *, +__MPFR_DECLSPEC void mpfr_dump_mant _MPFR_PROTO ((const mp_limb_t *, mp_prec_t, mp_prec_t, mp_prec_t)); -__MPFR_DECLSPEC int mpfr_round_near_x _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, +__MPFR_DECLSPEC int mpfr_round_near_x _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mp_exp_t, int, mp_rnd_t)); __MPFR_DECLSPEC void mpfr_abort_prec_max _MPFR_PROTO ((void)) MPFR_NORETURN_ATTR; diff --git a/mpfr-test.h b/mpfr-test.h index ff284a4e5..752788cae 100644 --- a/mpfr-test.h +++ b/mpfr-test.h @@ -41,7 +41,7 @@ MA 02110-1301, USA. */ /* Loop for all rounding modes */ #define RND_LOOP(_r) for((_r) = 0 ; (_r) < GMP_RND_MAX ; (_r)++) - + /* The MAX, MIN and ABS macros may already be defined if gmp-impl.h has been included. They have the same semantics as in gmp-impl.h, but the expressions may be slightly different. So, it's better to undefine @@ -31,7 +31,7 @@ MA 02110-1301, USA. */ a*2^exp_r <= b^e <= 2^exp_r (a + 2^f), where a represents {a, n}, i.e. the integer a[0] + a[1]*B + ... + a[n-1]*B^(n-1) where B=2^BITS_PER_MP_LIMB - + Return -2 if an overflow occurred in the computation of exp_r. */ @@ -33,7 +33,7 @@ MA 02110-1301, USA. */ int mpfr_mul2 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode); static int -mpfr_mul3 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) +mpfr_mul3 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) { /* Old implementation */ int sign_product, cc, inexact; @@ -91,28 +91,28 @@ mpfr_mul3 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) } MPFR_CLEAR_FLAGS(a); sign_product = MPFR_MULT_SIGN( MPFR_SIGN(b) , MPFR_SIGN(c) ); - + ax = MPFR_GET_EXP (b) + MPFR_GET_EXP (c); bq = MPFR_PREC(b); cq = MPFR_PREC(c); - + MPFR_ASSERTD(bq+cq > bq); /* PREC_MAX is /2 so no integer overflow */ - + bn = (bq+BITS_PER_MP_LIMB-1)/BITS_PER_MP_LIMB; /* number of limbs of b */ cn = (cq+BITS_PER_MP_LIMB-1)/BITS_PER_MP_LIMB; /* number of limbs of c */ k = bn + cn; /* effective nb of limbs used by b*c (= tn or tn+1) below */ - tn = (bq + cq + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB; + tn = (bq + cq + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB; /* <= k, thus no int overflow */ MPFR_ASSERTD(tn <= k); /* Check for no size_t overflow*/ MPFR_ASSERTD((size_t) k <= ((size_t) ~0) / BYTES_PER_MP_LIMB); - MPFR_TMP_MARK(marker); + MPFR_TMP_MARK(marker); tmp = (mp_limb_t *) MPFR_TMP_ALLOC((size_t) k * BYTES_PER_MP_LIMB); /* multiplies two mantissa in temporary allocated space */ - b1 = (MPFR_LIKELY(bn >= cn)) ? + b1 = (MPFR_LIKELY(bn >= cn)) ? mpn_mul (tmp, MPFR_MANT(b), bn, MPFR_MANT(c), cn) : mpn_mul (tmp, MPFR_MANT(c), cn, MPFR_MANT(b), bn); @@ -126,8 +126,8 @@ mpfr_mul3 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) tmp += k - tn; if (MPFR_UNLIKELY(b1 == 0)) mpn_lshift (tmp, tmp, tn, 1); /* tn <= k, so no stack corruption */ - cc = mpfr_round_raw (MPFR_MANT (a), tmp, bq + cq, - MPFR_IS_NEG_SIGN(sign_product), + cc = mpfr_round_raw (MPFR_MANT (a), tmp, bq + cq, + MPFR_IS_NEG_SIGN(sign_product), MPFR_PREC (a), rnd_mode, &inexact); /* cc = 1 ==> result is a power of two */ @@ -172,7 +172,7 @@ mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) inexact2 = mpfr_mul3 (ta, tb, tc, rnd_mode); inexact1 = mpfr_mul2 (a, b, c, rnd_mode); - if (mpfr_cmp (ta, a) || inexact1*inexact2 < 0 + if (mpfr_cmp (ta, a) || inexact1*inexact2 < 0 || (inexact1*inexact2 == 0 && (inexact1|inexact2) != 0)) { printf("mpfr_mul return different values for %s\n" @@ -293,7 +293,7 @@ mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) tmp = (mp_limb_t *) MPFR_TMP_ALLOC ((size_t) k * BYTES_PER_MP_LIMB); /* multiplies two mantissa in temporary allocated space */ - if (MPFR_UNLIKELY (bn < cn)) + if (MPFR_UNLIKELY (bn < cn)) { mpfr_srcptr tmp = b; mp_size_t tn = bn; @@ -337,7 +337,7 @@ mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) /* Sum those two partial products */ add_ssaaaa (tmp[2], tmp[1], tmp[2], tmp[1], t1, t2); tmp[3] += (tmp[2] < t1); - + b1 = tmp[3]; } b1 >>= (BITS_PER_MP_LIMB - 1); @@ -381,13 +381,13 @@ mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) { bp = MPFR_TMP_ALLOC ((n+1)*sizeof (mp_limb_t)); bp[0] = 0; - MPN_COPY (bp+1, MPFR_MANT (b)+bn-n, n); + MPN_COPY (bp+1, MPFR_MANT (b)+bn-n, n); } if (cn > n) cp --; /* FIXME: Could this happen? */ else { - cp = MPFR_TMP_ALLOC ((n+1)*sizeof (mp_limb_t)); + cp = MPFR_TMP_ALLOC ((n+1)*sizeof (mp_limb_t)); cp[0] = 0; MPN_COPY (cp+1, MPFR_MANT (c)+cn-n, n); } @@ -409,7 +409,7 @@ mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) /* now tmp[0]..tmp[k-1] contains the product of both mantissa, with tmp[k-1]>=2^(BITS_PER_MP_LIMB-2) */ b1 = tmp[k-1] >> (BITS_PER_MP_LIMB - 1); /* msb from the product */ - + /* If the mantissas of b and c are uniformly distributed in ]1/2, 1], then their product is in ]1/4, 1/2] with probability 2*ln(2)-1 ~ 0.386 and in [1/2, 1] with probability 2-2*ln(2) ~ 0.614 */ @@ -422,19 +422,19 @@ mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) MPFR_PREC(a)+(rnd_mode==GMP_RNDN)))) { tmp -= k-tn; /* tmp may have changed, FIX IT!!!!! */ - goto full_multiply; + goto full_multiply; } } else { full_multiply: MPFR_LOG_MSG (("Use mpn_mul\n", 0)); - b1 = mpn_mul (tmp, MPFR_MANT (b), bn, MPFR_MANT (c), cn); + b1 = mpn_mul (tmp, MPFR_MANT (b), bn, MPFR_MANT (c), cn); /* now tmp[0]..tmp[k-1] contains the product of both mantissa, with tmp[k-1]>=2^(BITS_PER_MP_LIMB-2) */ b1 >>= BITS_PER_MP_LIMB - 1; /* msb from the product */ - + /* if the mantissas of b and c are uniformly distributed in ]1/2, 1], then their product is in ]1/4, 1/2] with probability 2*ln(2)-1 ~ 0.386 and in [1/2, 1] with probability 2-2*ln(2) ~ 0.614 */ @@ -39,7 +39,7 @@ mpfr_mul_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mp_rnd_t rnd_mode) MPFR_SET_NAN (y); MPFR_RET_NAN; } - else if (MPFR_IS_INF (x)) + else if (MPFR_IS_INF (x)) { if (u != 0) { @@ -103,13 +103,13 @@ mpfr_mul_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mp_rnd_t rnd_mode) /* now yp[xn], ..., yp[0] is msb-normalized too, and has at most PREC(x) + (BITS_PER_MP_LIMB - cnt) non-zero bits */ - MPFR_RNDRAW (inexact, y, yp, (mp_prec_t) (xn + 1) * BITS_PER_MP_LIMB, + MPFR_RNDRAW (inexact, y, yp, (mp_prec_t) (xn + 1) * BITS_PER_MP_LIMB, rnd_mode, MPFR_SIGN (x), cnt -- ); MPFR_TMP_FREE (marker); cnt = BITS_PER_MP_LIMB - cnt; - if (MPFR_UNLIKELY (__gmpfr_emax < MPFR_EMAX_MIN + cnt + if (MPFR_UNLIKELY (__gmpfr_emax < MPFR_EMAX_MIN + cnt || MPFR_GET_EXP (x) > __gmpfr_emax - cnt)) return mpfr_overflow (y, rnd_mode, MPFR_SIGN(x)); @@ -32,7 +32,7 @@ static short mulhigh_ktab[] = {MPFR_MULHIGH_TAB}; #endif /* Put in rp[n..2n-1] an approximation of the n high limbs - of {mp, n} * {np, n}. + of {mp, n} * {np, n}. The error is at worst of ln(n) for rp[n] and rp[n-1] is totally wrong */ static void mpfr_mulhigh_n_basecase (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n) @@ -49,7 +49,7 @@ void mpfr_mulhigh_n (mp_ptr rp, mp_srcptr np, mp_srcptr mp, mp_size_t n) { mp_size_t k; - + MPFR_ASSERTD (MPFR_MULHIGH_TAB_SIZE > 4); k = MPFR_LIKELY (n < MPFR_MULHIGH_TAB_SIZE) ? mulhigh_ktab[n] : 2*n/3; MPFR_ASSERTD (k == -1 || k == 0 || (k > n/2 && k < n)); @@ -84,7 +84,7 @@ void mpfr_sqrhigh_n (mp_ptr rp, mp_srcptr np, mp_size_t n) { mp_size_t k; - + MPFR_ASSERTD (MPFR_SQRHIGH_TAB_SIZE > 4); k = MPFR_LIKELY (n < MPFR_SQRHIGH_TAB_SIZE) ? sqrhigh_ktab[n] : 2*n/3; MPFR_ASSERTD (k == -1 || k == 0 || (k > n/2 && k < n)); @@ -25,7 +25,7 @@ MA 02110-1301, USA. */ #include "mpfr-impl.h" -size_t +size_t mpfr_out_str (FILE *stream, int base, size_t n_digits, mpfr_srcptr op, mp_rnd_t rnd_mode) { @@ -43,8 +43,8 @@ mpfr_out_str (FILE *stream, int base, size_t n_digits, mpfr_srcptr op, return 3; } - if (MPFR_IS_INF(op)) - { + if (MPFR_IS_INF(op)) + { if (MPFR_SIGN(op) > 0) { fprintf (stream, "@Inf@"); @@ -72,7 +72,7 @@ mpfr_pow_si (mpfr_ptr y, mpfr_srcptr x, long int n, mp_rnd_t rnd_mode) mpfr_set_si (y, (n % 2) ? MPFR_INT_SIGN(x) : 1, rnd_mode); expx --; MPFR_ASSERTD (n < 0); - /* Warning n*expx may overflow! + /* Warning n*expx may overflow! Some systems abort with LONG_MIN / 1 or LONG_MIN/-1*/ if (n != -1 && expx > 0 && -expx < MPFR_EXP_MIN / (-n)) MPFR_EXP (y) = MPFR_EMIN_MIN - 1; /* Underflow */ @@ -105,7 +105,7 @@ mpfr_pow_si (mpfr_ptr y, mpfr_srcptr x, long int n, mp_rnd_t rnd_mode) /* initialise of intermediary variable */ mpfr_init2 (t, Nt); - + MPFR_ZIV_INIT (loop, Nt); for (;;) { @@ -89,7 +89,7 @@ mpfr_pow_ui (mpfr_ptr x, mpfr_srcptr y, unsigned long int n, mp_rnd_t rnd) __gmpfr_emin -= 3; /* So that we can check for underflow properly */ /* setup initial precision */ - prec = MPFR_PREC (x) + 3 + BITS_PER_MP_LIMB + prec = MPFR_PREC (x) + 3 + BITS_PER_MP_LIMB + MPFR_INT_CEIL_LOG2 (MPFR_PREC (x)); mpfr_init2 (res, prec); diff --git a/print_raw.c b/print_raw.c index 9ea6bb03c..5e8493274 100644 --- a/print_raw.c +++ b/print_raw.c @@ -74,7 +74,7 @@ mpfr_print_binary (mpfr_srcptr x) } } -void +void mpfr_print_mant_binary(const char *str, const mp_limb_t *p, mp_prec_t r) { int i; @@ -98,8 +98,8 @@ mpfr_print_mant_binary(const char *str, const mp_limb_t *p, mp_prec_t r) putchar('\n'); } -void -mpfr_dump_mant (const mp_limb_t *p, mp_prec_t r, mp_prec_t precx, +void +mpfr_dump_mant (const mp_limb_t *p, mp_prec_t r, mp_prec_t precx, mp_prec_t error) { int i; @@ -53,7 +53,7 @@ mpfr_random2 (mpfr_ptr x, mp_size_t size, mp_exp_t exp) xp = MPFR_MANT (x); if (size > xn) size = xn; - k = xn - size; + k = xn - size; /* k : # of 0 limbs at the end size: # of limbs to fill @@ -30,8 +30,8 @@ mpfr_reldiff (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) if (MPFR_ARE_SINGULAR (b, c)) { if (MPFR_IS_NAN(b) || MPFR_IS_NAN(c)) - { - MPFR_SET_NAN(a); + { + MPFR_SET_NAN(a); return; } else if (MPFR_IS_INF(b)) @@ -61,12 +61,12 @@ mpfr_reldiff (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) mpfr_init2 (b_copy, MPFR_PREC(b)); mpfr_set (b_copy, b, GMP_RNDN); } - + mpfr_sub (a, b, c, rnd_mode); mpfr_abs (a, a, rnd_mode); /* for compatibility with MPF */ mpfr_div (a, a, (a == b) ? b_copy : b, rnd_mode); - + if (a == b) mpfr_clear (b_copy); - + } @@ -174,7 +174,7 @@ mpfr_root (mpfr_ptr y, mpfr_srcptr x, unsigned long k, mp_rnd_t rnd_mode) { if (negative) rnd_mode = MPFR_INVERT_RND (rnd_mode); - if (rnd_mode == GMP_RNDU + if (rnd_mode == GMP_RNDU || (rnd_mode == GMP_RNDN && mpz_tstbit (m, 0))) inexact = 1, mpz_add_ui (m, m, 1); else @@ -51,7 +51,7 @@ mpfr_round_p (mp_limb_t *bp, mp_size_t bn, mp_exp_t err0, mp_prec_t prec) /* * Assuming {bp, bn} is an approximation of a non-singular number - * with error at most equal to 2^(EXP(b)-err) (`err' bits of b are known) + * with error at most equal to 2^(EXP(b)-err) (`err' bits of b are known) * of direction unknown, check if we can round b to zero with precision prec. */ int @@ -75,7 +75,7 @@ mpfr_round_p (mp_limb_t *bp, mp_size_t bn, mp_exp_t err0, mp_prec_t prec) MPFR_ASSERTD (bn > k); /* Check first limb */ - bp += bn-1-k; + bp += bn-1-k; tmp = *bp--; mask = s == BITS_PER_MP_LIMB ? MP_LIMB_T_MAX : MPFR_LIMB_MASK (s); tmp &= mask; diff --git a/round_prec.c b/round_prec.c index 4af45e7ed..58989cd75 100644 --- a/round_prec.c +++ b/round_prec.c @@ -1,7 +1,7 @@ /* mpfr_round_raw_generic, mpfr_round_raw2, mpfr_round_raw, mpfr_prec_round, mpfr_can_round, mpfr_can_round_raw -- various rounding functions -Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -79,7 +79,7 @@ mpfr_prec_round (mpfr_ptr x, mp_prec_t prec, mp_rnd_t rnd_mode) /* x is a non-zero real number */ - MPFR_TMP_MARK(marker); + MPFR_TMP_MARK(marker); tmp = (mp_limb_t*) MPFR_TMP_ALLOC (nw * BYTES_PER_MP_LIMB); xp = MPFR_MANT(x); carry = mpfr_round_raw (tmp, xp, MPFR_PREC(x), MPFR_IS_NEG(x), @@ -122,7 +122,7 @@ mpfr_can_round (mpfr_srcptr b, mp_exp_t err, mp_rnd_t rnd1, mp_rnd_t rnd2, mp_prec_t prec) { if (MPFR_UNLIKELY(MPFR_IS_SINGULAR(b))) - return 0; /* We cannot round if Zero, Nan or Inf */ + return 0; /* We cannot round if Zero, Nan or Inf */ else return mpfr_can_round_raw(MPFR_MANT(b), MPFR_LIMB_SIZE(b), MPFR_SIGN(b), err, rnd1, rnd2, prec); @@ -223,6 +223,6 @@ mpfr_can_round_raw (const mp_limb_t *bp, mp_size_t bn, int neg, mp_exp_t err0, cc2 = (tmp[bn - 1] >> s1) & 1; cc2 ^= mpfr_round_raw2 (tmp, bn, neg, rnd2, prec); - MPFR_TMP_FREE(marker); + MPFR_TMP_FREE(marker); return cc == cc2; } diff --git a/round_raw_generic.c b/round_raw_generic.c index 6408506fc..7e7a004f3 100644 --- a/round_raw_generic.c +++ b/round_raw_generic.c @@ -67,7 +67,7 @@ mpfr_round_raw_generic( int rw; #if flag == 0 int carry; -#endif +#endif #if use_inexp == 0 int *inexp; #endif @@ -76,7 +76,7 @@ mpfr_round_raw_generic( MPFR_ASSERTD(inexp != ((int*) 0)); MPFR_ASSERTD(neg == 0 || neg == 1); - if (flag && !use_inexp && + if (flag && !use_inexp && (xprec <= yprec || MPFR_IS_LIKE_RNDZ (rnd_mode, neg))) return 0; @@ -90,7 +90,7 @@ mpfr_round_raw_generic( if (MPFR_LIKELY(rw)) nw++; MPFR_ASSERTD(nw >= 1); - MPFR_ASSERTD(nw >= xsize); + MPFR_ASSERTD(nw >= xsize); if (use_inexp) *inexp = 0; #if flag == 0 @@ -101,7 +101,7 @@ mpfr_round_raw_generic( } if (use_inexp || !MPFR_IS_LIKE_RNDZ(rnd_mode, neg)) - { + { mp_size_t k = xsize - nw - 1; if (MPFR_LIKELY(rw)) @@ -170,8 +170,8 @@ mpfr_round_raw_generic( return 1; /*sb != 0 && rnd_mode != GMP_RNDZ;*/ #else carry = mpn_add_1 (yp, xp + xsize - nw, nw, - rw ? - MPFR_LIMB_ONE << (BITS_PER_MP_LIMB - rw) + rw ? + MPFR_LIMB_ONE << (BITS_PER_MP_LIMB - rw) : MPFR_LIMB_ONE); yp[0] &= himask; return carry; @@ -187,17 +187,17 @@ mpfr_round_raw_generic( sb = xp[--k]; if (use_inexp) /* rnd_mode == GMP_RNDZ and neg = 0 or 1 */ - /* (neg != 0) ^ (rnd_mode != GMP_RNDZ)) ? 1 : -1);*/ + /* (neg != 0) ^ (rnd_mode != GMP_RNDZ)) ? 1 : -1);*/ *inexp = MPFR_UNLIKELY(sb == 0) ? 0 : (2*neg-1); #if flag == 1 return 0; /*sb != 0 && rnd_mode != GMP_RNDZ;*/ #else MPN_COPY_INCR(yp, xp + xsize - nw, nw); - yp[0] &= himask; + yp[0] &= himask; return 0; #endif } - else + else { /* rnd_mode = Away */ while (MPFR_UNLIKELY(sb == 0) && k > 0) @@ -39,7 +39,7 @@ mpfr_set4 (mpfr_ptr a, mpfr_srcptr b, mp_rnd_t rnd_mode, int signb) since MPFR_EXP (a) = MPFR_EXP (b) does the job */ if (MPFR_IS_NAN (b)) MPFR_RET_NAN; - else + else MPFR_RET (0); } else if (MPFR_LIKELY (MPFR_PREC (b) == MPFR_PREC (a))) @@ -47,7 +47,7 @@ mpfr_set4 (mpfr_ptr a, mpfr_srcptr b, mp_rnd_t rnd_mode, int signb) /* Same precision and b is not singular: * just copy the mantissa, and set the exponent and the sign * The result is exact. */ - MPN_COPY (MPFR_MANT (a), MPFR_MANT (b), + MPN_COPY (MPFR_MANT (a), MPFR_MANT (b), (MPFR_PREC (b) + BITS_PER_MP_LIMB-1)/BITS_PER_MP_LIMB); MPFR_RET (0); } @@ -56,8 +56,8 @@ mpfr_set4 (mpfr_ptr a, mpfr_srcptr b, mp_rnd_t rnd_mode, int signb) int inex; /* Else Round B inside a */ - MPFR_RNDRAW (inex, a, MPFR_MANT (b), MPFR_PREC (b), rnd_mode, signb, - if (MPFR_UNLIKELY ( ++MPFR_EXP (a) > __gmpfr_emax)) + MPFR_RNDRAW (inex, a, MPFR_MANT (b), MPFR_PREC (b), rnd_mode, signb, + if (MPFR_UNLIKELY ( ++MPFR_EXP (a) > __gmpfr_emax)) return mpfr_overflow (a, rnd_mode, signb) ); MPFR_RET (inex); } @@ -169,12 +169,12 @@ mpfr_set_d (mpfr_ptr r, double d, mp_rnd_t rnd_mode) else MPFR_SET_POS(r); #else /* _GMP_IEEE_FLOATS */ - MPFR_SET_ZERO(r); + MPFR_SET_ZERO(r); { /* This is to get the sign of zero on non-IEEE hardware Some systems support +0.0, -0.0 and unsigned zero. We can't use d==+0.0 since it should be always true, - so we check that the memory representation of d is the + so we check that the memory representation of d is the same than +0.0. etc */ double poszero = +0.0, negzero = -0.0; if (memcmp(&d, &poszero, sizeof(double)) == 0) @@ -188,7 +188,7 @@ mpfr_set_d (mpfr_ptr r, double d, mp_rnd_t rnd_mode) return 0; /* 0 is exact */ } else if (MPFR_UNLIKELY(DOUBLE_ISINF(d))) - { + { MPFR_SET_INF(r); if (d > 0) MPFR_SET_POS(r); @@ -52,7 +52,7 @@ set_z (mpfr_ptr f, mpz_srcptr z, mp_size_t *zs) mpn_lshift (MPFR_MANT (f), p, s, c); else MPN_COPY (MPFR_MANT (f), p, s); - + MPFR_SET_SIGN (f, mpz_sgn (z)); MPFR_SET_EXP (f, 0); @@ -99,7 +99,7 @@ mpfr_set_q (mpfr_ptr f, mpq_srcptr q, mp_rnd_t rnd) cn = set_z (n, num, &sn); cd = set_z (d, den, &sd); - + sn -= sd; if (MPFR_UNLIKELY (sn > MPFR_EMAX_MAX / BITS_PER_MP_LIMB)) { @@ -52,7 +52,7 @@ int MPFR_SET_NEG(x); else MPFR_SET_POS(x); - + nbits = BITS_PER_MP_LIMB - cnt; MPFR_EXP (x) = nbits; /* may be out-of-range, check range below */ inex = mpfr_check_range(x, 0, rnd_mode); diff --git a/set_ui_2exp.c b/set_ui_2exp.c index 97bfde698..c699af27c 100644 --- a/set_ui_2exp.c +++ b/set_ui_2exp.c @@ -1,4 +1,4 @@ -/* mpfr_set_ui_2exp -- set a MPFR number from a machine unsigned integer with +/* mpfr_set_ui_2exp -- set a MPFR number from a machine unsigned integer with a shift Copyright 2004 Free Software Foundation. @@ -24,7 +24,7 @@ MA 02110-1301, USA. */ #include "mpfr-impl.h" /* set f to the integer z */ -int +int mpfr_set_z (mpfr_ptr f, mpz_srcptr z, mp_rnd_t rnd_mode) { mp_size_t fn, zn, dif; @@ -39,7 +39,7 @@ mpfr_set_z (mpfr_ptr f, mpz_srcptr z, mp_rnd_t rnd_mode) MPFR_SET_POS(f); MPFR_RET(0); } - MPFR_ASSERTD (sign_z == MPFR_SIGN_POS || sign_z == MPFR_SIGN_NEG); + MPFR_ASSERTD (sign_z == MPFR_SIGN_POS || sign_z == MPFR_SIGN_NEG); zn = ABS(SIZ(z)); MPFR_ASSERTD (zn >= 1); @@ -81,10 +81,10 @@ mpfr_set_z (mpfr_ptr f, mpz_srcptr z, mp_rnd_t rnd_mode) } else MPN_COPY (fp, zp + dif, fn); - + /* Compute Rounding Bit and Sticky Bit */ MPFR_UNSIGNED_MINUS_MODULO (sh, MPFR_PREC (f) ); - if (MPFR_LIKELY (sh != 0)) + if (MPFR_LIKELY (sh != 0)) { mp_limb_t mask = MPFR_LIMB_ONE << (sh-1); mp_limb_t limb = fp[0]; @@ -111,7 +111,7 @@ mpfr_set_z (mpfr_ptr f, mpz_srcptr z, mp_rnd_t rnd_mode) sb = zp[--dif]; if (MPFR_LIKELY (k != 0)) sb &= MPFR_LIMB_MASK (BITS_PER_MP_LIMB - k); - if (MPFR_UNLIKELY (sb == 0) && MPFR_LIKELY (dif > 0)) + if (MPFR_UNLIKELY (sb == 0) && MPFR_LIKELY (dif > 0)) do { sb = zp[--dif]; } while (dif > 0 && sb == 0); @@ -140,8 +140,8 @@ mpfr_set_z (mpfr_ptr f, mpz_srcptr z, mp_rnd_t rnd_mode) addoneulp: inex = 1; - if (MPFR_UNLIKELY (mpn_add_1 (fp, fp, fn, ulp))) - { + if (MPFR_UNLIKELY (mpn_add_1 (fp, fp, fn, ulp))) + { /* Pow 2 case */ if (MPFR_UNLIKELY (exp == __gmpfr_emax)) return mpfr_overflow (f, rnd_mode, sign_z); @@ -60,7 +60,7 @@ mpfr_sin_sign (mpfr_srcptr x) /* determine parity of k for sign */ if (MPFR_GET_EXP (k) <= 0 || (mpfr_uexp_t) MPFR_GET_EXP (k) <= m) { - mp_size_t j = BITS_PER_MP_LIMB * MPFR_LIMB_SIZE(k) + mp_size_t j = BITS_PER_MP_LIMB * MPFR_LIMB_SIZE(k) - MPFR_GET_EXP(k); mp_size_t l = j / BITS_PER_MP_LIMB; /* parity bit is j-th bit starting from least significant bits */ @@ -72,7 +72,7 @@ mpfr_sin_sign (mpfr_srcptr x) <= 2^(K+2-m) */ mpfr_sub (k, x, k, GMP_RNDN); /* assuming |k| <= Pi, err <= 2^(1-m)+2^(K+2-m) < 2^(K+3-m) */ - MPFR_ASSERTN (MPFR_IS_ZERO (k) || MPFR_GET_EXP (k) <= 2); + MPFR_ASSERTN (MPFR_IS_ZERO (k) || MPFR_GET_EXP (k) <= 2); y = k; } else @@ -82,7 +82,7 @@ mpfr_sin_sign (mpfr_srcptr x) } /* sign of sign(y) is uncertain if |y| <= err < 2^(K+3-m), thus EXP(y) < K+4-m */ - if (MPFR_LIKELY (!MPFR_IS_ZERO (y) + if (MPFR_LIKELY (!MPFR_IS_ZERO (y) && MPFR_GET_EXP (y) >= K + 4 - (mp_exp_t) m)) break; MPFR_ZIV_NEXT (loop, m); @@ -95,19 +95,19 @@ mpfr_sin_sign (mpfr_srcptr x) mpfr_clear (k); mpfr_clear (c); - + return sign; } -int -mpfr_sin (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) +int +mpfr_sin (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) { mpfr_t c; mp_exp_t e; mp_prec_t precy, m; int inexact, sign; MPFR_ZIV_DECL (loop); - + MPFR_LOG_FUNC (("x[%#R]=%R rnd=%d", x, x, rnd_mode), ("y[%#R]=%R inexact=%d", y, y, inexact)); @@ -175,7 +175,7 @@ mpfr_sin (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) if (MPFR_GET_EXP (c) == 1) m += m; } - + /* Else generic increase */ MPFR_ZIV_NEXT (loop, m); mpfr_set_prec (c, m); @@ -22,10 +22,10 @@ MA 02110-1301, USA. */ #define MPFR_NEED_LONGLONG_H #include "mpfr-impl.h" -/* (y, z) <- (sin(x), cos(x)), return value is 0 iff both results are exact +/* (y, z) <- (sin(x), cos(x)), return value is 0 iff both results are exact ie, iff x = 0 */ -int -mpfr_sin_cos (mpfr_ptr y, mpfr_ptr z, mpfr_srcptr x, mp_rnd_t rnd_mode) +int +mpfr_sin_cos (mpfr_ptr y, mpfr_ptr z, mpfr_srcptr x, mp_rnd_t rnd_mode) { mp_prec_t prec, m; int neg; @@ -54,7 +54,7 @@ mpfr_sin_cos (mpfr_ptr y, mpfr_ptr z, mpfr_srcptr x, mp_rnd_t rnd_mode) MPFR_LOG_FUNC (("x[%#R]=%R rnd=%d", x, x, rnd_mode), ("sin[%#R]=%R cos[%#R]=%R", y, y, z, z)); - prec = MAX (MPFR_PREC (y), MPFR_PREC (z)); + prec = MAX (MPFR_PREC (y), MPFR_PREC (z)); m = prec + MPFR_INT_CEIL_LOG2 (prec) + 13; e = MPFR_GET_EXP (x); m += (e < 0) ? -2*e : e; @@ -62,7 +62,7 @@ mpfr_sin_cos (mpfr_ptr y, mpfr_ptr z, mpfr_srcptr x, mp_rnd_t rnd_mode) mpfr_init2 (c, m); /* first determine sign of sinus */ - if (MPFR_GET_EXP (x) > 0) + if (MPFR_GET_EXP (x) > 0) { mpfr_init2 (k, m); mpfr_const_pi (c, GMP_RNDN); @@ -183,7 +183,7 @@ mpfr_sqrt (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode) else /* tsize = rsize */ { int cmp; - + cmp = mpn_cmp (tp, rp, rsize); if (cmp > 0) inexact = 1; diff --git a/sub_one_ulp.c b/sub_one_ulp.c index 0d30aaf4e..42a43940c 100644 --- a/sub_one_ulp.c +++ b/sub_one_ulp.c @@ -28,7 +28,7 @@ mpfr_sub_one_ulp(mpfr_ptr x, mp_rnd_t rnd_mode) mp_size_t xn; int sh; mp_limb_t *xp; - + if (MPFR_UNLIKELY( MPFR_IS_SINGULAR(x) )) { if (MPFR_IS_NAN(x)) @@ -37,7 +37,7 @@ mpfr_sub_one_ulp(mpfr_ptr x, mp_rnd_t rnd_mode) MPFR_RET (0); } - xn = MPFR_LIMB_SIZE(x); + xn = MPFR_LIMB_SIZE(x); MPFR_UNSIGNED_MINUS_MODULO(sh, MPFR_PREC(x) ); xp = MPFR_MANT(x); mpn_sub_1 (xp, xp, xn, MPFR_LIMB_ONE << sh); @@ -32,7 +32,7 @@ mpfr_swap (mpfr_ptr u, mpfr_ptr v) mpfr_sign_t s1, s2; mp_exp_t e1, e2; mp_limb_t *m1, *m2; - + p1 = MPFR_PREC(u); p2 = MPFR_PREC(v); MPFR_PREC(v) = p1; @@ -23,7 +23,7 @@ MA 02110-1301, USA. */ #include "mpfr-impl.h" int -mpfr_tanh (mpfr_ptr y, mpfr_srcptr xt , mp_rnd_t rnd_mode) +mpfr_tanh (mpfr_ptr y, mpfr_srcptr xt , mp_rnd_t rnd_mode) { /****** Declaration ******/ mpfr_t x; @@ -81,7 +81,7 @@ mpfr_tanh (mpfr_ptr y, mpfr_srcptr xt , mp_rnd_t rnd_mode) If 2 ^(2*x) > 2^emax or x>emax/2, there is an overflow */ if (MPFR_UNLIKELY (mpfr_cmp_si (x, __gmpfr_emax/2) >= 0)) { /* initialise of intermediary variables - since 'set_one' label assumes the variables have been + since 'set_one' label assumes the variables have been initialize */ MPFR_GROUP_INIT_2 (group, MPFR_PREC_MIN, t, te); goto set_one; diff --git a/tests/memory.c b/tests/memory.c index 27ae16516..5c9757453 100644 --- a/tests/memory.c +++ b/tests/memory.c @@ -5,7 +5,7 @@ Copyright 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU MP Library. ChangeLog: - tests_memory_valid has been commented out since it is not used + tests_memory_valid has been commented out since it is not used tests_memory_list is declared as static The GNU MP Library is free software; you can redistribute it and/or modify diff --git a/tests/reuse.c b/tests/reuse.c index 50a4f7014..73245e79e 100644 --- a/tests/reuse.c +++ b/tests/reuse.c @@ -29,13 +29,13 @@ MA 02110-1301, USA. */ #define SPECIAL_MAX 12 -static void +static void set_special (mpfr_ptr x, unsigned int select) { MPFR_ASSERTN (select < SPECIAL_MAX); - switch (select) + switch (select) { - case 0: + case 0: MPFR_SET_NAN (x); break; case 1: @@ -318,7 +318,7 @@ test2ui (int (*testfunc)(mpfr_ptr, mpfr_srcptr, unsigned long int, mp_rnd_t), if (mpfr_compare (res1, ref1)) { printf ("Error for %s(a, a, c) for c=%u\n", foo, ref3); - DISP2("a=",ref2); + DISP2("a=",ref2); printf ("expected "); mpfr_print_binary (ref1); puts (""); printf ("got "); mpfr_print_binary (res1); puts (""); exit (1); diff --git a/tests/tabs.c b/tests/tabs.c index 896a1bdeb..092c6b7b0 100644 --- a/tests/tabs.c +++ b/tests/tabs.c @@ -142,10 +142,10 @@ check_cmp(int argc, char *argv[]) MPFR_SET_POS(x); if (mpfr_cmp(x,y)) { - printf ("Mismatch for sign=%d and x=", sign); + printf ("Mismatch for sign=%d and x=", sign); mpfr_print_binary(x); printf ("\nResults="); - mpfr_print_binary(y); + mpfr_print_binary(y); putchar ('\n'); exit (1); } diff --git a/tests/tacos.c b/tests/tacos.c index 7832ee640..3719c1af2 100644 --- a/tests/tacos.c +++ b/tests/tacos.c @@ -33,7 +33,7 @@ special (void) { mpfr_t x, y; int inex1, inex2; - + mpfr_init2 (x, 32); mpfr_init2 (y, 32); @@ -55,14 +55,14 @@ special (void) mpfr_print_binary (y); printf ("\n"); exit (1); } - + mpfr_set_prec (x, 2); mpfr_set_ui (x, 0, GMP_RNDN); inex1 = mpfr_acos (x, x, GMP_RNDN); /* Pi/2 */ inex2 = mpfr_const_pi (x, GMP_RNDN); if (inex1 != inex2) { - printf ("Error in mpfr_acos (3) for prec=2\n"); + printf ("Error in mpfr_acos (3) for prec=2\n"); exit (1); } diff --git a/tests/tadd_ui.c b/tests/tadd_ui.c index 11933fd72..4e1c36726 100644 --- a/tests/tadd_ui.c +++ b/tests/tadd_ui.c @@ -103,11 +103,11 @@ main (int argc, char *argv[]) special (); check3 ("-1.716113812768534e-140", 1271212614, GMP_RNDZ, "1.27121261399999976e9"); - check3 ("1.22191250737771397120e+20", 948002822, GMP_RNDN, + check3 ("1.22191250737771397120e+20", 948002822, GMP_RNDN, "122191250738719408128.0"); check3 ("-6.72658901114033715233e-165", 2000878121, GMP_RNDZ, "2.0008781209999997615e9"); - check3 ("-2.0769715792901673e-5", 880524, GMP_RNDN, + check3 ("-2.0769715792901673e-5", 880524, GMP_RNDN, "8.8052399997923023e5"); test_generic_ui (2, 1000, 100); diff --git a/tests/tagm.c b/tests/tagm.c index f58c9b8e8..4fc0de3e1 100644 --- a/tests/tagm.c +++ b/tests/tagm.c @@ -196,9 +196,9 @@ main (int argc, char* argv[]) { MPFR_TEST_USE_RANDS (); tests_start_mpfr (); - + check_nans (); - + check_large (); check4 ("2.0", "1.0", GMP_RNDN, "1.45679103104690677029"); check4 ("6.0", "4.0", GMP_RNDN, "4.94936087247260925182"); @@ -212,6 +212,6 @@ main (int argc, char* argv[]) "7.55393356971199025907e-02"); test_generic (2, 300, 17); - tests_end_mpfr (); + tests_end_mpfr (); return 0; } diff --git a/tests/tasin.c b/tests/tasin.c index 77a6511cc..415180556 100644 --- a/tests/tasin.c +++ b/tests/tasin.c @@ -149,7 +149,7 @@ special (void) } mpfr_set_prec (x, 9); - mpfr_set_prec (y, 19); + mpfr_set_prec (y, 19); mpfr_set_str_binary (x, "0.110000000E-6"); mpfr_asin (y, x, GMP_RNDD); mpfr_set_prec (x, 19); diff --git a/tests/tatan.c b/tests/tatan.c index bb4c4afe9..0a5ea071b 100644 --- a/tests/tatan.c +++ b/tests/tatan.c @@ -164,10 +164,10 @@ special (void) /* Test regression */ mpfr_set_prec (x, 51); mpfr_set_prec (y, 51); - mpfr_set_str_binary (x, + mpfr_set_str_binary (x, "0.101100100000101111111010001111111000001000000000000E-11"); i = mpfr_atan (y, x, GMP_RNDN); - if (mpfr_cmp_str (y, + if (mpfr_cmp_str (y, "1.01100100000101111111001110011001010110100100000000e-12", 2, GMP_RNDN) || i >= 0) { @@ -175,7 +175,7 @@ special (void) mpfr_dump (y); exit (1); } - + mpfr_set_si (x, -1, GMP_RNDN); mpfr_atan (x, x, GMP_RNDN); MPFR_ASSERTN (MPFR_IS_NEG (x)); @@ -190,7 +190,7 @@ special (void) printf ("Error in mpfr_atan (4)\n"); printf ("Input 1.11001110010000011111100000010000000000000000000e-19 [prec=48]\n"); printf ("Expected 0.111001110010000011111100000001111111110000010011E-18\n"); - printf ("Got "); mpfr_dump (y); + printf ("Got "); mpfr_dump (y); exit (1); } @@ -258,7 +258,7 @@ special_atan2 (void) /* 0+ 0+ --> 0+ */ mpfr_set_ui (y, 0, GMP_RNDN); mpfr_atan2 (z, y, x, GMP_RNDN); - MPFR_ASSERTN (MPFR_IS_ZERO (z) && MPFR_IS_POS (z)); + MPFR_ASSERTN (MPFR_IS_ZERO (z) && MPFR_IS_POS (z)); /* 0- 0+ --> 0- */ MPFR_CHANGE_SIGN (y); mpfr_atan2 (z, y, x, GMP_RNDN); @@ -275,7 +275,7 @@ special_atan2 (void) mpfr_set_si (x, -1, GMP_RNDN); mpfr_atan2 (z, y, x, GMP_RNDN); MPFR_ASSERTN (mpfr_cmp_str (z, "3.1415", 10, GMP_RNDN) == 0); - /* 0- -1 --> -PI */ + /* 0- -1 --> -PI */ MPFR_CHANGE_SIGN (y); mpfr_atan2 (z, y, x, GMP_RNDN); MPFR_ASSERTN (mpfr_cmp_str (z, "-3.1415", 10, GMP_RNDN) == 0); diff --git a/tests/tcan_round.c b/tests/tcan_round.c index 06532f53d..7310bb62a 100644 --- a/tests/tcan_round.c +++ b/tests/tcan_round.c @@ -68,14 +68,14 @@ main (void) /* checks that rounds to nearest sets the last bit to zero in case of equal distance */ mpfr_init2 (x, 59); - mpfr_set_str_binary (x, "-0.10010001010111000011110010111010111110000000111101100111111E663"); + mpfr_set_str_binary (x, "-0.10010001010111000011110010111010111110000000111101100111111E663"); if (mpfr_can_round (x, 54, GMP_RNDZ, GMP_RNDZ, 53) != 0) { printf ("Error (1) in mpfr_can_round\n"); exit (1); } - mpfr_set_str_binary (x, "-Inf"); + mpfr_set_str_binary (x, "-Inf"); if (mpfr_can_round (x, 2000, GMP_RNDZ, GMP_RNDZ, 2000) != 0) { printf ("Error (2) in mpfr_can_round\n"); diff --git a/tests/tcheck.c b/tests/tcheck.c index 547943692..125a2956d 100644 --- a/tests/tcheck.c +++ b/tests/tcheck.c @@ -34,7 +34,7 @@ main (void) mp_size_t s; mpfr_prec_t pr; int max; - + tests_start_mpfr (); for(pr = MPFR_PREC_MIN ; pr < 500 ; pr++) { diff --git a/tests/tcmp.c b/tests/tcmp.c index dbf5ccc92..be2c3ca47 100644 --- a/tests/tcmp.c +++ b/tests/tcmp.c @@ -187,31 +187,31 @@ main (void) } } } - + /* Check for NAN */ mpfr_set_nan (xx); mpfr_clear_erangeflag (); c = (mpfr_cmp) (xx, yy); - if (c != 0 || !mpfr_erangeflag_p () ) + if (c != 0 || !mpfr_erangeflag_p () ) { printf ("NAN error (1)\n"); exit (1); } mpfr_clear_erangeflag (); c = (mpfr_cmp) (yy, xx); - if (c != 0 || !mpfr_erangeflag_p () ) + if (c != 0 || !mpfr_erangeflag_p () ) { printf ("NAN error (2)\n"); exit (1); } mpfr_clear_erangeflag (); c = (mpfr_cmp) (xx, xx); - if (c != 0 || !mpfr_erangeflag_p () ) + if (c != 0 || !mpfr_erangeflag_p () ) { printf ("NAN error (3)\n"); exit (1); } - + mpfr_clear (xx); mpfr_clear (yy); diff --git a/tests/tcmp_ld.c b/tests/tcmp_ld.c index 6ecd4ca79..81bcd296a 100644 --- a/tests/tcmp_ld.c +++ b/tests/tcmp_ld.c @@ -32,7 +32,7 @@ main (void) tests_start_mpfr (); mpfr_init2(x, MPFR_LDBL_MANT_DIG); - + mpfr_set_ld (x, 2.34763465, GMP_RNDN); if (mpfr_cmp_ld(x, 2.34763465)!=0) { printf("Error in mpfr_cmp_ld 2.34763465 and "); diff --git a/tests/tcmp_ui.c b/tests/tcmp_ui.c index 609c51fcb..fd645de8c 100644 --- a/tests/tcmp_ui.c +++ b/tests/tcmp_ui.c @@ -27,8 +27,8 @@ MA 02110-1301, USA. */ int main (void) { - mpfr_t x; - unsigned long i; + mpfr_t x; + unsigned long i; long s; int c; @@ -154,14 +154,14 @@ main (void) mpfr_set_nan (x); mpfr_clear_erangeflag (); c = mpfr_cmp_ui (x, 12); - if (c != 0 || !mpfr_erangeflag_p () ) + if (c != 0 || !mpfr_erangeflag_p () ) { printf ("NAN error (1)\n"); exit (1); } mpfr_clear_erangeflag (); c = mpfr_cmp_si (x, -12); - if (c != 0 || !mpfr_erangeflag_p () ) + if (c != 0 || !mpfr_erangeflag_p () ) { printf ("NAN error (2)\n"); exit (1); diff --git a/tests/tcmpabs.c b/tests/tcmpabs.c index c3e1e6cc7..5f199c274 100644 --- a/tests/tcmpabs.c +++ b/tests/tcmpabs.c @@ -56,20 +56,20 @@ main (void) mpfr_set_str_binary (yy, "0.10011010101000110101010000000011001001001110001011101011111011100E623"); if (mpfr_cmpabs (xx, yy) <= 0) ERROR ("Error (1) in mpfr_cmpabs\n"); - + mpfr_set_str_binary (xx, "-0.10100010001110110111000010001000010011111101000100011101000011100"); mpfr_set_str_binary (yy, "-0.10100010001110110111000010001000010011111101000100011101000011011"); if (mpfr_cmpabs (xx, yy) <= 0) ERROR ("Error (2) in mpfr_cmpabs\n"); - mpfr_set_prec (xx, 160); + mpfr_set_prec (xx, 160); mpfr_set_prec (yy, 160); mpfr_set_str_binary (xx, "0.1E1"); mpfr_set_str_binary (yy, "-0.1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000110001110100"); if (mpfr_cmpabs (xx, yy) <= 0) ERROR ("Error (3) in mpfr_cmpabs\n"); - mpfr_set_prec(xx, 53); + mpfr_set_prec(xx, 53); mpfr_set_prec(yy, 200); mpfr_set_ui (xx, 1, (mp_rnd_t) 0); mpfr_set_ui (yy, 1, (mp_rnd_t) 0); @@ -120,21 +120,21 @@ main (void) mpfr_set_nan (xx); mpfr_clear_erangeflag (); c = (mpfr_cmp) (xx, yy); - if (c != 0 || !mpfr_erangeflag_p () ) + if (c != 0 || !mpfr_erangeflag_p () ) { printf ("NAN error (1)\n"); exit (1); } mpfr_clear_erangeflag (); c = (mpfr_cmp) (yy, xx); - if (c != 0 || !mpfr_erangeflag_p () ) + if (c != 0 || !mpfr_erangeflag_p () ) { printf ("NAN error (2)\n"); exit (1); } mpfr_clear_erangeflag (); c = (mpfr_cmp) (xx, xx); - if (c != 0 || !mpfr_erangeflag_p () ) + if (c != 0 || !mpfr_erangeflag_p () ) { printf ("NAN error (3)\n"); exit (1); diff --git a/tests/tconst_log2.c b/tests/tconst_log2.c index 33b0d43e4..a593b9f12 100644 --- a/tests/tconst_log2.c +++ b/tests/tconst_log2.c @@ -47,7 +47,7 @@ check (mp_prec_t p0, mp_prec_t p1) rnd = (mp_rnd_t) RND_RAND (); mpfr_const_log2 (x, rnd); mpfr_set (y, z, rnd); - if ((dif = mpfr_cmp (x, y)) + if ((dif = mpfr_cmp (x, y)) && mpfr_can_round (z, mpfr_get_prec(z), GMP_RNDN, rnd, p0)) { @@ -80,11 +80,11 @@ check_large (void) exit (1); } - /* worst-case with 15 successive ones after last bit, + /* worst-case with 15 successive ones after last bit, to exercise can_round loop */ mpfr_set_prec (x, 26249); mpfr_const_log2 (x, GMP_RNDZ); - + mpfr_clears (x, y, NULL); } diff --git a/tests/tcos.c b/tests/tcos.c index fa6c5671e..876f1ee1e 100644 --- a/tests/tcos.c +++ b/tests/tcos.c @@ -57,7 +57,7 @@ check53 (const char *xs, const char *cos_xs, mp_rnd_t rnd_mode) test_cos (c, xx, rnd_mode); if (mpfr_cmp_str1 (c, cos_xs)) { - printf ("mpfr_cos failed for x=%s, rnd=%s\n", + printf ("mpfr_cos failed for x=%s, rnd=%s\n", xs, mpfr_print_rnd_mode (rnd_mode)); printf ("mpfr_cos gives cos(x)="); mpfr_out_str(stdout, 10, 0, c, GMP_RNDN); @@ -119,14 +119,14 @@ check_nans (void) } /* Compute ~Pi/2 to check */ - /* FIXME: Too slow! + /* FIXME: Too slow! mpfr_set_prec (x, 20000); mpfr_const_pi (x, GMP_RNDD); mpfr_div_2ui (x, x, 1, GMP_RNDN); mpfr_set_prec (y, 24); test_cos (y, x, GMP_RNDN); if (mpfr_cmp_str (y, "0.111001010110100011000001E-20000", 2, GMP_RNDN)) { - printf("Error computing cos(~Pi/2)\n"); + printf("Error computing cos(~Pi/2)\n"); mpfr_dump (y); exit (1); } */ @@ -150,7 +150,7 @@ special_overflow (void) test_cos (y, x, GMP_RNDZ); set_emin (MPFR_EMIN_MIN); set_emax (MPFR_EMAX_MAX); - + mpfr_clear (x); mpfr_clear (y); } diff --git a/tests/tcosh.c b/tests/tcosh.c index d1ab9b0a1..01f5f6def 100644 --- a/tests/tcosh.c +++ b/tests/tcosh.c @@ -142,7 +142,7 @@ special_overflow (void) set_emin (-125); set_emax (128); - + mpfr_init2 (x, 24); mpfr_init2 (y, 24); @@ -152,7 +152,7 @@ special_overflow (void) { printf("Special overflow error 1.\n"); mpfr_dump (y); - exit (1); + exit (1); } mpfr_set_str_binary (x, "0.101100100000000000110100E8"); @@ -163,7 +163,7 @@ special_overflow (void) mpfr_dump (y); exit (1); } - + set_emin (MPFR_EMIN_MIN); set_emax (MPFR_EMAX_MAX); diff --git a/tests/tdiv.c b/tests/tdiv.c index dafaa48cb..3646e3682 100644 --- a/tests/tdiv.c +++ b/tests/tdiv.c @@ -62,10 +62,10 @@ inex_cmp (int a, int b) return (b == 0) ? 0 : 1; else return (b < 0) ? 0 : 1; -} +} static void -check4 (const char *Ns, const char *Ds, mp_rnd_t rnd_mode, int p, +check4 (const char *Ns, const char *Ds, mp_rnd_t rnd_mode, int p, const char *Qs) { mpfr_t q, n, d; @@ -204,7 +204,7 @@ check_64(void) { printf("Error for tdiv for GMP_RNDU and p=64\nx="); mpfr_print_binary(x); - printf("\ny="); + printf("\ny="); mpfr_print_binary(y); printf("\ngot "); mpfr_print_binary(z); @@ -750,12 +750,12 @@ main (int argc, char *argv[]) check_convergence(); check_64(); - check4("4.0","4.503599627370496e15", GMP_RNDZ, 62, + check4("4.0","4.503599627370496e15", GMP_RNDZ, 62, "0.10000000000000000000000000000000000000000000000000000000000000E-49"); - check4("1.0","2.10263340267725788209e+187", GMP_RNDU, 65, + check4("1.0","2.10263340267725788209e+187", GMP_RNDU, 65, "0.11010011111001101011111001100111110100000001101001111100111000000E-622"); check4("2.44394909079968374564e-150", "2.10263340267725788209e+187",GMP_RNDU, - 65, + 65, "0.11010011111001101011111001100111110100000001101001111100111000000E-1119"); test_generic (2, 800, 50); diff --git a/tests/teq.c b/tests/teq.c index fcffd081a..c29c61d7c 100644 --- a/tests/teq.c +++ b/tests/teq.c @@ -176,7 +176,7 @@ special (void) MPFR_ASSERTN(mpfr_eq (x, y, 2) == 0); MPFR_ASSERTN(mpfr_eq (x, y, mp_bits_per_limb) == 0); MPFR_ASSERTN(mpfr_eq (x, y, mp_bits_per_limb + 1) == 0); - + mpfr_clear (x); mpfr_clear (y); mpfr_clear (z); diff --git a/tests/terf.c b/tests/terf.c index ac5ebc2af..a81f64c4b 100644 --- a/tests/terf.c +++ b/tests/terf.c @@ -325,7 +325,7 @@ special_erf (void) printf ("Error: erf for prec=43,64 (13)\n"); exit (1); } - + mpfr_clear (x); mpfr_clear (y); @@ -385,10 +385,10 @@ main (int argc, char *argv[]) { tests_start_mpfr (); - special_erf (); - special_erfc (); + special_erf (); + special_erfc (); - test_generic_erf (2, 100, 15); + test_generic_erf (2, 100, 15); test_generic_erfc (2, 100, 15); tests_end_mpfr (); diff --git a/tests/tests.c b/tests/tests.c index 158e544f3..63a392923 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -53,7 +53,7 @@ static void tests_rand_start (void); static void tests_rand_end (void); /* We want to always import the function mpfr_dump inside the test - suite, so that we can use it in GDB. But it doesn't work if we build + suite, so that we can use it in GDB. But it doesn't work if we build a Windows DLL (initializer element is not a constant) */ #if !__GMP_LIBGMP_DLL extern void (*dummy_func) (mpfr_srcptr); diff --git a/tests/texceptions.c b/tests/texceptions.c index f100f47dd..bc549220d 100644 --- a/tests/texceptions.c +++ b/tests/texceptions.c @@ -77,7 +77,7 @@ check_emin_emax (void) if ((mpfr_get_emax)() != MPFR_EMAX_MAX) ERROR("get_emax FAILED!"); if ((mpfr_set_emax)(MPFR_EMAX_MAX+1) == 0) - ERROR("set_emax failed! (2)"); + ERROR("set_emax failed! (2)"); if ((mpfr_get_emin_min) () != MPFR_EMIN_MIN) ERROR ("get_emin_min"); @@ -162,7 +162,7 @@ check_flags (void) (mpfr_clear_erangeflag) (); mpfr_set_ui (x, 1, GMP_RNDN); - mpfr_mul_2exp (x, x, 1024, GMP_RNDN); + mpfr_mul_2exp (x, x, 1024, GMP_RNDN); mpfr_get_ui (x, GMP_RNDN); if (!(mpfr_erangeflag_p)()) ERROR ("ERROR: No erange flag!\n"); @@ -259,7 +259,7 @@ test_set_overflow (void) static void check_set () { mpfr_clear_flags (); - + mpfr_set_overflow (); MPFR_ASSERTN ((mpfr_overflow_p) ()); mpfr_set_underflow (); diff --git a/tests/texp.c b/tests/texp.c index 5c567235d..d398ca2ad 100644 --- a/tests/texp.c +++ b/tests/texp.c @@ -244,11 +244,11 @@ check_special () mpfr_set_prec (x, 64); mpfr_set_emax (MPFR_EMAX_DEFAULT); mpfr_set_emin (MPFR_EMIN_DEFAULT); - mpfr_set_str (x, + mpfr_set_str (x, "0.1011000101110010000101111111010100001100000001110001100111001101E30", 2, GMP_RNDN); mpfr_exp (x, x, GMP_RNDD); - if (mpfr_cmp_str (x, + if (mpfr_cmp_str (x, ".1111111111111111111111111111111111111111111111111111111111111111E1073741823", 2, GMP_RNDN) != 0) { @@ -280,7 +280,7 @@ check_special () /* Check overflow. Corner case of mpfr_exp_3 */ if (MPFR_PREC_MAX > MPFR_EXP_THRESHOLD+10) { mpfr_set_prec (x, MPFR_EXP_THRESHOLD+10); - mpfr_set_str (x, + mpfr_set_str (x, "0.1011000101110010000101111111010100001100000001110001100111001101E30", 2, GMP_RNDN); mpfr_clear_overflow (); diff --git a/tests/tfits.c b/tests/tfits.c index b73c15ab3..1caadfdb7 100644 --- a/tests/tfits.c +++ b/tests/tfits.c @@ -207,7 +207,7 @@ static void check_intmax (void) mpfr_t x; mpfr_init2 (x, sizeof(uintmax_t)*CHAR_BIT); - + /* Check NAN */ mpfr_set_nan(x); if (mpfr_fits_uintmax_p(x, GMP_RNDN)) @@ -221,7 +221,7 @@ static void check_intmax (void) ERROR1; if (mpfr_fits_intmax_p(x, GMP_RNDN)) ERROR1; - + /* Check Zero */ MPFR_SET_ZERO(x); if (!mpfr_fits_uintmax_p(x, GMP_RNDN)) diff --git a/tests/tfma.c b/tests/tfma.c index 261349816..0a96d9415 100644 --- a/tests/tfma.c +++ b/tests/tfma.c @@ -234,7 +234,7 @@ main (int argc, char *argv[]) mp_prec_t p0=2, p1=200; unsigned int N=200; - + mpfr_init (t); mpfr_init (slong); diff --git a/tests/tgamma.c b/tests/tgamma.c index 0e0c75c43..f246773d6 100644 --- a/tests/tgamma.c +++ b/tests/tgamma.c @@ -37,7 +37,7 @@ special (void) mpfr_init (x); mpfr_init (y); - + mpfr_set_nan (x); mpfr_gamma (y, x, GMP_RNDN); if (!mpfr_nan_p (y)) @@ -45,7 +45,7 @@ special (void) printf ("Error for gamma(NaN)\n"); exit (1); } - + mpfr_set_inf (x, -1); mpfr_gamma (y, x, GMP_RNDN); if (!mpfr_nan_p (y)) @@ -53,7 +53,7 @@ special (void) printf ("Error for gamma(-Inf)\n"); exit (1); } - + mpfr_set_inf (x, 1); mpfr_gamma (y, x, GMP_RNDN); if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0) diff --git a/tests/tgeneric.c b/tests/tgeneric.c index 8d4015b5e..c6d3a9164 100644 --- a/tests/tgeneric.c +++ b/tests/tgeneric.c @@ -129,7 +129,7 @@ test_generic (mp_prec_t p0, mp_prec_t p1, unsigned int N) mpfr_clear (t); #ifdef TWO_ARGS mpfr_clear (u); -#endif +#endif } #undef RAND_FUNCTION diff --git a/tests/tgeneric_ui.c b/tests/tgeneric_ui.c index 3a40a35cf..57ba3a045 100644 --- a/tests/tgeneric_ui.c +++ b/tests/tgeneric_ui.c @@ -69,7 +69,7 @@ test_generic_ui (mp_prec_t p0, mp_prec_t p1, unsigned int N) printf ("results differ for x="); mpfr_out_str (stdout, 2, prec, x, GMP_RNDN); printf ("\nu=%lu", (unsigned long) u); - printf (" prec=%lu rnd_mode=%s\n", + printf (" prec=%lu rnd_mode=%s\n", (unsigned long ) prec, mpfr_print_rnd_mode (rnd)); #ifdef TEST_FUNCTION_NAME printf ("Function: %s\n", TEST_FUNCTION_NAME); diff --git a/tests/tget_sj.c b/tests/tget_sj.c index 609c22cd1..196cc4b1c 100644 --- a/tests/tget_sj.c +++ b/tests/tget_sj.c @@ -142,8 +142,8 @@ check_erange (void) intmax_t d; /* Test for ERANGE flag + correct behaviour if overflow */ - - mpfr_init2 (x, 256); + + mpfr_init2 (x, 256); mpfr_set_uj (x, UINTMAX_MAX, GMP_RNDN); mpfr_clear_erangeflag (); dl = mpfr_get_uj (x, GMP_RNDN); @@ -197,7 +197,7 @@ check_erange (void) printf ("ERROR for get_sj + ERANGE + INTMAX_MIN (2)\n"); exit (1); } - + mpfr_clear (x); } diff --git a/tests/tget_str.c b/tests/tget_str.c index e2f35b0f8..90c95b31d 100644 --- a/tests/tget_str.c +++ b/tests/tget_str.c @@ -66,7 +66,7 @@ check_small (void) exit (1); } mpfr_free_str (s); - + /* check n_digits=0 */ mpfr_set_prec (x, 5); mpfr_set_ui (x, 17, GMP_RNDN); @@ -74,7 +74,7 @@ check_small (void) mpfr_free_str (s); s = mpfr_get_str (NULL, &e, 36, 0, x, GMP_RNDN); mpfr_free_str (s); - + mpfr_set_prec (x, 64); mpfr_set_si (x, -1, GMP_RNDN); mpfr_div_2exp (x, x, 63, GMP_RNDN); /* x = -2^(-63) */ @@ -96,7 +96,7 @@ check_small (void) exit (1); } mpfr_free_str (s); - + /* check corner case ret!=0, j0!=0 in mpfr_get_str_aux */ mpfr_set_prec (x, 100); mpfr_set_str_binary (x, "0.1001011111010001101110010101010101111001010111111101101101100110100011110110000101110110001011110000E-9"); @@ -108,7 +108,7 @@ check_small (void) exit (1); } mpfr_free_str (s); - + /* check corner case exact=0 in mpfr_get_str_aux */ mpfr_set_prec (x, 100); mpfr_set_str_binary (x, "0.1001001111101101111000101000110111111010101100000110010001111111011001101011101100001100110000000000E8"); @@ -120,7 +120,7 @@ check_small (void) exit (1); } mpfr_free_str (s); - + for (p=4; p<=200; p++) { mpfr_set_prec (x, p); @@ -134,7 +134,7 @@ check_small (void) exit (1); } mpfr_free_str (s); - + mpfr_nexttoinf (x); s = mpfr_get_str (NULL, &e, 6, 2, x, GMP_RNDN); if (strcmp (s, "11") || (e != 2)) @@ -407,7 +407,7 @@ check_small (void) exit (1); } mpfr_free_str (s); - + mpfr_set_str_binary (x, "11111001010011100101000001111111110001001001110110001E-136"); s = mpfr_get_str (NULL, &e, 10, 9, x, GMP_RNDN); if (strcmp (s, "100693858") || e != -24) @@ -415,7 +415,7 @@ check_small (void) printf ("Error in mpfr_get_str (27): s=%s e=%d\n", s, (int) e); exit (1); } - mpfr_free_str (s); + mpfr_free_str (s); mpfr_set_str_binary (x, "10001000001110010110001011111011111011011010000110001E-110"); s = mpfr_get_str (NULL, &e, 10, 14, x, GMP_RNDN); if (strcmp (s, "36923634350619") || e != -17) diff --git a/tests/tget_z.c b/tests/tget_z.c index f143e916e..d76e05926 100644 --- a/tests/tget_z.c +++ b/tests/tget_z.c @@ -59,8 +59,8 @@ check_one (mpz_ptr z) for (neg = 0; neg <= 1; neg++) { mpz_neg (z, z); - mpfr_set_z (f, z, GMP_RNDN); - + mpfr_set_z (f, z, GMP_RNDN); + if (sh < 0) { mpz_tdiv_q_2exp (z, z, -sh); @@ -72,7 +72,7 @@ check_one (mpz_ptr z) mpfr_mul_2exp (f, f, sh, GMP_RNDN); } - mpfr_get_z (got, f, GMP_RNDZ); + mpfr_get_z (got, f, GMP_RNDZ); if (mpz_cmp (got, z) != 0) { diff --git a/tests/tgmpop.c b/tests/tgmpop.c index 5af53ddc7..d2538fa2e 100644 --- a/tests/tgmpop.c +++ b/tests/tgmpop.c @@ -145,14 +145,14 @@ check_for_zero () MPFR_SET_ZERO (x); for(r = 0 ; r < GMP_RND_MAX ; r++) { - for (i = MPFR_SIGN_NEG ; i <= MPFR_SIGN_POS ; + for (i = MPFR_SIGN_NEG ; i <= MPFR_SIGN_POS ; i+=MPFR_SIGN_POS-MPFR_SIGN_NEG) { MPFR_SET_SIGN(x, i); mpfr_add_z (x, x, z, (mp_rnd_t) r); if (!MPFR_IS_ZERO(x) || MPFR_SIGN(x)!=i) { - printf("GMP Zero errors for add_z & rnd=%s & s=%d\n", + printf("GMP Zero errors for add_z & rnd=%s & s=%d\n", mpfr_print_rnd_mode ((mp_rnd_t) r), i); mpfr_dump (x); exit (1); @@ -426,7 +426,7 @@ test_genericz (mp_prec_t p0, mp_prec_t p1, unsigned int N, "arg1=", (unsigned) prec, mpfr_print_rnd_mode (rnd), op); mpfr_print_binary (arg1); - printf("\narg2="); + printf("\narg2="); mpz_out_str (stdout, 2, arg2); printf ("\ngot "); mpfr_dump (dst_small); @@ -448,12 +448,12 @@ test_genericz (mp_prec_t p0, mp_prec_t p1, unsigned int N, ((inexact < 0) && (compare >= 0))) { printf ("Wrong inexact flag for rnd=%s and %s_z:\n" - "expected %d, got %d\n", + "expected %d, got %d\n", mpfr_print_rnd_mode (rnd), op, compare, inexact); printf ("\narg1="); mpfr_print_binary (arg1); printf ("\narg2="); mpz_out_str(stdout, 2, arg2); - printf ("\ndstl="); mpfr_print_binary (dst_big); - printf ("\ndsts="); mpfr_print_binary (dst_small); + printf ("\ndstl="); mpfr_print_binary (dst_big); + printf ("\ndsts="); mpfr_print_binary (dst_small); printf ("\ntmp ="); mpfr_dump (tmp); exit (1); } @@ -527,7 +527,7 @@ test_genericq (mp_prec_t p0, mp_prec_t p1, unsigned int N, ((inexact < 0) && (compare >= 0))) { printf ("Wrong inexact flag for rnd=%s and %s_q:\n" - "expected %d, got %d", + "expected %d, got %d", mpfr_print_rnd_mode (rnd), op, compare, inexact); printf ("\narg1="); mpfr_print_binary (arg1); printf ("\narg2="); mpq_out_str(stdout, 2, arg2); diff --git a/tests/tinp_str.c b/tests/tinp_str.c index ef25bd262..dab6ee25f 100644 --- a/tests/tinp_str.c +++ b/tests/tinp_str.c @@ -65,7 +65,7 @@ main (int argc, char *argv[]) exit (1); } fclose (f); - + mpfr_clear (x); tests_end_mpfr (); diff --git a/tests/tlog.c b/tests/tlog.c index 6990d5a49..72d04676d 100644 --- a/tests/tlog.c +++ b/tests/tlog.c @@ -58,7 +58,7 @@ check2 (const char *as, mp_rnd_t rnd_mode, const char *res1s) if (mpfr_cmp_str1 (tres, res1s)) { - printf ("mpfr_log failed for a=%s, rnd_mode=%s\n", + printf ("mpfr_log failed for a=%s, rnd_mode=%s\n", as, mpfr_print_rnd_mode (rnd_mode)); printf ("correct result is %s\n mpfr_log gives ", res1s); @@ -245,7 +245,7 @@ main (int argc, char *argv[]) check2("8.0",GMP_RNDZ,"2.07944154167983574765e+00"); check2("44.0",GMP_RNDU,"3.78418963391826146392e+00"); check2("1.01979300812244555452", GMP_RNDN, "1.95996734891603664741e-02"); - + /* bugs found by Vincent Lefe`vre */ check2("0.99999599881598921769", GMP_RNDN, "-0.0000040011920155404072924737977900999652547398000024259090423583984375"); check2("9.99995576063808955247e-01",GMP_RNDZ,"-4.42394597667932383816e-06"); @@ -256,17 +256,17 @@ main (int argc, char *argv[]) check2("9.99985901426543311032e-01",GMP_RNDN,"-1.40986728425098585229e-05"); check2("9.99986053947420794330e-01",GMP_RNDN, "-0.000013946149826301084938555592540598837558718514628708362579345703125"); check2("9.99971938247442126979e-01",GMP_RNDN,"-2.80621462962173414790e-05"); - + /* other bugs found by Vincent Lefe`vre */ check2("1.18615436389927785905e+77",GMP_RNDN,"1.77469768607706015473e+02"); check2("9.48868723578399476187e+77",GMP_RNDZ,"1.79549152432275803903e+02"); check2("2.31822210096938820854e+89",GMP_RNDN,"2.05770873832573869322e+02"); - + /* further bugs found by Vincent Lefe`vre */ check2("9.99999989485669482647e-01",GMP_RNDZ,"-1.05143305726283042331e-08"); check2("9.99999989237970177136e-01",GMP_RNDZ,"-1.07620298807745377934e-08"); check2("9.99999989239339082125e-01",GMP_RNDN,"-1.07606609757704445430e-08"); - + check2("7.3890560989306504",GMP_RNDU,"2.0000000000000004"); /* exp(2.0) */ check2("7.3890560989306495",GMP_RNDU,"2.0"); /* exp(2.0) */ check2("7.53428236571286402512e+34",GMP_RNDZ,"8.03073567492226345621e+01"); @@ -297,7 +297,7 @@ main (int argc, char *argv[]) check2("6.09969788341579732815e+00",GMP_RNDD,"1.80823924264386204363e+00"); test_generic (2, 100, 40); - + done: tests_end_mpfr (); return 0; diff --git a/tests/tlog10.c b/tests/tlog10.c index 7ff4705d1..b93750043 100644 --- a/tests/tlog10.c +++ b/tests/tlog10.c @@ -87,7 +87,7 @@ main (int argc, char *argv[]) mpfr_set_ui (x, 1, GMP_RNDN); test_log10 (y, x, GMP_RNDN); MPFR_ASSERTN((mpfr_cmp_ui (y, 0) == 0) && (MPFR_IS_POS (y))); - + /* check log10(10^n)=n */ mpfr_set_ui (x, 1, GMP_RNDN); for (n = 1; n <= 15; n++) diff --git a/tests/tlog1p.c b/tests/tlog1p.c index 8fee11477..54ea27ee4 100644 --- a/tests/tlog1p.c +++ b/tests/tlog1p.c @@ -57,7 +57,7 @@ special (void) mpfr_t x; mpfr_init (x); - + mpfr_set_nan (x); test_log1p (x, x, GMP_RNDN); MPFR_ASSERTN(mpfr_nan_p (x)); diff --git a/tests/tlog2.c b/tests/tlog2.c index d3665d082..718cd20e4 100644 --- a/tests/tlog2.c +++ b/tests/tlog2.c @@ -34,7 +34,7 @@ special (void) mpfr_t x; mpfr_init (x); - + mpfr_set_nan (x); mpfr_log2 (x, x, GMP_RNDN); MPFR_ASSERTN(mpfr_nan_p (x)); diff --git a/tests/tminmax.c b/tests/tminmax.c index 6d81ec164..392fc7bc1 100644 --- a/tests/tminmax.c +++ b/tests/tminmax.c @@ -78,7 +78,7 @@ main (void) exit (1); } /* Case x=0+ and x=0- */ - mpfr_set_ui (x, 0, GMP_RNDN); + mpfr_set_ui (x, 0, GMP_RNDN); mpfr_set_ui (y, 0, GMP_RNDN); MPFR_SET_NEG(y); mpfr_max (z, x, y, GMP_RNDN); if (!MPFR_IS_ZERO(z) || MPFR_IS_NEG(z)) diff --git a/tests/tmul.c b/tests/tmul.c index 3203bbafc..ac289f79c 100644 --- a/tests/tmul.c +++ b/tests/tmul.c @@ -140,7 +140,7 @@ check24 (const char *xs, const char *ys, mp_rnd_t rnd_mode, const char *zs) mpfr_clears(xx, yy, zz, NULL); } -/* the following examples come from the paper "Number-theoretic Test +/* the following examples come from the paper "Number-theoretic Test Generation for Directed Rounding" from Michael Parks, Table 1 */ static void check_float (void) @@ -332,7 +332,7 @@ check_max(void) /* exact result is 0.1E-1, which should round to 0 */ MPFR_ASSERTN(mpfr_cmp_ui (zz, 0) == 0 && MPFR_IS_POS(zz)); set_emin (emin); - + /* coverage test for mpfr_powerof2_raw */ emin = mpfr_get_emin (); set_emin (0); @@ -344,7 +344,7 @@ check_max(void) /* exact result is just above 0.1E-1, which should round to minfloat */ MPFR_ASSERTN(mpfr_cmp (zz, yy) == 0); set_emin (emin); - + mpfr_clear(xx); mpfr_clear(yy); mpfr_clear(zz); @@ -447,8 +447,8 @@ check_regression (void) int i; mpfr_inits2 (6177, x, y, z, NULL); - - mpfr_set_str (y, + + mpfr_set_str (y, "5.17cc1b727220a94fe13abe8fa9a6ee06db14acc9e21c820ff28b1d5ef5de2b0db92371d212" "6e9700324977504e8c90e7f0ef58e5894d39f74411afa975da24274ce38135a2fbf209cc8eb1" "cc1a99cfa4e422fc5defc941d8ffc4bffef02cc07f79788c5ad05368fb69b3f6793e584dba7a" @@ -493,7 +493,7 @@ check_regression (void) "ffa35db8f011a010fa3d98fd2183b84afcb56c2dd1d35b9a53e479b6f84565d28e49bc4bfb97" "90e1ddf2daa4cb7e3362fb1342", 16, GMP_RNDN); i = mpfr_mul (x, y, z, GMP_RNDN); - if (mpfr_cmp_str (x, + if (mpfr_cmp_str (x, "f.fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" @@ -580,14 +580,14 @@ check_regression (void) printf ("\n"); exit (1); } - + mpfr_set_prec (x, 50); mpfr_set_prec (y, 40); mpfr_set_prec (z, 53); mpfr_set_str (y, "4.1ffffffff8", 16, GMP_RNDN); mpfr_set_str (z, "4.2000000ffe0000@-4", 16, GMP_RNDN); - i = mpfr_mul (x, y, z, GMP_RNDN); + i = mpfr_mul (x, y, z, GMP_RNDN); if (mpfr_cmp_str (x, "1.104000041d6c0@-3", 16, GMP_RNDN) != 0 || i <= 0) { @@ -655,8 +655,8 @@ main (int argc, char *argv[]) check53("0.0", "6.9314718055994530941514e-1", GMP_RNDZ, "0.0"); check_sign(); check53("-4.165000000e4", "-0.00004801920768307322868063274915", GMP_RNDN, - "2.0"); - check53("2.71331408349172961467e-08", "-6.72658901114033715233e-165", + "2.0"); + check53("2.71331408349172961467e-08", "-6.72658901114033715233e-165", GMP_RNDZ, "-1.8251348697787782844e-172"); check53("0.31869277231188065", "0.88642843322303122", GMP_RNDZ, "2.8249833483992453642e-1"); @@ -664,12 +664,12 @@ main (int argc, char *argv[]) 28, 45, 2, "0.375"); check("2.63978122803639081440e-01", "6.8378615379333496093e-1", GMP_RNDN, 34, 23, 31, "0.180504585267044603"); - check("1.0", "0.11835170935876249132", GMP_RNDU, 6, 41, 36, + check("1.0", "0.11835170935876249132", GMP_RNDU, 6, 41, 36, "0.1183517093595583"); check53("67108865.0", "134217729.0", GMP_RNDN, "9.007199456067584e15"); check("1.37399642157394197284e-01", "2.28877275604219221350e-01", GMP_RNDN, 49, 15, 32, "0.0314472340833162888"); - check("4.03160720978664954828e-01", "5.854828e-1" + check("4.03160720978664954828e-01", "5.854828e-1" /*"5.85483042917246621073e-01"*/, GMP_RNDZ, 51, 22, 32, "0.2360436821472831"); check("3.90798504668055102229e-14", "9.85394674650308388664e-04", GMP_RNDN, diff --git a/tests/tmul_ui.c b/tests/tmul_ui.c index f5d88789d..b862f99bc 100644 --- a/tests/tmul_ui.c +++ b/tests/tmul_ui.c @@ -152,7 +152,7 @@ main (int argc, char *argv[]) MPFR_ASSERTN(mpfr_inf_p (x) && MPFR_IS_POS(x)); set_emax (emax); - mpfr_set_str (x, /*1.0/3.0*/ + mpfr_set_str (x, /*1.0/3.0*/ "0.333333333333333333333333333333333", 10, GMP_RNDZ); mpfr_mul_ui (x, x, 3, GMP_RNDU); if (mpfr_cmp_ui (x, 1)) diff --git a/tests/tout_str.c b/tests/tout_str.c index 780733400..b799e48e0 100644 --- a/tests/tout_str.c +++ b/tests/tout_str.c @@ -120,7 +120,7 @@ special (void) mpfr_out_str (fout, 10, 0, x, GMP_RNDN); mpfr_neg (x, x, GMP_RNDN); mpfr_out_str (fout, 10, 0, x, GMP_RNDN); - + mpfr_clear (x); } diff --git a/tests/toutimpl.c b/tests/toutimpl.c index 486e18c39..62861d4c0 100644 --- a/tests/toutimpl.c +++ b/tests/toutimpl.c @@ -30,7 +30,7 @@ MA 02110-1301, USA. */ We can't use tmpname since it is insecure */ #define FILE_NAME "dummy.tmp" -static const char Buffer[] = +static const char Buffer[] = "@NaN@\n" "-@Inf@\n" "-0\n" @@ -72,7 +72,7 @@ int main() exit (1); } - /* Reopen stdout to a file. All errors will be put to stderr + /* Reopen stdout to a file. All errors will be put to stderr Can't use tmpname since it is unsecure */ if (freopen (FILE_NAME, "w", stdout) == NULL) { @@ -89,7 +89,7 @@ int main() mpfr_set_str_binary (x, "0.101010101010111110010001100011000100001E32"); mpfr_dump (x); mpfr_print_mant_binary ("x=",MPFR_MANT(x), MPFR_PREC(x)); - + mpfr_clear (x); fclose (stdout); @@ -112,7 +112,7 @@ int main() fprintf (stderr, "Character mismatch for i=%d / %lu\n", i, (unsigned long) sizeof(Buffer)); exit (1); - } + } } fclose (f); diff --git a/tests/tpow_z.c b/tests/tpow_z.c index de6811aee..3c31de58c 100644 --- a/tests/tpow_z.c +++ b/tests/tpow_z.c @@ -160,8 +160,8 @@ static void check_integer (mp_prec_t begin, mp_prec_t end, unsigned long max) { /* printf ("Check pow_z\n"); */ res2 = mpfr_pow_z (y2, x, z, rnd); if (mpfr_cmp (y1, y2) != 0) { - printf ("Error for p=%lu, z=%ld, rnd=%s and x=", p, n, - mpfr_print_rnd_mode (rnd)); + printf ("Error for p=%lu, z=%ld, rnd=%s and x=", p, n, + mpfr_print_rnd_mode (rnd)); mpfr_dump (x); printf ("Ypowui="); mpfr_dump (y1); printf ("Ypowz ="); mpfr_dump (y2); @@ -182,7 +182,7 @@ static void check_integer (mp_prec_t begin, mp_prec_t end, unsigned long max) { mpz_clear (z); } -static void check_regression (void) +static void check_regression (void) { mpfr_t x, y; mpz_t z; @@ -200,7 +200,7 @@ static void check_regression (void) printf ("Regression (1) tested failed (%d=?%d)\n",res1, res2); printf ("pow_ui: "); mpfr_dump (x); printf ("pow_z: "); mpfr_dump (y); - + exit (1); } @@ -212,7 +212,7 @@ static void check_regression (void) int main () { MPFR_TEST_USE_RANDS (); tests_start_mpfr (); - + check_special (); check_integer (2, 163, 100); check_regression (); diff --git a/tests/trandom.c b/tests/trandom.c index d0092c0fc..6e249e72d 100644 --- a/tests/trandom.c +++ b/tests/trandom.c @@ -28,14 +28,14 @@ MA 02110-1301, USA. */ static void test_random (long nbtests, mp_prec_t prec, int verbose) { - mpfr_t x; - int *tab, size_tab, k; - double d, av = 0, var = 0, chi2 = 0, th; + mpfr_t x; + int *tab, size_tab, k; + double d, av = 0, var = 0, chi2 = 0, th; - mpfr_init2(x, prec); + mpfr_init2(x, prec); - size_tab = (nbtests >= 1000 ? nbtests / 50 : 20); - tab = (int *) malloc (size_tab * sizeof(int)); + size_tab = (nbtests >= 1000 ? nbtests / 50 : 20); + tab = (int *) malloc (size_tab * sizeof(int)); for (k = 0; k < size_tab; ++k) tab[k] = 0; @@ -53,14 +53,14 @@ test_random (long nbtests, mp_prec_t prec, int verbose) return; } - av /= nbtests; - var = (var /nbtests) - av*av; + av /= nbtests; + var = (var /nbtests) - av*av; th = (double) nbtests / size_tab; - - printf("Average = %.5f\nVariance = %.5f\n", av, var); - printf("Repartition for random. Each integer should be close to %d.\n", - (int)th); + + printf("Average = %.5f\nVariance = %.5f\n", av, var); + printf("Repartition for random. Each integer should be close to %d.\n", + (int)th); for (k = 0; k < size_tab; k++) { @@ -90,8 +90,8 @@ test_random2 (long nbtests, mp_prec_t prec, int verbose) xn = 1 + (prec - 1) / mp_bits_per_limb; sh = xn * mp_bits_per_limb - prec; - size_tab = (nbtests >= 1000 ? nbtests / 50 : 20); - tab = (int *) malloc (size_tab * sizeof(int)); + size_tab = (nbtests >= 1000 ? nbtests / 50 : 20); + tab = (int *) malloc (size_tab * sizeof(int)); for (k = 0; k < size_tab; ++k) tab[k] = 0; @@ -132,7 +132,7 @@ test_random2 (long nbtests, mp_prec_t prec, int verbose) free(tab); return; } - + av /= nbtests; var = (var /nbtests) - av*av; @@ -158,9 +158,9 @@ test_random2 (long nbtests, mp_prec_t prec, int verbose) static void test_urandomb (long nbtests, mp_prec_t prec, int verbose) { - mpfr_t x; + mpfr_t x; int *tab, size_tab, k, sh, xn; - gmp_randstate_t state; + gmp_randstate_t state; double d, av = 0, var = 0, chi2 = 0, th; mp_exp_t emin; @@ -168,8 +168,8 @@ test_urandomb (long nbtests, mp_prec_t prec, int verbose) xn = 1 + (prec - 1) / mp_bits_per_limb; sh = xn * mp_bits_per_limb - prec; - size_tab = (nbtests >= 1000 ? nbtests / 50 : 20); - tab = (int *) malloc (size_tab * sizeof(int)); + size_tab = (nbtests >= 1000 ? nbtests / 50 : 20); + tab = (int *) malloc (size_tab * sizeof(int)); for (k = 0; k < size_tab; ++k) tab[k] = 0; @@ -238,9 +238,9 @@ int main (int argc, char *argv[]) { long nbtests; - mp_prec_t prec; - int verbose = 0; - + mp_prec_t prec; + int verbose = 0; + MPFR_TEST_USE_RANDS (); tests_start_mpfr (); @@ -261,7 +261,7 @@ main (int argc, char *argv[]) prec = atol(argv[2]); test_random (nbtests, prec, verbose); - test_random2 (nbtests, prec, verbose); + test_random2 (nbtests, prec, verbose); test_urandomb (nbtests, prec, verbose); if (argc == 1) /* check also small precision */ diff --git a/tests/trint.c b/tests/trint.c index b23481a61..d6d2de2ea 100644 --- a/tests/trint.c +++ b/tests/trint.c @@ -136,7 +136,7 @@ special (void) /* Bug found by Mark J Watkins */ mpfr_set_prec (x, 84); - mpfr_set_str_binary (x, + mpfr_set_str_binary (x, "0.110011010010001000000111101101001111111100101110010000000000000" \ "000000000000000000000E32"); mpfr_round (x, x); @@ -192,7 +192,7 @@ test_against_libc (void) #if HAVE_ROUND TEST_FCT (round); -#endif +#endif #if HAVE_TRUNC TEST_FCT (trunc); #endif diff --git a/tests/tset_si.c b/tests/tset_si.c index 5c2625e31..4e1935cb9 100644 --- a/tests/tset_si.c +++ b/tests/tset_si.c @@ -35,7 +35,7 @@ test_2exp (void) int res; mpfr_init2 (x, 32); - + mpfr_set_ui_2exp (x, 1, 0, GMP_RNDN); if (mpfr_cmp_ui(x, 1)) ERROR("(1U,0)"); @@ -183,7 +183,7 @@ main (int argc, char *argv[]) mpfr_set_ui (x, 0, (mp_rnd_t) r); if (MPFR_IS_NEG (x) || mpfr_get_ui (x, (mp_rnd_t) r) != 0) { - printf ("mpfr_set_ui (x, 0) gives -0 for %s\n", + printf ("mpfr_set_ui (x, 0) gives -0 for %s\n", mpfr_print_rnd_mode ((mp_rnd_t) r)); exit (1); } @@ -197,7 +197,7 @@ main (int argc, char *argv[]) exit (1); } } - + /* check potential bug in case mp_limb_t is unsigned */ emax = mpfr_get_emax (); set_emax (0); @@ -266,7 +266,7 @@ main (int argc, char *argv[]) MPFR_ASSERTN (mpfr_get_si (x, GMP_RNDD) == 0); /* Test for ERANGE flag + correct behaviour if overflow */ - mpfr_set_prec (x, 256); + mpfr_set_prec (x, 256); mpfr_set_ui (x, ULONG_MAX, GMP_RNDN); mpfr_clear_erangeflag (); dl = mpfr_get_ui (x, GMP_RNDN); @@ -320,7 +320,7 @@ main (int argc, char *argv[]) printf ("ERROR for get_si + ERANGE + LONG_MIN (2)\n"); exit (1); } - + mpfr_clear (x); test_2exp (); diff --git a/tests/tset_sj.c b/tests/tset_sj.c index 621441704..494178598 100644 --- a/tests/tset_sj.c +++ b/tests/tset_sj.c @@ -1,4 +1,4 @@ -/* Test file for +/* Test file for mpfr_set_sj, mpfr_set_uj, mpfr_set_sj_2exp and mpfr_set_uj_2exp. Copyright 2004 Free Software Foundation, Inc. @@ -50,7 +50,7 @@ int main() { return 0; } #define ERROR(str) {printf("Error for "str"\n"); exit(1);} -static int +static int inexact_sign (int x) { return (x < 0) ? -1 : (x > 0); @@ -78,7 +78,7 @@ check_set_uj (mp_prec_t pmin, mp_prec_t pmax, int N) inex2 = mpfr_set_ui (y, limb, GMP_RNDN); if (mpfr_cmp (x, y)) { - printf ("ERROR for mpfr_set_uj and j=%lu and p=%lu\n", + printf ("ERROR for mpfr_set_uj and j=%lu and p=%lu\n", (unsigned long) limb, p); printf ("X="); mpfr_dump (x); printf ("Y="); mpfr_dump (y); @@ -88,7 +88,7 @@ check_set_uj (mp_prec_t pmin, mp_prec_t pmax, int N) { printf ("ERROR for inexact(set_uj): j=%lu p=%lu\n" "Inexact1= %d Inexact2= %d\n", - (unsigned long) limb, p, inex1, inex2); + (unsigned long) limb, p, inex1, inex2); exit (1); } } @@ -116,7 +116,7 @@ check_set_uj_2exp (void) int inex; mpfr_init2 (x, sizeof(uintmax_t)*CHAR_BIT); - + inex = mpfr_set_uj_2exp (x, 1, 0, GMP_RNDN); if (inex || mpfr_cmp_ui(x, 1)) ERROR("(1U,0)"); @@ -135,7 +135,7 @@ check_set_uj_2exp (void) if (inex || !mpfr_powerof2_raw (x) || MPFR_EXP (x) != (sizeof(uintmax_t)*CHAR_BIT+1) ) ERROR("(UINTMAX_MAX)"); - + inex = mpfr_set_uj_2exp (x, UINTMAX_MAX, MPFR_EMAX_MAX-10, GMP_RNDN); if (inex == 0 || !mpfr_inf_p (x)) ERROR ("Overflow"); @@ -154,13 +154,13 @@ check_set_sj () int inex; mpfr_init2 (x, sizeof(intmax_t)*CHAR_BIT-1); - + inex = mpfr_set_sj (x, -INTMAX_MAX, GMP_RNDN); inex |= mpfr_add_si (x, x, -1, GMP_RNDN); if (inex || mpfr_sgn (x) >=0 || !mpfr_powerof2_raw (x) || MPFR_EXP (x) != (sizeof(intmax_t)*CHAR_BIT) ) ERROR("set_sj (-INTMAX_MAX)"); - + inex = mpfr_set_sj (x, 1742, GMP_RNDN); if (inex || mpfr_cmp_ui (x, 1742)) ERROR ("set_sj (1742)"); diff --git a/tests/tset_str.c b/tests/tset_str.c index c563084b8..169a4797d 100644 --- a/tests/tset_str.c +++ b/tests/tset_str.c @@ -44,7 +44,7 @@ MA 02110-1301, USA. */ exit (1); \ } -static void +static void check_underflow (void) { mpfr_t a; @@ -656,7 +656,7 @@ main (int argc, char *argv[]) CHECK53(y, "5783893e-128", GMP_RNDU, x, "0.10011000111100000110011110000101100111110011101110101E-402", 38); - + CHECK53(y, "87575437e-310", GMP_RNDD, x, "0.11000000001011100000110011110011010000000010001010110E-1003", 39); @@ -827,7 +827,7 @@ main (int argc, char *argv[]) mpfr_set_prec (y, 135); mpfr_set_str (y, "23833565676460972739462619524519814462546", 10, GMP_RNDN); MPFR_ASSERTN (mpfr_cmp (x, y) == 0 && ret == 0); - + /* coverage test for set_str_binary */ mpfr_set_str_binary (x, "NaN"); MPFR_ASSERTN(mpfr_nan_p (x)); diff --git a/tests/tset_z.c b/tests/tset_z.c index 7c6b17d7a..e8d81f1b3 100644 --- a/tests/tset_z.c +++ b/tests/tset_z.c @@ -48,7 +48,7 @@ static void check0(void) } mpfr_clear(x); mpz_clear(y); -} +} /* FIXME: It'd be better to examine the actual data in an mpfr_t to see that it's as expected. Comparing mpfr_set_z with mpfr_cmp or against diff --git a/tests/tsi_op.c b/tests/tsi_op.c index fdf15d895..0d28f721e 100644 --- a/tests/tsi_op.c +++ b/tests/tsi_op.c @@ -1,4 +1,4 @@ -/* Test file for mpfr_add_si, mpfr_sub_si, mpfr_si_sub, mpfr_mul_si, +/* Test file for mpfr_add_si, mpfr_sub_si, mpfr_si_sub, mpfr_mul_si, mpfr_div_si, mpfr_si_div Copyright 2004 Free Software Foundation. @@ -41,7 +41,7 @@ const struct { const char * res_sub; const char * res_mul; const char * res_div; -} tab[] = { +} tab[] = { {"10", 0x1, "11", "0F", "10", "10"}, {"1", -1, "0", "2", "-1", "-1"}, {"17.42", -0x17, "0.42", "2E.42", "-216.ee", "-1.02de9bd37a6f4"}, @@ -53,7 +53,7 @@ check_invert () { mpfr_t x; mpfr_init2 (x, MPFR_PREC_MIN); - + mpfr_set_ui (x, 0xC, GMP_RNDN); mpfr_si_sub (x, -1, x, GMP_RNDD); /* -0001 - 1100 = - 1101 --> -1 0000 */ if (mpfr_cmp_si (x, -0x10) ) diff --git a/tests/tsin.c b/tests/tsin.c index 6919bc9f4..a5401a543 100644 --- a/tests/tsin.c +++ b/tests/tsin.c @@ -113,7 +113,7 @@ test_sign (void) test_sin (y, x, GMP_RNDN); mpfr_set_str_binary (x, "11011010111101011110111100010101010101110000000001011E-106"); MPFR_ASSERTN(mpfr_cmp (x, y) == 0); - + /* Bug on Special cases */ mpfr_set_str_binary (x, "0.100011011010111101E-32"); test_sin (y, x, GMP_RNDN); diff --git a/tests/tsin_cos.c b/tests/tsin_cos.c index 441f3d5ad..a8ceeafbe 100644 --- a/tests/tsin_cos.c +++ b/tests/tsin_cos.c @@ -35,7 +35,7 @@ large_test (int prec, int N) mpfr_init2 (c, prec); mpfr_set_ui (x, 3, GMP_RNDN); mpfr_sqrt (x, x, GMP_RNDN); - for (i=0; i<N; i++) + for (i=0; i<N; i++) mpfr_sin_cos (s, c, x, GMP_RNDN); mpfr_out_str (stdout, 10, 0, s, GMP_RNDN); puts (""); mpfr_clear (x); @@ -44,7 +44,7 @@ large_test (int prec, int N) } static void -check53 (const char *xs, const char *sin_xs, const char *cos_xs, +check53 (const char *xs, const char *sin_xs, const char *cos_xs, mp_rnd_t rnd_mode) { mpfr_t xx, s, c; @@ -178,7 +178,7 @@ main(int argc, char *argv[]) } /* worst case from PhD thesis of Vincent Lefe`vre: x=8980155785351021/2^54 */ - check53 ("4.984987858808754279e-1", "4.781075595393330379e-1", + check53 ("4.984987858808754279e-1", "4.781075595393330379e-1", "8.783012931285841817e-1", GMP_RNDN); check53 ("4.984987858808754279e-1", "4.781075595393329824e-1", "8.783012931285840707e-1", GMP_RNDD); diff --git a/tests/tsqr.c b/tests/tsqr.c index 103b8bced..dce8d4960 100644 --- a/tests/tsqr.c +++ b/tests/tsqr.c @@ -41,14 +41,14 @@ int main(void) return 0; } -static int +static int inexact_sign (int x) { return (x < 0) ? -1 : (x > 0); } -static void -error1 (mp_rnd_t rnd, mpfr_prec_t prec, +static void +error1 (mp_rnd_t rnd, mpfr_prec_t prec, mpfr_t in, mpfr_t outmul, mpfr_t outsqr) { printf("ERROR: for %s and prec=%lu\nINPUT=", mpfr_print_rnd_mode(rnd), prec); @@ -59,7 +59,7 @@ error1 (mp_rnd_t rnd, mpfr_prec_t prec, } static void -error2 (mp_rnd_t rnd, mpfr_prec_t prec, mpfr_t in, mpfr_t out, +error2 (mp_rnd_t rnd, mpfr_prec_t prec, mpfr_t in, mpfr_t out, int inexactmul, int inexactsqr) { printf("ERROR: for %s and prec=%lu\nINPUT=", mpfr_print_rnd_mode(rnd), prec); @@ -104,7 +104,7 @@ void check_special(void) mpfr_set_nan (x); mpfr_sqr (y, x, GMP_RNDN); MPFR_ASSERTN (mpfr_nan_p (y)); - + mpfr_set_inf (x, 1); mpfr_sqr (y, x, GMP_RNDN); MPFR_ASSERTN (mpfr_inf_p (y) && mpfr_sgn (y) > 0); diff --git a/tests/tsqrt.c b/tests/tsqrt.c index b01898775..14a90f701 100644 --- a/tests/tsqrt.c +++ b/tests/tsqrt.c @@ -351,7 +351,7 @@ special (void) MPFR_ASSERTN (mpfr_mul (x, x, x, GMP_RNDN) == 0); /* exact */ inexact = test_sqrt (z, x, GMP_RNDN); /* even rule: z should be 2^(BITS_PER_MP_LIMB - 1) */ - MPFR_ASSERTN (inexact < 0); + MPFR_ASSERTN (inexact < 0); MPFR_ASSERTN (mpfr_cmp_ui_2exp (z, 1, BITS_PER_MP_LIMB - 1) == 0); mpfr_nextbelow (x); /* now x is just below [2^(BITS_PER_MP_LIMB - 1) + 1]^2 */ @@ -520,7 +520,7 @@ test_property1 (mp_prec_t p, mp_rnd_t r) printf ("got "); mpfr_dump (z); exit (1); } - + mpfr_clear (x); mpfr_clear (y); mpfr_clear (z); diff --git a/tests/tstrtofr.c b/tests/tstrtofr.c index eca635dbe..fc915ea0e 100644 --- a/tests/tstrtofr.c +++ b/tests/tstrtofr.c @@ -37,7 +37,7 @@ int main (int argc, char *argv[]) { tests_start_mpfr (); - + check_special(); check_reftable (); check_parse (); @@ -131,7 +131,7 @@ check_special (void) mpfr_dump (x); exit (1); } - + /* Check Zero */ res = mpfr_strtofr (x, " 00000", &s, 11, GMP_RNDN); if (res != 0 || !mpfr_zero_p (x) || s[0] != 0) @@ -147,7 +147,7 @@ check_special (void) if (res != 0 || mpfr_cmp_ui (x, 10)) { printf ("Error for setting 'A' in base 62\n x="); - mpfr_out_str (stdout, 10, 0, x, GMP_RNDN); + mpfr_out_str (stdout, 10, 0, x, GMP_RNDN); putchar ('\n'); exit (1); } @@ -155,7 +155,7 @@ check_special (void) if (res != 0 || mpfr_cmp_ui (x, 36)) { printf ("Error for setting 'a' in base 62\n x="); - mpfr_out_str (stdout, 10, 0, x, GMP_RNDN); + mpfr_out_str (stdout, 10, 0, x, GMP_RNDN); putchar ('\n'); exit (1); } @@ -163,7 +163,7 @@ check_special (void) if (res != 0 || mpfr_cmp_ui (x, 35)) { printf ("Error for setting 'Z' in base 62\n x="); - mpfr_out_str (stdout, 10, 0, x, GMP_RNDN); + mpfr_out_str (stdout, 10, 0, x, GMP_RNDN); putchar ('\n'); exit (1); } @@ -171,7 +171,7 @@ check_special (void) if (res != 0 || mpfr_cmp_ui (x, 61)) { printf ("Error for setting 'z' in base 62\n x="); - mpfr_out_str (stdout, 10, 0, x, GMP_RNDN); + mpfr_out_str (stdout, 10, 0, x, GMP_RNDN); putchar ('\n'); exit (1); } @@ -196,9 +196,9 @@ int main() mpfr_t x; mp_prec_t p; mp_exp_t e; - + mpfr_init (x); - printf ("struct dymmy_test { \n" + printf ("struct dymmy_test { \n" " mp_prec_t prec; \n" " int base; \n" " const char *str; \n" @@ -223,12 +223,12 @@ int main() } #endif -static struct dymmy_test { - mp_prec_t prec; - int base; - const char *str; - const char *binstr; - } RefTable[] = { +static struct dymmy_test { + mp_prec_t prec; + int base; + const char *str; + const char *binstr; + } RefTable[] = { {39, 20, "1.1c9jeh9jg12d8iiggf26b8ce2cig24agai51d9@1445", "1.00111010111010001110110001101011101011e6245"}, @@ -528,7 +528,7 @@ static struct dymmy_test { "1.01010010101011010111011e-13092"}, {88, 18, "3.5ed0gad0bhhb7aa9ge2ad1dhcg6833f3e068936hghf23gd2aa69f13539f15hfce50aa64achfee49bfg7249g@-4058", -"1.001000010110011011000101100000101111101001100011101101001111110111000010010110010001100e-16920"} +"1.001000010110011011000101100000101111101001100011101101001111110111000010010110010001100e-16920"} }; @@ -582,9 +582,9 @@ check_parse (void) { mpfr_t x; char *s; - + mpfr_init (x); - + /* Check if it stops correctly */ mpfr_strtofr (x, "15*x", &s, 10, GMP_RNDN); if (mpfr_cmp_ui (x, 15) || strcmp (s, "*x")) @@ -654,7 +654,7 @@ check_parse (void) } - /* Check for space inside the mantissa */ + /* Check for space inside the mantissa */ mpfr_strtofr (x, "+0x4 2@17", &s, 0, GMP_RNDN); if (mpfr_cmp_ui (x, 4) || strcmp(s," 2@17")) { @@ -676,7 +676,7 @@ check_parse (void) printf ("Failed parsing '-0b0101P 17'\n S=%s\n X=", s); mpfr_out_str (stdout, 2, 0, x, GMP_RNDN); putchar ('\n'); exit (1); - } + } /* Check for Invalid exponent. */ mpfr_strtofr (x, " -0b0101PF17", &s, 0, GMP_RNDN); if (mpfr_cmp_si (x, -5) || strcmp(s,"PF17")) @@ -684,7 +684,7 @@ check_parse (void) printf ("Failed parsing '-0b0101PF17'\n S=%s\n X=", s); mpfr_out_str (stdout, 2, 0, x, GMP_RNDN); putchar ('\n'); exit (1); - } + } /* At least one digit in the mantissa. */ mpfr_strtofr (x, " .E10", &s, 0, GMP_RNDN); if (strcmp(s," .E10")) @@ -692,7 +692,7 @@ check_parse (void) printf ("Failed parsing ' .E10'\n S=%s\n X=", s); mpfr_out_str (stdout, 10, 0, x, GMP_RNDN); putchar ('\n'); exit (1); - } + } /* Check 2 '.': 2.3.4 */ mpfr_strtofr (x, "-1.2.3E4", &s, 0, GMP_RNDN); if (mpfr_cmp_str1 (x, "-1.2") || strcmp(s,".3E4")) @@ -700,7 +700,7 @@ check_parse (void) printf ("Failed parsing '-1.2.3E4'\n S=%s\n X=", s); mpfr_out_str (stdout, 10, 0, x, GMP_RNDN); putchar ('\n'); exit (1); - } + } /* Check for 0x */ mpfr_strtofr (x, " 0xG", &s, 0, GMP_RNDN); if (mpfr_cmp_ui (x, 0) || strcmp(s,"xG")) @@ -708,28 +708,28 @@ check_parse (void) printf ("Failed parsing ' 0xG'\n S=%s\n X=", s); mpfr_out_str (stdout, 16, 0, x, GMP_RNDN); putchar ('\n'); exit (1); - } + } mpfr_strtofr (x, " 0b2", &s, 0, GMP_RNDN); if (mpfr_cmp_ui (x, 0) || strcmp(s,"b2")) { printf ("Failed parsing ' 0b2'\n S=%s\n X=", s); mpfr_out_str (stdout, 2, 0, x, GMP_RNDN); putchar ('\n'); exit (1); - } + } mpfr_strtofr (x, "-0x.23@2Z33", &s, 0, GMP_RNDN); if (mpfr_cmp_si (x, -0x23) || strcmp(s,"Z33")) { printf ("Failed parsing '-0x.23@2Z33'\n S=%s\n X=", s); mpfr_out_str (stdout, 16, 0, x, GMP_RNDN); putchar ('\n'); exit (1); - } + } mpfr_strtofr (x, " 0x", &s, 0, GMP_RNDN); if (mpfr_cmp_ui (x, 0) || strcmp(s,"x")) { printf ("Failed parsing ' 0x'\n S=%s\n X=", s); mpfr_out_str (stdout, 16, 0, x, GMP_RNDN); putchar ('\n'); exit (1); - } + } mpfr_clear (x); } @@ -749,7 +749,7 @@ check_overflow (void) printf ("Check overflow failed (1) with:\n s=%s\n x=", s); mpfr_dump (x); exit (1); - } + } mpfr_strtofr (x, "123456789E9223372036854775807", &s, 0, GMP_RNDN); if (s[0] != 0 || !MPFR_IS_INF (x) || !MPFR_IS_POS (x) ) { @@ -773,21 +773,21 @@ check_overflow (void) printf ("Check overflow failed (4) with:\n s=%s\n x=", s); mpfr_dump (x); exit (1); - } + } mpfr_strtofr (x, "12E2147483645", &s, 0, GMP_RNDN); if (s[0] != 0 || !MPFR_IS_INF (x) || !MPFR_IS_POS (x)) { printf ("Check overflow failed (5) with:\n s=%s\n x=", s); mpfr_dump (x); exit (1); - } + } mpfr_strtofr (x, "0123456789ABCDEF@2147483640", &s, 16, GMP_RNDN); if (s[0] != 0 || !MPFR_IS_INF (x) || !MPFR_IS_POS (x)) { printf ("Check overflow failed (6) with:\n s=%s\n x=", s); mpfr_dump (x); exit (1); - } + } mpfr_strtofr (x, "0123456789ABCDEF@540000000", &s, 16, GMP_RNDN); if (s[0] != 0 || !MPFR_IS_INF (x) || !MPFR_IS_POS (x)) { @@ -803,7 +803,7 @@ check_overflow (void) printf ("Check underflow failed (1) with:\n s=%s\n x=", s); mpfr_dump (x); exit (1); - } + } mpfr_strtofr (x, "123456789E-9223372036854775807", &s, 0, GMP_RNDN); if (s[0] != 0 || !MPFR_IS_ZERO (x) || !MPFR_IS_POS (x) ) { @@ -846,4 +846,4 @@ check_retval (void) MPFR_ASSERTN (res < 0); mpfr_clear (x); -} +} diff --git a/tests/tsub_ui.c b/tests/tsub_ui.c index 55ea783dd..fdf52380e 100644 --- a/tests/tsub_ui.c +++ b/tests/tsub_ui.c @@ -134,7 +134,7 @@ main (int argc, char *argv[]) for (k=0; k<200; k++) check_two_sum (p); - check3 ("0.9999999999", 1, GMP_RNDN, + check3 ("0.9999999999", 1, GMP_RNDN, "-10000000827403709990903735160827636718750e-50"); test_generic_ui (2, 1000, 100); diff --git a/tests/ttan.c b/tests/ttan.c index ac393ba3e..7f09f668f 100644 --- a/tests/ttan.c +++ b/tests/ttan.c @@ -69,7 +69,7 @@ check_nans (void) MPFR_ASSERTN(mpfr_cmp (x, y) == 0); /* Compute ~Pi/2 to check overflow */ - /* TOO SLOW! Disable this test. + /* TOO SLOW! Disable this test. mpfr_set_prec (x, 20000); mpfr_const_pi (x, GMP_RNDD); mpfr_div_2ui (x, x, 1, GMP_RNDN); mpfr_set_prec (y, 24); diff --git a/tests/ttanh.c b/tests/ttanh.c index 98acc0964..38e19746f 100644 --- a/tests/ttanh.c +++ b/tests/ttanh.c @@ -86,7 +86,7 @@ special_overflow (void) exit (1); } MPFR_ASSERTN (!mpfr_overflow_p ()); - + set_emin (MPFR_EMIN_MIN); set_emax (MPFR_EMAX_MAX); diff --git a/tests/ttrunc.c b/tests/ttrunc.c index e34ef27bc..9a4b24ca3 100644 --- a/tests/ttrunc.c +++ b/tests/ttrunc.c @@ -41,7 +41,7 @@ main (void) if (mpfr_cmp_ui (y, 1)) { printf ("Error in mpfr_ceil for x=0.5: expected 1.0, got "); - mpfr_print_binary(y); + mpfr_print_binary(y); putchar('\n'); exit (1); } diff --git a/tests/tzeta.c b/tests/tzeta.c index dda59feaa..3d3083fd6 100644 --- a/tests/tzeta.c +++ b/tests/tzeta.c @@ -115,7 +115,7 @@ static const char *const val[] = { "-2.0", "0.0", "-1.0", "-0.000101010101010101010101010101010101010101010101010101010101010", "-0.9", "-0.000110011110011111010001010001100010111101001010100110001110110", - /* "-0.8", "-0.000111110011101010001011100011010010000001010011110100010001110", + /* "-0.8", "-0.000111110011101010001011100011010010000001010011110100010001110", "-0.7", "-0.00100101011011111100110011110011111010111111000110110100010110", "-0.6", "-0.00101100101100100100110111111000110010111010110010111000001100", "-0.5", "-0.00110101001110000000100000011001100100010000111100010001111100", @@ -33,7 +33,7 @@ MA 02110-1301, USA. */ int verbose; /* s->size: precision of both input and output - s->xp : Mantissa of first input + s->xp : Mantissa of first input s->yp : mantissa of second input */ #define SPEED_MPFR_FUNC(mean_fun) do { \ @@ -144,7 +144,7 @@ static double speed_mpfr_mul (struct speed_params *s) { /************************************************ * Common functions (inspired by GMP function) * ************************************************/ -static int +static int analyze_data (double *dat, int ndat) { double x, min_x; int j, min_j; @@ -170,7 +170,7 @@ analyze_data (double *dat, int ndat) { #define THRESHOLD_WINDOW 16 #define THRESHOLD_FINAL_WINDOW 128 -static double domeasure (mp_prec_t *threshold, +static double domeasure (mp_prec_t *threshold, double (*func) (struct speed_params *), mp_prec_t p) { @@ -192,14 +192,14 @@ static double domeasure (mp_prec_t *threshold, mpn_random (s.yp, size); *threshold = MPFR_PREC_MAX; t1 = speed_measure (func, &s); - if (t1 == -1.0) + if (t1 == -1.0) { fprintf (stderr, "Failed to measure function 1!\n"); abort (); } *threshold = /*MPFR_PREC_MIN*/0; t2 = speed_measure (func, &s); - if (t2 == -1.0) + if (t2 == -1.0) { fprintf (stderr, "Failed to measure function 2!\n"); abort (); @@ -215,16 +215,16 @@ static double domeasure (mp_prec_t *threshold, return d; } -/* Tune a function with a simple THRESHOLD +/* Tune a function with a simple THRESHOLD The function doesn't depend on another threshold. It assumes that it uses algo1 if p < THRESHOLD and algo2 otherwise. if algo2 is better for low prec, and algo1 better for high prec, the behaviour of this function is undefined. */ -static void -tune_simple_func (mp_prec_t *threshold, +static void +tune_simple_func (mp_prec_t *threshold, double (*func) (struct speed_params *), - mp_prec_t pstart) + mp_prec_t pstart) { double measure[THRESHOLD_FINAL_WINDOW+1]; double d; @@ -237,7 +237,7 @@ tune_simple_func (mp_prec_t *threshold, d = domeasure (threshold, func, pmin); if (d < 0.0) { if (verbose) - printf ("Oups: even for %lu, algo 2 seems to be faster!\n", + printf ("Oups: even for %lu, algo 2 seems to be faster!\n", (unsigned long) pmin); *threshold = MPFR_PREC_MIN; return; @@ -266,17 +266,17 @@ tune_simple_func (mp_prec_t *threshold, break; pmax += pmax/2; } - + /* The threshold is between pmin and pmax. Affine them */ try = 0; - while ((pmax-pmin) >= THRESHOLD_FINAL_WINDOW) + while ((pmax-pmin) >= THRESHOLD_FINAL_WINDOW) { pstep = MAX(MIN(BITS_PER_MP_LIMB/2,(pmax-pmin)/(2*THRESHOLD_WINDOW)),1); if (verbose) printf ("Pmin = %8lu Pmax = %8lu Pstep=%lu\n", pmin, pmax, pstep); p = (pmin + pmax) / 2; for (i = numpos = numneg = 0 ; i < THRESHOLD_WINDOW + 1 ; i++) { - measure[i] = domeasure (threshold, func, + measure[i] = domeasure (threshold, func, p+(i-THRESHOLD_WINDOW/2)*pstep); if (measure[i] > 0) numpos ++; @@ -295,9 +295,9 @@ tune_simple_func (mp_prec_t *threshold, if (verbose) printf ("Quick find: %lu\n", *threshold); return ; - } + } } - + /* Final tune... */ if (verbose) printf ("Finalizing in [%lu, %lu]... ", pmin, pmax); @@ -400,8 +400,8 @@ tune_mulder (FILE *f) * Tune all the threshold of MPFR * * Warning: tune the function in their dependent order!* *******************************************************/ -static void -all (const char *filename) +static void +all (const char *filename) { FILE *f; time_t start_time, end_time; @@ -412,10 +412,10 @@ all (const char *filename) fprintf (stderr, "Can't open file '%s' for writing.\n", filename); abort (); } - - speed_time_init (); + + speed_time_init (); if (verbose) { - printf ("Using: %s\n", speed_time_string); + printf ("Using: %s\n", speed_time_string); printf ("speed_precision %d", speed_precision); if (speed_unittime == 1.0) printf (", speed_unittime 1 cycle"); @@ -456,26 +456,26 @@ all (const char *filename) /* Tune mpfr_mul (Threshold is limb size, but it doesn't matter too much */ if (verbose) printf ("Tuning mpfr_mul...\n"); - tune_simple_func (&mpfr_mul_threshold, speed_mpfr_mul, - 2*BITS_PER_MP_LIMB+1); - fprintf (f, "#define MPFR_MUL_THRESHOLD %lu\n", + tune_simple_func (&mpfr_mul_threshold, speed_mpfr_mul, + 2*BITS_PER_MP_LIMB+1); + fprintf (f, "#define MPFR_MUL_THRESHOLD %lu\n", (unsigned long) (mpfr_mul_threshold-1)/BITS_PER_MP_LIMB+1); /* Tune mpfr_exp_2 */ if (verbose) printf ("Tuning mpfr_exp_2...\n"); tune_simple_func (&mpfr_exp_2_threshold, speed_mpfr_exp_2, - MPFR_PREC_MIN); + MPFR_PREC_MIN); mpfr_exp_2_threshold = MAX (BITS_PER_MP_LIMB, mpfr_exp_2_threshold); - fprintf (f, "#define MPFR_EXP_2_THRESHOLD %lu\n", + fprintf (f, "#define MPFR_EXP_2_THRESHOLD %lu\n", (unsigned long) mpfr_exp_2_threshold); /* Tune mpfr_exp */ if (verbose) printf ("Tuning mpfr_exp...\n"); tune_simple_func (&mpfr_exp_threshold, speed_mpfr_exp, - MPFR_PREC_MIN+3*BITS_PER_MP_LIMB); - fprintf (f, "#define MPFR_EXP_THRESHOLD %lu\n", + MPFR_PREC_MIN+3*BITS_PER_MP_LIMB); + fprintf (f, "#define MPFR_EXP_THRESHOLD %lu\n", (unsigned long) mpfr_exp_threshold); /* End of tuning */ diff --git a/uceil_log2.c b/uceil_log2.c index cd8c50e6e..e34f92f77 100644 --- a/uceil_log2.c +++ b/uceil_log2.c @@ -54,7 +54,7 @@ __gmpfr_ceil_log2 (double d) { exp = 1; for( m= 1.0 ; m >= d ; m *= (1.0/2.0) ) - exp--; + exp--; } #endif return exp; diff --git a/ufloor_log2.c b/ufloor_log2.c index 4c085f4ad..107999d8e 100644 --- a/ufloor_log2.c +++ b/ufloor_log2.c @@ -30,7 +30,7 @@ __gmpfr_floor_log2 (double d) x.d = d; return (long) x.s.exp - 1023; -#else +#else long exp; double m; @@ -45,7 +45,7 @@ __gmpfr_floor_log2 (double d) { exp = 0; for( m= 1.0 ; m > d ; m *= (1.0/2.0) ) - exp--; + exp--; } return exp; #endif diff --git a/ui_pow_ui.c b/ui_pow_ui.c index ea1be6b89..bb1479550 100644 --- a/ui_pow_ui.c +++ b/ui_pow_ui.c @@ -1,6 +1,6 @@ /* mpfr_ui_pow_ui -- compute the power beetween two machine integer -Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. diff --git a/urandomb.c b/urandomb.c index 3addee0dc..16cf19d73 100644 --- a/urandomb.c +++ b/urandomb.c @@ -61,7 +61,7 @@ mpfr_urandomb (mpfr_ptr rop, gmp_randstate_t rstate) if (MPFR_LIKELY(nlimbs != 0)) /* otherwise value is zero */ { - count_leading_zeros (cnt, rp[nlimbs - 1]); + count_leading_zeros (cnt, rp[nlimbs - 1]); if (mpfr_set_exp (rop, exp - cnt)) { MPFR_SET_NAN (rop); |