diff options
102 files changed, 487 insertions, 679 deletions
@@ -35,7 +35,6 @@ mpfr_asin (mpfr_ptr asin, mpfr_srcptr x, mp_rnd_t rnd_mode) mpfr_t tmp; int Prec; int prec_asin; - int good = 0; int realprec; int estimated_delta; int compared; @@ -96,33 +95,34 @@ mpfr_asin (mpfr_ptr asin, mpfr_srcptr x, mp_rnd_t rnd_mode) supplement = 2 - MPFR_GET_EXP (xp); realprec = prec_asin + 10; - while (!good) + mpfr_init (tmp); + mpfr_init (arcs); + + while (1) { estimated_delta = 1 + supplement; Prec = realprec+estimated_delta; - /* Initialisation */ - mpfr_init2 (tmp, Prec); - mpfr_init2 (arcs, Prec); + /* Fix prec */ + mpfr_set_prec (tmp, Prec); + mpfr_set_prec (arcs, Prec); mpfr_mul (tmp, x, x, GMP_RNDN); mpfr_ui_sub (tmp, 1, tmp, GMP_RNDN); mpfr_sqrt (tmp, tmp, GMP_RNDN); mpfr_div (tmp, x, tmp, GMP_RNDN); mpfr_atan (arcs, tmp, GMP_RNDN); - if (mpfr_can_round (arcs, realprec, GMP_RNDN, GMP_RNDZ, + if (!mpfr_can_round (arcs, realprec, GMP_RNDN, GMP_RNDZ, MPFR_PREC(asin) + (rnd_mode == GMP_RNDN))) - { - inexact = mpfr_set (asin, arcs, rnd_mode); - good = 1; - } + realprec += __gmpfr_ceil_log2 ((double) realprec); else - { - realprec += __gmpfr_ceil_log2 ((double) realprec); - } - mpfr_clear (tmp); - mpfr_clear (arcs); + break; } + inexact = mpfr_set (asin, arcs, rnd_mode); + + mpfr_clear (tmp); + mpfr_clear (arcs); + mpfr_clear (xp); return inexact; @@ -72,7 +72,6 @@ mpfr_atan (mpfr_ptr arctangent, mpfr_srcptr x, mp_rnd_t rnd_mode) int Prec; int prec_x; int prec_arctan; - int good = 0; int realprec; int estimated_delta; /* calculation of the floor */ @@ -150,28 +149,40 @@ mpfr_atan (mpfr_ptr arctangent, mpfr_srcptr x, mp_rnd_t rnd_mode) if (logn < 2) logn = 2; realprec = prec_arctan + __gmpfr_ceil_log2((double) prec_arctan) + 4; + mpz_init (ukz); mpz_init (square); - while (!good) + /* Initialisation */ + mpfr_init(sk); + mpfr_init(ukf); + mpfr_init(t_arctan); + mpfr_init(tmp_arctan); + mpfr_init(tmp); + mpfr_init(tmp2); + mpfr_init(Ak); + mpfr_init(arctgt); + mpfr_init(Pisur2); + + while (1) { N0 = __gmpfr_ceil_log2((double) realprec + supplement + CST); estimated_delta = 1 + supplement + __gmpfr_ceil_log2((double) (3*N0-2)); Prec = realprec+estimated_delta; /* Initialisation */ - mpfr_init2(sk,Prec); - mpfr_init2(ukf, Prec); - mpfr_init2(t_arctan, Prec); - mpfr_init2(tmp_arctan, Prec); - mpfr_init2(tmp, Prec); - mpfr_init2(tmp2, Prec); - mpfr_init2(Ak, Prec); - mpfr_init2(arctgt, Prec); + mpfr_set_prec (sk,Prec); + mpfr_set_prec (ukf, Prec); + mpfr_set_prec (t_arctan, Prec); + mpfr_set_prec (tmp_arctan, Prec); + mpfr_set_prec (tmp, Prec); + mpfr_set_prec (tmp2, Prec); + mpfr_set_prec (Ak, Prec); + mpfr_set_prec (arctgt, Prec); if (comparaison > 0) { - mpfr_init2(Pisur2, Prec); + mpfr_set_prec (Pisur2, Prec); mpfr_const_pi(Pisur2, GMP_RNDN); mpfr_div_2ui(Pisur2, Pisur2, 1, GMP_RNDN); mpfr_ui_div(sk, 1, xp, GMP_RNDN); @@ -219,30 +230,25 @@ mpfr_atan (mpfr_ptr arctangent, mpfr_srcptr x, mp_rnd_t rnd_mode) mpfr_set(arctgt, tmp_arctan, GMP_RNDN); MPFR_SET_POS(arctgt); - if (mpfr_can_round (arctgt, realprec, GMP_RNDN, GMP_RNDZ, + if (!mpfr_can_round (arctgt, realprec, GMP_RNDN, GMP_RNDZ, MPFR_PREC (arctangent) + (rnd_mode == GMP_RNDN))) - { - inexact = mpfr_set (arctangent, arctgt, rnd_mode); - good = 1; - realprec += 1; - } + realprec += __gmpfr_ceil_log2 ((double) realprec); else - { - realprec += __gmpfr_ceil_log2 ((double) realprec); - } + break; + } - mpfr_clear(sk); - mpfr_clear(ukf); - mpfr_clear(t_arctan); - mpfr_clear(tmp_arctan); - mpfr_clear(tmp); - mpfr_clear(tmp2); - mpfr_clear(Ak); - mpfr_clear(arctgt); + inexact = mpfr_set (arctangent, arctgt, rnd_mode); - if (comparaison > 0) - mpfr_clear(Pisur2); - } + mpfr_clear(sk); + mpfr_clear(ukf); + mpfr_clear(t_arctan); + mpfr_clear(tmp_arctan); + mpfr_clear(tmp); + mpfr_clear(tmp2); + mpfr_clear(Ak); + mpfr_clear(arctgt); + + mpfr_clear(Pisur2); mpfr_clear(xp); mpz_clear(ukz); @@ -115,7 +115,7 @@ mpfr_cbrt (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) sh = mpz_sizeinbase (m, 2) - n; if (sh > 0) /* we have to flush to 0 the last sh bits from m */ { - inexact = inexact || (mpz_scan1 (m, 0) < sh); + inexact = inexact || ((mp_exp_t) mpz_scan1 (m, 0) < sh); mpz_div_2exp (m, m, sh); e += 3 * sh; } @@ -35,11 +35,9 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode) mp_size_t asize, bsize, qsize, rsize; mp_exp_t qexp; - mp_rnd_t rnd_mode1, rnd_mode2; - mp_size_t err, k; mp_limb_t near; - int inex, sh, can_round = 0, can_round2 = 0, sign_quotient; + int inex, sh, can_round = 0, sign_quotient; unsigned int cc = 0, rw; TMP_DECL (marker); @@ -101,9 +99,6 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode) MPFR_ASSERTN(0); } MPFR_CLEAR_FLAGS(q); - - sign_quotient = MPFR_MULT_SIGN( MPFR_SIGN(u) , MPFR_SIGN(v) ); - MPFR_SET_SIGN(q, sign_quotient); /************************************************************************** * * @@ -111,8 +106,10 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode) * * **************************************************************************/ + sign_quotient = MPFR_MULT_SIGN( MPFR_SIGN(u) , MPFR_SIGN(v) ); up = MPFR_MANT(u); vp = MPFR_MANT(v); + MPFR_SET_SIGN(q, sign_quotient); TMP_MARK (marker); usize = MPFR_LIMB_SIZE(u); @@ -142,7 +139,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode) asize = bsize + qsize; ap = (mp_ptr) TMP_ALLOC(asize * BYTES_PER_MP_LIMB); - if (asize > usize) + if (MPFR_LIKELY(asize > usize)) { MPN_COPY(ap + asize - usize, up, usize); MPN_ZERO(ap, asize - usize); @@ -160,14 +157,19 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode) /* Estimate number of correct bits. */ err = qsize * BITS_PER_MP_LIMB; - if (bsize < vsize) err -= 2; else if (asize < usize) err --; + if (bsize < vsize) + err -= 2; + else if (asize < usize) + err --; /* We want to check if rounding is possible, but without normalizing because we might have to divide again if rounding is impossible, or if the result might be exact. We have however to mimic normalization */ - if (qp[qsize] != 0) { sh = -1; } - else { count_leading_zeros(sh, qp[qsize - 1]); } + if (qp[qsize] != 0) + { sh = -1; } + else + { count_leading_zeros(sh, qp[qsize - 1]); } /* To detect asap if the result is inexact, so as to avoid doing the @@ -186,46 +188,51 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode) if (asize < usize || bsize < vsize) { - if (rnd_mode == GMP_RNDN) - { - rnd_mode1 = GMP_RNDZ; - near = 1; - } - else - { - rnd_mode1 = rnd_mode; - near = 0; - } - - sh += near; - can_round = mpfr_can_round_raw(qp, qsize + 1, sign_quotient, err + sh + - BITS_PER_MP_LIMB, GMP_RNDN, rnd_mode1, - MPFR_PREC(q) + sh + BITS_PER_MP_LIMB); - - switch (rnd_mode1) - { - case GMP_RNDU : rnd_mode2 = GMP_RNDD; break; - case GMP_RNDD : rnd_mode2 = GMP_RNDU; break; - case GMP_RNDZ : - rnd_mode2 = MPFR_IS_POS_SIGN(sign_quotient) ? GMP_RNDU : GMP_RNDD; - break; - default: - rnd_mode2 = GMP_RNDZ; - break; - } - - can_round2 = mpfr_can_round_raw(qp, qsize + 1, sign_quotient, err + sh + - BITS_PER_MP_LIMB, GMP_RNDN, rnd_mode2, - MPFR_PREC(q) + sh + BITS_PER_MP_LIMB); - - sh -= near; + { + mp_rnd_t rnd_mode1, rnd_mode2; + mp_exp_t tmp_exp; + mp_prec_t tmp_prec; + + if (MPFR_LIKELY(rnd_mode == GMP_RNDN)) + { + rnd_mode1 = GMP_RNDZ; + rnd_mode2 = MPFR_IS_POS_SIGN(sign_quotient) ? GMP_RNDU : GMP_RNDD; + sh++; + } + else + { + rnd_mode1 = rnd_mode; + switch (rnd_mode) + { + case GMP_RNDU: + rnd_mode2 = GMP_RNDD; break; + case GMP_RNDD: + rnd_mode2 = GMP_RNDU; break; + default: + rnd_mode2 = MPFR_IS_POS_SIGN(sign_quotient) ? + GMP_RNDU : GMP_RNDD; + break; + } + } + + tmp_exp = err + sh + BITS_PER_MP_LIMB; + tmp_prec = MPFR_PREC(q) + sh + BITS_PER_MP_LIMB; + + can_round = + mpfr_can_round_raw(qp, qsize + 1, sign_quotient, tmp_exp, + GMP_RNDN, rnd_mode1, tmp_prec) + & mpfr_can_round_raw(qp, qsize + 1, sign_quotient, tmp_exp, + GMP_RNDN, rnd_mode2, tmp_prec); + + sh -= (rnd_mode == GMP_RNDN); + } - /* If either can_round or can_round2 is 0, either we cannot round or + /* If can_round is 0, either we cannot round or the result might be exact. If asize >= usize and bsize >= vsize, we can just check this by looking at the remainder. Otherwise, we have to correct our first approximation. */ - if (!can_round || !can_round2) + if (MPFR_UNLIKELY(!can_round)) { int b = 0; mp_ptr rem, rem2; @@ -374,7 +381,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode) except when rounding to nearest (the nasty case of even rounding again). */ - if (!can_round || !can_round2) /* Lazy case. */ + if (MPFR_UNLIKELY(!can_round)) /* Lazy case. */ { if (inex == 0) { @@ -383,7 +390,8 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode) /* If a bit has been shifted out during normalization, then the remainder is nonzero. */ if (near == 0) - while (k >= 0) { if (rp[k]) break; k--; } + while ((k >= 0) && !(rp[k])) + k--; if (k >= 0) /* Remainder is nonzero. */ { @@ -408,12 +416,8 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode) /* If a bit has been shifted out during normalization, hence the remainder is nonzero. */ if (near == 0) - while (k >= 0) - { - if (rp[k]) - break; - k--; - } + while ((k >= 0) && !(rp[k])) + k--; if (k >= 0) /* In fact the quotient is larger than expected */ { @@ -427,14 +431,9 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode) /* Final modification due to rounding */ if (cc) { - sh = MPFR_PREC(q) & (BITS_PER_MP_LIMB - 1); - if (sh) - cc = mpn_add_1 (qp, qp, qsize, - MP_LIMB_T_ONE << (BITS_PER_MP_LIMB - sh)); - else - cc = mpn_add_1 (qp, qp, qsize, MP_LIMB_T_ONE); - - if (cc) + MPFR_UNSIGNED_MINUS_MODULO(sh, MPFR_PREC(q)); + cc = mpn_add_1 (qp, qp, qsize, MPFR_LIMB_ONE << sh); + if (MPFR_UNLIKELY(cc)) { mpn_rshift (qp, qp, qsize, 1); qp[qsize-1] |= MPFR_LIMB_HIGHBIT; @@ -446,8 +445,8 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode) MPN_COPY(MPFR_MANT(q), qp, qsize); TMP_FREE (marker); - MPFR_MANT(q)[0] &= ~((MP_LIMB_T_ONE << rw) - MP_LIMB_T_ONE); + MPFR_MANT(q)[0] &= ~((MPFR_LIMB_ONE << rw) - MPFR_LIMB_ONE); MPFR_SET_EXP (q, qexp); - MPFR_RET(inex); + MPFR_RET(inex); } @@ -20,6 +20,7 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include <limits.h> #include "gmp.h" #include "gmp-impl.h" #include "mpfr.h" @@ -50,7 +50,6 @@ mpfr_gamma (mpfr_ptr gamma, mpfr_srcptr x, mp_rnd_t rnd_mode) mp_prec_t Prec; mp_prec_t prec_gamma; mp_prec_t prec_nec; - int good = 0; double C; mp_prec_t A, N, estimated_cancel; mp_prec_t realprec; @@ -101,8 +100,14 @@ mpfr_gamma (mpfr_ptr gamma, mpfr_srcptr x, mp_rnd_t rnd_mode) realprec = prec_gamma + 10; mpfr_init2 (xp, 2); - - while (!good) + /* Initialisation */ + mpfr_init (tmp); + mpfr_init (tmp2); + mpfr_init (the_pi); + mpfr_init (product); + mpfr_init (GammaTrial); + + while (1) { /* Precision stuff */ prec_nec = compared < 0 ? @@ -132,12 +137,12 @@ mpfr_gamma (mpfr_ptr gamma, mpfr_srcptr x, mp_rnd_t rnd_mode) mpfr_sub_ui (xp, x, 1, GMP_RNDN); } - /* Initialisation */ - mpfr_init2(tmp, Prec); - mpfr_init2(tmp2, Prec); - mpfr_init2(the_pi, Prec); - mpfr_init2(product, Prec); - mpfr_init2(GammaTrial, Prec); + /* Set prec */ + mpfr_set_prec (tmp, Prec); + mpfr_set_prec (tmp2, Prec); + mpfr_set_prec (the_pi, Prec); + mpfr_set_prec (product, Prec); + mpfr_set_prec (GammaTrial, Prec); mpfr_set_ui(GammaTrial, 0, GMP_RNDN); sign = 1; @@ -196,25 +201,24 @@ mpfr_gamma (mpfr_ptr gamma, mpfr_srcptr x, mp_rnd_t rnd_mode) mpfr_out_str (stdout, 10, 0, GammaTrial, GMP_RNDD); printf ("\n"); #endif - if (mpfr_can_round (GammaTrial, realprec, GMP_RNDD, GMP_RNDZ, + if (!mpfr_can_round (GammaTrial, realprec, GMP_RNDD, GMP_RNDZ, MPFR_PREC(gamma) + (rnd_mode == GMP_RNDN))) { - inex = mpfr_set (gamma, GammaTrial, rnd_mode); - good = 1; - } - else - { realprec += __gmpfr_ceil_log2 ((double) realprec); #ifdef DEBUG printf("RETRY\n"); #endif } - mpfr_clear(tmp); - mpfr_clear(tmp2); - mpfr_clear(the_pi); - mpfr_clear(product); - mpfr_clear(GammaTrial); + else + break; } + inex = mpfr_set (gamma, GammaTrial, rnd_mode); + + mpfr_clear(tmp); + mpfr_clear(tmp2); + mpfr_clear(the_pi); + mpfr_clear(product); + mpfr_clear(GammaTrial); mpfr_clear (xp); @@ -51,19 +51,28 @@ 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 = { { 0, 0, 0, 0, 0, 0, 0xF0, 0x7F } }; -static const struct dbl_bytes dbl_infm = { { 0, 0, 0, 0, 0, 0, 0xF0, 0xFF } }; -static const struct dbl_bytes dbl_nan = { { 0, 0, 0, 0, 0, 0, 0xF8, 0x7F } }; +static const struct dbl_bytes dbl_infp = + { { 0, 0, 0, 0, 0, 0, 0xF0, 0x7F }, 0.0 }; +static const struct dbl_bytes dbl_infm = + { { 0, 0, 0, 0, 0, 0, 0xF0, 0xFF }, 0.0 }; +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 = { { 0, 0, 0xF0, 0x7F, 0, 0, 0, 0 } }; -static const struct dbl_bytes dbl_infm = { { 0, 0, 0xF0, 0xFF, 0, 0, 0, 0 } }; -static const struct dbl_bytes dbl_nan = { { 0, 0, 0xF8, 0x7F, 0, 0, 0, 0 } }; +static const struct dbl_bytes dbl_infp = + { { 0, 0, 0xF0, 0x7F, 0, 0, 0, 0 }, 0.0 }; +static const struct dbl_bytes dbl_infm = + { { 0, 0, 0xF0, 0xFF, 0, 0, 0, 0 }, 0.0 }; +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 = { { 0x7F, 0xF0, 0, 0, 0, 0, 0, 0 } }; -static const struct dbl_bytes dbl_infm = { { 0xFF, 0xF0, 0, 0, 0, 0, 0, 0 } }; -static const struct dbl_bytes dbl_nan = { { 0x7F, 0xF8, 0, 0, 0, 0, 0, 0 } }; +static const struct dbl_bytes dbl_infp = + { { 0x7F, 0xF0, 0, 0, 0, 0, 0, 0 }, 0.0 }; +static const struct dbl_bytes dbl_infm = + { { 0xFF, 0xF0, 0, 0, 0, 0, 0, 0 }, 0.0 }; +static const struct dbl_bytes dbl_nan = + { { 0x7F, 0xF8, 0, 0, 0, 0, 0, 0 }, 0.0 }; #endif #else /* _GMP_IEEE_FLOATS */ diff --git a/mpfr-impl.h b/mpfr-impl.h index 9d0828d12..7f70c933b 100644 --- a/mpfr-impl.h +++ b/mpfr-impl.h @@ -22,6 +22,9 @@ MA 02111-1307, USA. */ #ifndef __MPFR_IMPL_H__ #define __MPFR_IMPL_H__ +/* Auto-include limits.h (Before gmp-impl.h) */ +#include <limits.h> + /* Auto include local gmp.h if not included */ #ifndef __GMP_H__ #include "gmp.h" @@ -37,9 +40,6 @@ MA 02111-1307, USA. */ #include "mpfr.h" #endif -/* Auto-include limits.h */ -#include <limits.h> - #ifndef HAVE_STRCASECMP #define strcasecmp mpfr_strcasecmp #endif @@ -98,15 +98,14 @@ typedef unsigned long int mpfr_exp_unsigned_t; # define mp_exp_unsigned_t mpfr_exp_unsigned_t #endif +#define MPFR_LIMB_ONE ((mp_limb_t) 1) #ifndef MP_LIMB_T_ONE -# define MP_LIMB_T_ONE ((mp_limb_t) 1) +# define MP_LIMB_T_ONE MPFR_LIMB_ONE #endif -#define MPFR_LIMB_ONE ((mp_limb_t) 1) #define MPFR_INTPREC_MAX (ULONG_MAX & ~(unsigned long) (BITS_PER_MP_LIMB - 1)) -/* Redefine MPN_COPY if compilation for small vars - FIXME: Usefull ?*/ +/* Redefine MPN_COPY if compilation for small vars FIXME: Usefull ?*/ #ifdef SMALL #undef MPN_COPY #define MPN_COPY(dest, src, n) \ @@ -296,7 +295,7 @@ long double __gmpfr_longdouble_volatile _MPFR_PROTO ((long double)) ATTRIBUTE_CO /* We want to test this : * (rnd == GMP_RNDU && test) || (rnd == RNDD && !test) - * This macro does this test faster*/ + * It transforms RNDU or RNDD to Away or Zero according to the sign */ #define MPFR_IS_RNDUTEST_OR_RNDDNOTTEST(rnd, test) \ (((rnd) + (test)) == GMP_RNDD) @@ -463,8 +462,8 @@ void mpfr_restore_emin_emax _MPFR_PROTO ((void)); int mpfr_add1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t)); int mpfr_sub1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t)); int mpfr_sub1sp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t)); -int mpfr_can_round_raw _MPFR_PROTO ((mp_limb_t *, mp_size_t, int, mp_exp_t, - mp_rnd_t, mp_rnd_t, mp_prec_t)); +int mpfr_can_round_raw _MPFR_PROTO ((mp_limb_t *, mp_size_t, int, + mp_exp_t, mp_rnd_t, mp_rnd_t, mp_prec_t)); double mpfr_get_d3 _MPFR_PROTO ((mpfr_srcptr, mp_exp_t, mp_rnd_t)); int mpfr_cmp2 _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr, mp_prec_t *)); @@ -486,8 +485,8 @@ long mpn_exp _MPFR_PROTO ((mp_limb_t *, mp_exp_t *, int, mp_exp_t, size_t)); void mpfr_print_binary _MPFR_PROTO ((mpfr_srcptr)); -void mpfr_print_mant_binary _MPFR_PROTO ((const char *, const mp_limb_t *, - mp_prec_t)); +void mpfr_print_mant_binary _MPFR_PROTO ((__gmp_const char *, + __gmp_const mp_limb_t *, mp_prec_t)); void mpfr_set_str_binary _MPFR_PROTO ((mpfr_ptr, __gmp_const char *)); int mpfr_round_raw _MPFR_PROTO ((mp_limb_t *, mp_limb_t *, @@ -500,7 +499,7 @@ int mpfr_round_raw_4 _MPFR_PROTO ((mp_limb_t *, mp_limb_t *, mp_prec_t, int, mp_prec_t, mp_rnd_t)); #define mpfr_round_raw2(xp, xn, neg, r, prec) \ - mpfr_round_raw_2(0, (xp), (xn) * BITS_PER_MP_LIMB, (neg), (prec), (r) ) + mpfr_round_raw_2((mp_limb_t*)0,(xp),(xn)*BITS_PER_MP_LIMB,(neg),(prec),(r)) int mpfr_check _MPFR_PROTO ((mpfr_srcptr)); int mpfr_sub1sp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t)); diff --git a/mpfr-test.h b/mpfr-test.h index cb4e97378..91c7e4219 100644 --- a/mpfr-test.h +++ b/mpfr-test.h @@ -19,10 +19,7 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <stdlib.h> -#include <limits.h> -#include <float.h> -#include <math.h> +#include "mpfr-impl.h" #if HAVE_CONFIG_H #include "config.h" diff --git a/round_prec.c b/round_prec.c index ca14a6eaf..15fcc3c52 100644 --- a/round_prec.c +++ b/round_prec.c @@ -138,8 +138,7 @@ mpfr_can_round_raw (mp_limb_t *bp, mp_size_t bn, int neg, mp_exp_t err0, mp_limb_t *tmp; TMP_DECL(marker); - /* FIXME: likely or not ? To check... How?*/ - if (err0 < 0 || (mp_exp_unsigned_t) err0 <= prec) + if (MPFR_UNLIKELY(err0 < 0 || (mp_exp_unsigned_t) err0 <= prec)) return 0; /* can't round */ if (prec > (mp_prec_t) bn * BITS_PER_MP_LIMB) @@ -183,31 +182,22 @@ mpfr_can_round_raw (mp_limb_t *bp, mp_size_t bn, int neg, mp_exp_t err0, MPFR_ASSERTD (k > 0); + /* Transform RNDD and RNDU to Zero / Away */ + MPFR_ASSERTD((neg == 0) || (neg ==1)); + if (MPFR_IS_RNDUTEST_OR_RNDDNOTTEST(rnd1, neg)) + rnd1 = GMP_RNDZ; + switch (rnd1) { - case GMP_RNDD: - if (neg) - goto round_rndu; - else - goto round_rndz; - break; - case GMP_RNDU: - if (neg) - goto round_rndz; - round_rndu: - cc = (bp[bn - 1] >> s1) & 1; - cc ^= mpfr_round_raw2(bp, bn, neg, rnd2, prec); - /* now round b +/- 2^(MPFR_EXP(b)-err) */ - cc2 = mpn_sub_1 (tmp + bn - k, bp + bn - k, k, MP_LIMB_T_ONE << s); - break; case GMP_RNDZ: - round_rndz: + /* Round to Zero */ cc = (bp[bn - 1] >> s1) & 1; cc ^= mpfr_round_raw2(bp, bn, neg, rnd2, prec); /* now round b +/- 2^(MPFR_EXP(b)-err) */ cc2 = mpn_add_1 (tmp + bn - k, bp + bn - k, k, MP_LIMB_T_ONE << s); break; case GMP_RNDN: + /* Round to nearest */ /* first round b+2^(MPFR_EXP(b)-err) */ cc = mpn_add_1 (tmp + bn - k, bp + bn - k, k, MP_LIMB_T_ONE << s); cc = (tmp[bn - 1] >> s1) & 1; /* gives 0 when cc=1 */ @@ -215,6 +205,13 @@ mpfr_can_round_raw (mp_limb_t *bp, mp_size_t bn, int neg, mp_exp_t err0, /* now round b-2^(MPFR_EXP(b)-err) */ cc2 = mpn_sub_1 (tmp + bn - k, bp + bn - k, k, MP_LIMB_T_ONE << s); break; + default: + /* Round away */ + cc = (bp[bn - 1] >> s1) & 1; + cc ^= mpfr_round_raw2(bp, bn, neg, rnd2, prec); + /* now round b +/- 2^(MPFR_EXP(b)-err) */ + cc2 = mpn_sub_1 (tmp + bn - k, bp + bn - k, k, MP_LIMB_T_ONE << s); + break; } if (cc2 && cc) diff --git a/round_raw_generic.c b/round_raw_generic.c index 9c966b63b..a93f4d364 100644 --- a/round_raw_generic.c +++ b/round_raw_generic.c @@ -91,7 +91,7 @@ mpfr_round_raw_generic(mp_limb_t *yp, mp_limb_t *xp, mp_prec_t xprec, return 0; } - /* Rounding is necessary */ + /* Transform RNDD & RNDU to RND Away */ if (MPFR_IS_RNDUTEST_OR_RNDDNOTTEST(rnd_mode, neg)) rnd_mode = GMP_RNDZ; @@ -190,7 +190,7 @@ mpfr_round_raw_generic(mp_limb_t *yp, mp_limb_t *xp, mp_prec_t xprec, } else { - /* rnd_mode != GMP_RNDZ && rnd_mode != GMP_RNDN */ + /* rnd_mode = Away */ while (MPFR_UNLIKELY(sb == 0) && k > 0) sb = xp[--k]; if (sb == 0) @@ -39,7 +39,7 @@ static const struct { } ldbl_max_struct = { { '\377','\377','\377','\377', '\377','\377','\377','\377', - '\376','\177' } + '\376','\177' }, 0.0 }; #define MPFR_LDBL_MAX (* (const long double *) ldbl_max_struct.bytes) #else @@ -68,7 +68,7 @@ mpfr_set_ui (mpfr_ptr x, unsigned long i, mp_rnd_t rnd_mode) if (MPFR_UNLIKELY(carry)) { /* nbits is the current exponent */ - if (MPFR_UNLIKELY(nbits == __gmpfr_emax)) + if (MPFR_UNLIKELY((mp_exp_t) nbits == __gmpfr_emax)) return mpfr_set_overflow(x, rnd_mode, 1); MPFR_SET_EXP (x, nbits + 1); @@ -165,176 +165,179 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) if (MPFR_IS_RNDUTEST_OR_RNDDNOTTEST(rnd_mode, MPFR_IS_NEG(a))) rnd_mode = GMP_RNDZ; - if (d == 0) + if (d <=1) { - /* <-- b --> - <-- c --> : exact sub */ - ap = MPFR_MANT(a); - mpn_sub_n (ap, MPFR_MANT(b), MPFR_MANT(c), n); - /* Normalize */ - ExactNormalize: - limb = ap[n-1]; - if (limb) + if (d == 0) { - /* First limb is not zero. */ - count_leading_zeros(cnt, limb); - if (MPFR_LIKELY(cnt)) + /* <-- b --> + <-- c --> : exact sub */ + ap = MPFR_MANT(a); + mpn_sub_n (ap, MPFR_MANT(b), MPFR_MANT(c), n); + /* Normalize */ + ExactNormalize: + limb = ap[n-1]; + if (limb) { - mpn_lshift(ap, ap, n, cnt); /* Normalize number */ - bx -= cnt; /* Update final expo */ + /* First limb is not zero. */ + count_leading_zeros(cnt, limb); + if (MPFR_LIKELY(cnt)) + { + mpn_lshift(ap, ap, n, cnt); /* Normalize number */ + bx -= cnt; /* Update final expo */ + } + sh = (-p % BITS_PER_MP_LIMB); + if (MPFR_LIKELY(sh)) + ap[0] &= ~((MPFR_LIMB_ONE << sh) - MPFR_LIMB_ONE); } - sh = (-p % BITS_PER_MP_LIMB); - if (MPFR_LIKELY(sh)) - ap[0] &= ~((MPFR_LIMB_ONE << sh) - MPFR_LIMB_ONE); - } - else - { - /* First limb is zero */ - mp_size_t k = n-1, len; - /* Find the first limb not equal to zero. - FIXME: It is assume it exists (since |b| > |c| and same prec)*/ - do { - MPFR_ASSERTD( k > 0 ); - limb = ap[--k]; - } while (limb == 0); - MPFR_ASSERTD(limb != 0); - count_leading_zeros(cnt, limb); - k++; - len = n - k; /* Number of last limb */ - MPFR_ASSERTD(k >= 0); - mpn_lshift(ap+len, ap, k, cnt); /* Normalize the High Limb*/ - MPN_ZERO(ap, len); /* Zeroing the last limbs */ - bx -= cnt + len*BITS_PER_MP_LIMB; /* Update Expo */ - sh = (-p % BITS_PER_MP_LIMB); - if (MPFR_LIKELY(sh)) - ap[len] &= ~((MPFR_LIMB_ONE << sh) - MPFR_LIMB_ONE); - } - /* Check expo underflow */ - if (MPFR_UNLIKELY(bx < __gmpfr_emin)) - { + else + { + /* First limb is zero */ + mp_size_t k = n-1, len; + /* Find the first limb not equal to zero. + FIXME:It is assume it exists (since |b| > |c| and same prec)*/ + do { + MPFR_ASSERTD( k > 0 ); + limb = ap[--k]; + } while (limb == 0); + MPFR_ASSERTD(limb != 0); + count_leading_zeros(cnt, limb); + k++; + len = n - k; /* Number of last limb */ + MPFR_ASSERTD(k >= 0); + mpn_lshift(ap+len, ap, k, cnt); /* Normalize the High Limb*/ + MPN_ZERO(ap, len); /* Zeroing the last limbs */ + bx -= cnt + len*BITS_PER_MP_LIMB; /* Update Expo */ + sh = (-p % BITS_PER_MP_LIMB); + if (MPFR_LIKELY(sh)) + ap[len] &= ~((MPFR_LIMB_ONE << sh) - MPFR_LIMB_ONE); + } + /* Check expo underflow */ + if (MPFR_UNLIKELY(bx < __gmpfr_emin)) + { + TMP_FREE(marker); + /* inexact=0 */ + DEBUG( printf("(D==0 Underflow)\n") ); + if (rnd_mode == GMP_RNDN && + (bx < __gmpfr_emin - 1 || + (/*inexact >= 0 &&*/ mpfr_powerof2_raw (a)))) + rnd_mode = GMP_RNDZ; + return mpfr_set_underflow (a, rnd_mode, MPFR_SIGN(a)); + } + MPFR_SET_EXP (a, bx); + /* No rounding is necessary since the result is exact */ + MPFR_ASSERTD(ap[n-1] > ~ap[n-1]); TMP_FREE(marker); - /* inexact=0 */ - DEBUG( printf("(D==0 Underflow)\n") ); - if (rnd_mode == GMP_RNDN && - (bx < __gmpfr_emin - 1 || - (/*inexact >= 0 &&*/ mpfr_powerof2_raw (a)))) - rnd_mode = GMP_RNDZ; - return mpfr_set_underflow (a, rnd_mode, MPFR_SIGN(a)); + return 0; } - MPFR_SET_EXP (a, bx); - /* No rounding is necessary since the result is exact */ - MPFR_ASSERTD(ap[n-1] > ~ap[n-1]); - TMP_FREE(marker); - return 0; - } - else if (d == 1) - { - /* | <-- b --> - | <-- c --> */ - mp_limb_t c0, mask; - mp_size_t k; - sh = -p % BITS_PER_MP_LIMB; - /* If we lose at least one bit, compute 2*b-c (Exact) - * else compute b-c/2 */ - bp = MPFR_MANT(b); - cp = MPFR_MANT(c); - k = n-1; - limb = bp[k] - cp[k]/2; - if (limb > MPFR_LIMB_HIGHBIT) + else /* if (d == 1) */ { - /* We can't lose precision: compute b-c/2 */ - /* Shift c in the allocated temporary block */ - SubD1NoLose: - c0 = cp[0] & (MPFR_LIMB_ONE<<sh); - cp = (mp_limb_t*) TMP_ALLOC(n * BYTES_PER_MP_LIMB); - mpn_rshift(cp, MPFR_MANT(c), n, 1); - if (c0 == 0) - { - /* Result is exact: no need of rounding! */ + /* | <-- b --> + | <-- c --> */ + mp_limb_t c0, mask; + mp_size_t k; + sh = -p % BITS_PER_MP_LIMB; + /* If we lose at least one bit, compute 2*b-c (Exact) + * else compute b-c/2 */ + bp = MPFR_MANT(b); + cp = MPFR_MANT(c); + k = n-1; + limb = bp[k] - cp[k]/2; + if (limb > MPFR_LIMB_HIGHBIT) + { + /* We can't lose precision: compute b-c/2 */ + /* Shift c in the allocated temporary block */ + SubD1NoLose: + c0 = cp[0] & (MPFR_LIMB_ONE<<sh); + cp = (mp_limb_t*) TMP_ALLOC(n * BYTES_PER_MP_LIMB); + mpn_rshift(cp, MPFR_MANT(c), n, 1); + if (c0 == 0) + { + /* Result is exact: no need of rounding! */ + ap = MPFR_MANT(a); + mpn_sub_n (ap, bp, cp, n); + MPFR_SET_EXP(a, bx); /* No expo overflow! */ + /* No truncate or normalize is needed */ + MPFR_ASSERTD(ap[n-1] > ~ap[n-1]); + /* No rounding is necessary since the result is exact */ + TMP_FREE(marker); + return 0; + } ap = MPFR_MANT(a); + mask = ~((MPFR_LIMB_ONE << sh) - MPFR_LIMB_ONE); + cp[0] &= mask; /* Delete last bit of c */ mpn_sub_n (ap, bp, cp, n); - MPFR_SET_EXP(a, bx); /* No expo overflow! */ - /* No truncate or normalize is needed */ + MPFR_SET_EXP(a, bx); /* No expo overflow! */ + MPFR_ASSERTD( !(ap[0] & ~mask) ); /* Check last bits */ + /* No normalize is needed */ MPFR_ASSERTD(ap[n-1] > ~ap[n-1]); - /* No rounding is necessary since the result is exact */ - TMP_FREE(marker); - return 0; + /* Rounding is necessary since c0 = 1*/ + /* Cp =-1 and C'p+1=0 */ + bcp = 1; bcp1 = 0; + switch (rnd_mode) + { + case GMP_RNDN: + /* Even Rule apply: Check Ap-1 */ + if ((ap[0] & (MPFR_LIMB_ONE<<sh)) == 0) + goto truncate; + case GMP_RNDZ: + goto sub_one_ulp; + default: + goto truncate; + } } - ap = MPFR_MANT(a); - mask = ~((MPFR_LIMB_ONE << sh) - MPFR_LIMB_ONE); - cp[0] &= mask; /* Delete last bit of c */ - mpn_sub_n (ap, bp, cp, n); - MPFR_SET_EXP(a, bx); /* No expo overflow! */ - MPFR_ASSERTD( !(ap[0] & ~mask) ); /* Check last bits */ - /* No normalize is needed */ - MPFR_ASSERTD(ap[n-1] > ~ap[n-1]); - /* Rounding is necessary since c0 = 1*/ - /* Cp =-1 and C'p+1=0 */ - bcp = 1; bcp1 = 0; - switch (rnd_mode) + else if (limb < MPFR_LIMB_HIGHBIT) { - case GMP_RNDN: - /* Even Rule apply: Check Ap-1 */ - if ((ap[0] & (MPFR_LIMB_ONE<<sh)) == 0) - goto truncate; - case GMP_RNDZ: - goto sub_one_ulp; - default: - goto truncate; + /* We lose at least one bit of prec */ + /* Calcul of 2*b-c (Exact) */ + /* Shift b in the allocated temporary block */ + SubD1Lose: + bp = (mp_limb_t*) TMP_ALLOC(n * BYTES_PER_MP_LIMB); + mpn_lshift(bp, MPFR_MANT(b), n, 1); + ap = MPFR_MANT(a); + mpn_sub_n (ap, bp, cp, n); + bx--; + goto ExactNormalize; } - } - else if (limb < MPFR_LIMB_HIGHBIT) - { - /* We lose at least one bit of prec */ - /* Calcul of 2*b-c (Exact) */ - /* Shift b in the allocated temporary block */ - SubD1Lose: - bp = (mp_limb_t*) TMP_ALLOC(n * BYTES_PER_MP_LIMB); - mpn_lshift(bp, MPFR_MANT(b), n, 1); - ap = MPFR_MANT(a); - mpn_sub_n (ap, bp, cp, n); - bx--; - goto ExactNormalize; - } - else - { - /* Case: limb = 100000000000 */ - /* Check while b[k] == c'[k] (C' is C shifted by 1) */ - /* If b[k]<c'[k] => We lose at least one bit*/ - /* If b[k]>c'[k] => We don't lose any bit */ - /* If k==-1 => We don't lose any bit - AND the result is 100000000000 0000000000 00000000000 */ - mp_limb_t carry; - do { - carry = cp[k]&MPFR_LIMB_ONE; - k--; - } while (k>=0 && - bp[k]==(carry=cp[k]/2+(carry<<(BITS_PER_MP_LIMB-1)))); - if (MPFR_UNLIKELY(k<0)) + else { - /* If carry then (sh==0 and Virtual c'[-1] > Virtual b[-1]) */ - if (MPFR_UNLIKELY(carry)) /* carry = cp[0]&MPFR_LIMB_ONE */ + /* Case: limb = 100000000000 */ + /* Check while b[k] == c'[k] (C' is C shifted by 1) */ + /* If b[k]<c'[k] => We lose at least one bit*/ + /* If b[k]>c'[k] => We don't lose any bit */ + /* If k==-1 => We don't lose any bit + AND the result is 100000000000 0000000000 00000000000 */ + mp_limb_t carry; + do { + carry = cp[k]&MPFR_LIMB_ONE; + k--; + } while (k>=0 && + bp[k]==(carry=cp[k]/2+(carry<<(BITS_PER_MP_LIMB-1)))); + if (MPFR_UNLIKELY(k<0)) + { + /*If carry then (sh==0 and Virtual c'[-1] > Virtual b[-1]) */ + if (MPFR_UNLIKELY(carry)) /* carry = cp[0]&MPFR_LIMB_ONE */ + { + MPFR_ASSERTD(sh == 0); + goto SubD1Lose; + } + /* Result is a power of 2 */ + ap = MPFR_MANT(a); + MPN_ZERO(ap, n); + ap[n-1] = MPFR_LIMB_HIGHBIT; + MPFR_SET_EXP(a, bx); /* No expo overflow! */ + /* No Normalize is needed*/ + /* No Rounding is needed */ + TMP_FREE(marker); + return 0; + } + /* carry = cp[k]/2+(cp[k-1]&1)<<(BITS_PER_MP_LIMB-1) = c'[k]*/ + else if (bp[k]>carry) + goto SubD1NoLose; + else { - MPFR_ASSERTD(sh == 0); + MPFR_ASSERTD(bp[k]<carry); goto SubD1Lose; } - /* Result is a power of 2 */ - ap = MPFR_MANT(a); - MPN_ZERO(ap, n); - ap[n-1] = MPFR_LIMB_HIGHBIT; - MPFR_SET_EXP(a, bx); /* No expo overflow! */ - /* No Normalize is needed*/ - /* No Rounding is needed */ - TMP_FREE(marker); - return 0; - } - /* carry = cp[k]/2+(cp[k-1]&1)<<(BITS_PER_MP_LIMB-1) = c'[k]*/ - else if (bp[k]>carry) - goto SubD1NoLose; - else - { - MPFR_ASSERTD(bp[k]<carry); - goto SubD1Lose; } } } diff --git a/tests/memory.c b/tests/memory.c index 8284e3d13..a145e0328 100644 --- a/tests/memory.c +++ b/tests/memory.c @@ -4,6 +4,9 @@ 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 + The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your @@ -21,12 +24,12 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> /* for abort */ +#include <limits.h> + #include "gmp.h" #include "gmp-impl.h" -#include "mpfr.h" #include "mpfr-test.h" - /* Each block allocated is a separate malloc, for the benefit of a redzoning malloc debugger during development or when bug hunting. @@ -37,7 +40,6 @@ MA 02111-1307, USA. */ when tests_memory_end() is called. Test programs must be sure to have "clear"s for all temporary variables used. */ - struct header { void *ptr; size_t size; @@ -60,11 +62,13 @@ tests_memory_find (void *ptr) return NULL; } +/* static int tests_memory_valid (void *ptr) { return (tests_memory_find (ptr) != NULL); } +*/ static void * tests_allocate (size_t size) diff --git a/tests/mpf_compat.h b/tests/mpf_compat.h index 21b851fea..6fc145e9d 100644 --- a/tests/mpf_compat.h +++ b/tests/mpf_compat.h @@ -61,6 +61,8 @@ main () if (prec2 < prec) { printf ("Error in get_prec: %lu < %lu\n", prec2, prec); + mpf_clear (y); + mpf_clear (x); exit (1); } @@ -69,6 +71,8 @@ main () if (prec2 < 2 * prec) { printf ("Error in set_prec: %lu < %lu\n", prec2, 2 * prec); + mpf_clear (y); + mpf_clear (x); exit (1); } @@ -77,6 +81,8 @@ main () if (prec2 < prec) { printf ("Error in set_prec_raw: %lu < %lu\n", prec2, prec); + mpf_clear (y); + mpf_clear (x); exit (1); } @@ -184,6 +190,7 @@ main () /* clear all variables */ + done: mpf_clear (y); mpf_clear (x); diff --git a/tests/reuse.c b/tests/reuse.c index 01d0a4c79..608c05eb3 100644 --- a/tests/reuse.c +++ b/tests/reuse.c @@ -21,9 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" typedef void (*fct_t)(); diff --git a/tests/rnd_mode.c b/tests/rnd_mode.c index 94f5981e5..b949b6b8b 100644 --- a/tests/rnd_mode.c +++ b/tests/rnd_mode.c @@ -19,18 +19,8 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" #include "mpfr-test.h" -/* Note: "gmp-impl.h" must be included because MPFR_HAVE_FESETROUND - may be defined from it (if MPFR is built with GMP). */ - -#ifdef MPFR_HAVE_FESETROUND -#include <fenv.h> -#endif - /* It is important to test each FE_* macro -- see the ISO C99 standard. For instance, with some ARM implementations, only FE_TONEAREST may be defined. */ diff --git a/tests/tabs.c b/tests/tabs.c index d26891bd8..f6d2d1ed9 100644 --- a/tests/tabs.c +++ b/tests/tabs.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <float.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static void diff --git a/tests/tacos.c b/tests/tacos.c index 67241dbe5..62b372ba9 100644 --- a/tests/tacos.c +++ b/tests/tacos.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define TEST_FUNCTION mpfr_acos diff --git a/tests/tacosh.c b/tests/tacosh.c index 37e9ef5ee..e4ffd5f61 100644 --- a/tests/tacosh.c +++ b/tests/tacosh.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define TEST_FUNCTION mpfr_acosh diff --git a/tests/tadd.c b/tests/tadd.c index c910cc264..df32b5e97 100644 --- a/tests/tadd.c +++ b/tests/tadd.c @@ -25,10 +25,7 @@ MA 02111-1307, USA. */ #include <stdlib.h> #include <float.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" /* Parameter "z1" of check() used to be last in the argument list, but that @@ -61,10 +58,19 @@ _check (double x, double y, double z1, mp_rnd_t rnd_mode, unsigned int px, mpfr_set_d (yy, z2, GMP_RNDN); if (!mpfr_cmp (zz, yy) && cert && z1!=z2 && !(Isnan(z1) && Isnan(z2))) { + /* If the format is not IEEE, we can't really check if it fails + (The mantissa could be != 53 bits and the base could be 10)*/ +#if _GMP_IEEE_FLOATS printf ("expected sum is %1.20e, got %1.20e\n", z1, z2); printf ("mpfr_add failed for x=%1.20e y=%1.20e with rnd_mode=%s\n", x, y, mpfr_print_rnd_mode (rnd_mode)); exit (1); +#else + printf ("Warning: expected sum is %1.20e, got %1.20e\n", z1, z2); + printf ("mpfr_add could have failed for x=%1.20e y=%1.20e" + "with rnd_mode=%s\n", + x, y, mpfr_print_rnd_mode (rnd_mode)); +#endif } mpfr_clear (xx); mpfr_clear (yy); diff --git a/tests/tadd_ui.c b/tests/tadd_ui.c index 67c8fc0b6..ec3b5683c 100644 --- a/tests/tadd_ui.c +++ b/tests/tadd_ui.c @@ -23,10 +23,7 @@ MA 02111-1307, USA. */ #include <stdlib.h> #include <float.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define check(x,y,r) check3(x,y,r,0.0) diff --git a/tests/tagm.c b/tests/tagm.c index 904a9ad6a..2981b0ffc 100644 --- a/tests/tagm.c +++ b/tests/tagm.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define check(a,b,r) check4(a,b,r,0.0) diff --git a/tests/tasin.c b/tests/tasin.c index bba0c5221..a3fc361dc 100644 --- a/tests/tasin.c +++ b/tests/tasin.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define TEST_FUNCTION mpfr_asin diff --git a/tests/tasinh.c b/tests/tasinh.c index b65088486..45eaffcc1 100644 --- a/tests/tasinh.c +++ b/tests/tasinh.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define TEST_FUNCTION mpfr_asinh diff --git a/tests/tatan.c b/tests/tatan.c index 47aeac36d..98d143514 100644 --- a/tests/tatan.c +++ b/tests/tatan.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static void diff --git a/tests/tatanh.c b/tests/tatanh.c index f8e99c4b8..6cf23d554 100644 --- a/tests/tatanh.c +++ b/tests/tatanh.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define TEST_FUNCTION mpfr_atanh diff --git a/tests/tcan_round.c b/tests/tcan_round.c index 4afd6ad1e..f9c2b4a40 100644 --- a/tests/tcan_round.c +++ b/tests/tcan_round.c @@ -21,10 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" int diff --git a/tests/tcbrt.c b/tests/tcbrt.c index 6b9d6bb13..d6ee3f034 100644 --- a/tests/tcbrt.c +++ b/tests/tcbrt.c @@ -21,8 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "mpfr.h" + #include "mpfr-test.h" int diff --git a/tests/tcheck.c b/tests/tcheck.c index d883f7317..62927209a 100644 --- a/tests/tcheck.c +++ b/tests/tcheck.c @@ -21,7 +21,7 @@ MA 02111-1307, USA. */ #include <stdlib.h> #include <stdio.h> -#include "mpfr-impl.h" + #include "mpfr-test.h" #define ERROR(s) fprintf(stderr, "mpfr_check failed " s " Prec=%lu\n", pr), abort() diff --git a/tests/tcmp.c b/tests/tcmp.c index f9bdfc234..75bfa7020 100644 --- a/tests/tcmp.c +++ b/tests/tcmp.c @@ -21,10 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" int diff --git a/tests/tcmp2.c b/tests/tcmp2.c index a2ae6e6cc..401f1f0d7 100644 --- a/tests/tcmp2.c +++ b/tests/tcmp2.c @@ -21,10 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" /* set bit n of x to b, where bit 0 is the most significant one */ @@ -169,13 +166,13 @@ tcmp2 (double x, double y, int i) exit (1); } } - else if (j != i) + else if (j != (unsigned) i) { printf ("Error in mpfr_cmp2 for\nx="); mpfr_out_str (stdout, 2, 0, xx, GMP_RNDN); printf ("\ny="); mpfr_out_str (stdout, 2, 0, yy, GMP_RNDN); - printf ("\ngot %lu instead of %u\n", j, i); + printf ("\ngot %lu instead of %d\n", j, i); exit (1); } mpfr_clear(xx); mpfr_clear(yy); diff --git a/tests/tcmp_d.c b/tests/tcmp_d.c index 3c5a3b742..acae591d6 100644 --- a/tests/tcmp_d.c +++ b/tests/tcmp_d.c @@ -21,8 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "mpfr.h" + #include "mpfr-test.h" int diff --git a/tests/tcmp_ui.c b/tests/tcmp_ui.c index 49d4a251a..a3dcf86b4 100644 --- a/tests/tcmp_ui.c +++ b/tests/tcmp_ui.c @@ -21,8 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "mpfr.h" + #include "mpfr-test.h" int diff --git a/tests/tcomparisons.c b/tests/tcomparisons.c index 0de9e6b70..3dcc37e7a 100644 --- a/tests/tcomparisons.c +++ b/tests/tcomparisons.c @@ -23,10 +23,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static void diff --git a/tests/tconst_euler.c b/tests/tconst_euler.c index 8dd947f8e..5357029ef 100644 --- a/tests/tconst_euler.c +++ b/tests/tconst_euler.c @@ -21,9 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" int diff --git a/tests/tconst_log2.c b/tests/tconst_log2.c index 71695d52d..2d6483fcb 100644 --- a/tests/tconst_log2.c +++ b/tests/tconst_log2.c @@ -21,10 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" /* tlog2 [prec] [rnd] [0 = no print] */ diff --git a/tests/tconst_pi.c b/tests/tconst_pi.c index 95c3df84c..aa97cda8b 100644 --- a/tests/tconst_pi.c +++ b/tests/tconst_pi.c @@ -21,8 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "mpfr.h" + #include "mpfr-test.h" /* tconst_pi [prec] [rnd] [0 = no print] */ diff --git a/tests/tcos.c b/tests/tcos.c index 5b8985a5a..dd8c64b43 100644 --- a/tests/tcos.c +++ b/tests/tcos.c @@ -21,9 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static void diff --git a/tests/tcosh.c b/tests/tcosh.c index 441966cd5..6203bc241 100644 --- a/tests/tcosh.c +++ b/tests/tcosh.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define TEST_FUNCTION mpfr_cosh diff --git a/tests/tdiv.c b/tests/tdiv.c index d8bf36eaa..e7baf74ad 100644 --- a/tests/tdiv.c +++ b/tests/tdiv.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define check53(n, d, rnd, res) check4(n, d, rnd, 53, res) diff --git a/tests/tdiv_ui.c b/tests/tdiv_ui.c index 7796fb388..fc624783a 100644 --- a/tests/tdiv_ui.c +++ b/tests/tdiv_ui.c @@ -23,10 +23,7 @@ MA 02111-1307, USA. */ #include <stdlib.h> #include <float.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static void diff --git a/tests/tdump.c b/tests/tdump.c index 9ab6d6372..624e79099 100644 --- a/tests/tdump.c +++ b/tests/tdump.c @@ -21,8 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "mpfr.h" + #include "mpfr-test.h" int diff --git a/tests/teq.c b/tests/teq.c index 6ccae2b21..0ef41df6b 100644 --- a/tests/teq.c +++ b/tests/teq.c @@ -21,16 +21,14 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static void teq (mpfr_t x) { mpfr_t y; - long k, px, mx; + unsigned long k, px, mx; mpfr_init2(y, MPFR_PREC(x)); diff --git a/tests/terf.c b/tests/terf.c index 4cf98821e..5d856d3c0 100644 --- a/tests/terf.c +++ b/tests/terf.c @@ -23,10 +23,7 @@ MA 02111-1307, USA. */ #include <math.h> #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define TEST_FUNCTION mpfr_erf diff --git a/tests/tests.c b/tests/tests.c index edb9b86ad..79f267356 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -24,6 +24,7 @@ MA 02111-1307, USA. */ #endif #include <stdio.h> +#include <stdlib.h> #include <float.h> #if TIME_WITH_SYS_TIME @@ -37,17 +38,8 @@ MA 02111-1307, USA. */ # endif #endif -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" #include "mpfr-test.h" -#if HAVE_SYS_FPU_H -#include <sys/fpu.h> /* for mips fpc_csr */ -#endif - - void tests_rand_start _MPFR_PROTO ((void)); void tests_rand_end _MPFR_PROTO ((void)); @@ -272,7 +264,7 @@ d_trace (const char *name, double d) u.d = d; printf ("["); - for (i = 0; i < sizeof (u.b); i++) + for (i = 0; i < (int) sizeof (u.b); i++) { if (i != 0) printf (" "); @@ -295,7 +287,7 @@ ld_trace (const char *name, long double ld) u.ld = ld; printf ("["); - for (i = 0; i < sizeof (u.b); i++) + for (i = 0; i < (int) sizeof (u.b); i++) { if (i != 0) printf (" "); diff --git a/tests/texceptions.c b/tests/texceptions.c index 6fee9f506..82e6cd8c1 100644 --- a/tests/texceptions.c +++ b/tests/texceptions.c @@ -21,10 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static void diff --git a/tests/texp.c b/tests/texp.c index 54ace9f8c..1ddb63589 100644 --- a/tests/texp.c +++ b/tests/texp.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" int maxu=0; diff --git a/tests/texp2.c b/tests/texp2.c index 54d752e25..33674a014 100644 --- a/tests/texp2.c +++ b/tests/texp2.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define TEST_FUNCTION mpfr_exp2 diff --git a/tests/texpm1.c b/tests/texpm1.c index fdb69d470..ea21cefe9 100644 --- a/tests/texpm1.c +++ b/tests/texpm1.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define TEST_FUNCTION mpfr_expm1 diff --git a/tests/tfactorial.c b/tests/tfactorial.c index cacc4374f..9d7243fce 100644 --- a/tests/tfactorial.c +++ b/tests/tfactorial.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define TEST_FUNCTION mpfr_fac_ui @@ -73,7 +70,8 @@ main (int argc, char *argv[]) /* fact(n) ends with floor(n/2)+floor(n/4)+... zeros */ for (k=n/2, zeros=0; k; k >>= 1) zeros += k; - if (MPFR_EXP(y) <= prec + zeros) /* result should be exact */ + if (MPFR_EXP(y) <= (mp_exp_t) (prec + zeros)) + /* result should be exact */ { if (inexact) { diff --git a/tests/tfma.c b/tests/tfma.c index aa02ec43a..4a17d030d 100644 --- a/tests/tfma.c +++ b/tests/tfma.c @@ -23,12 +23,8 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <limits.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" -#include "mpfr-test.h" +#include "mpfr-test.h" int main (int argc, char *argv[]) @@ -245,9 +241,8 @@ main (int argc, char *argv[]) int inexact, compare; unsigned int n; - int p0=2; - int p1=200; - int N=200; + mp_prec_t p0=2, p1=200; + unsigned int N=200; mpfr_init (t); mpfr_init (slong); diff --git a/tests/tfrac.c b/tests/tfrac.c index b6b3a581b..d17aa740d 100644 --- a/tests/tfrac.c +++ b/tests/tfrac.c @@ -21,8 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "mpfr.h" + #include "mpfr-test.h" #define PIP 70 diff --git a/tests/tgamma.c b/tests/tgamma.c index 26f1580c0..8fd703ba6 100644 --- a/tests/tgamma.c +++ b/tests/tgamma.c @@ -21,10 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" int mpfr_gamma (mpfr_ptr, mpfr_srcptr, mp_rnd_t); diff --git a/tests/tgeneric.c b/tests/tgeneric.c index a5e9c6537..f1fc39f9e 100644 --- a/tests/tgeneric.c +++ b/tests/tgeneric.c @@ -20,7 +20,7 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ static void -test_generic (int p0, int p1, int N) +test_generic (mp_prec_t p0, mp_prec_t p1, unsigned int N) { mp_prec_t prec, yprec; mpfr_t x, y, z, t; diff --git a/tests/tget_d.c b/tests/tget_d.c index 637038f3e..8ff9c2ccb 100644 --- a/tests/tget_d.c +++ b/tests/tget_d.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <float.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static int diff --git a/tests/tget_d_2exp.c b/tests/tget_d_2exp.c index 2a7b42fcc..989f990a0 100644 --- a/tests/tget_d_2exp.c +++ b/tests/tget_d_2exp.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <float.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" @@ -44,7 +41,7 @@ check_round (void) for (rnd_mode = 0; rnd_mode < 4; rnd_mode++) { - for (i = 0; i < numberof (data); i++) + for (i = 0; i < (int) numberof (data); i++) { mpfr_set_ui (f, 1L, GMP_RNDZ); mpfr_mul_2exp (f, f, data[i], GMP_RNDZ); diff --git a/tests/tget_str.c b/tests/tget_str.c index d30629a41..db9df9eff 100644 --- a/tests/tget_str.c +++ b/tests/tget_str.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static void @@ -400,7 +397,7 @@ check_special (int b, mp_prec_t p) { /* x = b^i (exact) */ for (r=0; r<4; r++) - for (m=(i < 3) ? 2 : i-1; m<=i+1; m++) + for (m= (i<3)? 2 : i-1 ; (int) m <= i+1 ; m++) { mpfr_get_str (s, &e, b, m, x, r); /* s should be 1 followed by (m-1) zeros, and e should be i+1 */ diff --git a/tests/thyperbolic.c b/tests/thyperbolic.c index eb003aa5c..12c9f9585 100644 --- a/tests/thyperbolic.c +++ b/tests/thyperbolic.c @@ -18,11 +18,9 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include <stdlib.h> #include <stdio.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static int diff --git a/tests/thypot.c b/tests/thypot.c index 15abd95e0..26a7d30ff 100644 --- a/tests/thypot.c +++ b/tests/thypot.c @@ -23,10 +23,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <limits.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define TEST_FUNCTION mpfr_hypot diff --git a/tests/tinits.c b/tests/tinits.c index 435f345f9..3433df89c 100644 --- a/tests/tinits.c +++ b/tests/tinits.c @@ -19,10 +19,6 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" #include "mpfr-test.h" int diff --git a/tests/tisnan.c b/tests/tisnan.c index 31e40e7bd..7cee98202 100644 --- a/tests/tisnan.c +++ b/tests/tisnan.c @@ -21,8 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "mpfr.h" + #include "mpfr-test.h" int diff --git a/tests/tlog.c b/tests/tlog.c index 79cfa0502..4bd6e475a 100644 --- a/tests/tlog.c +++ b/tests/tlog.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define check(a,r) check2(a,r,0.0) diff --git a/tests/tlog10.c b/tests/tlog10.c index 466847df7..63f10bc17 100644 --- a/tests/tlog10.c +++ b/tests/tlog10.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define TEST_FUNCTION mpfr_log10 diff --git a/tests/tlog1p.c b/tests/tlog1p.c index c079b9d02..6ddf7a4f3 100644 --- a/tests/tlog1p.c +++ b/tests/tlog1p.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define TEST_FUNCTION mpfr_log1p diff --git a/tests/tlog2.c b/tests/tlog2.c index f4aae6657..5f6be8d35 100644 --- a/tests/tlog2.c +++ b/tests/tlog2.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define TEST_FUNCTION mpfr_log2 diff --git a/tests/tmul.c b/tests/tmul.c index 328326312..8f40d2f12 100644 --- a/tests/tmul.c +++ b/tests/tmul.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" /* Workaround for sparc gcc 2.95.x bug, see notes in tadd.c. */ diff --git a/tests/tmul_2exp.c b/tests/tmul_2exp.c index 751978ae4..f333d61bf 100644 --- a/tests/tmul_2exp.c +++ b/tests/tmul_2exp.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" /* checks that x*y gives the same results in double diff --git a/tests/tmul_ui.c b/tests/tmul_ui.c index f8defca92..d6beda616 100644 --- a/tests/tmul_ui.c +++ b/tests/tmul_ui.c @@ -21,10 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static void diff --git a/tests/tnext.c b/tests/tnext.c index 0ae9b0a31..6a00d6c34 100644 --- a/tests/tnext.c +++ b/tests/tnext.c @@ -21,10 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" /* Generic tests for mpfr_nextabove and mpfr_nextbelow */ @@ -81,7 +78,7 @@ inverse_test (void) int i, neg, below; mp_prec_t prec; - for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) + for (i = 0; i < (int) (sizeof(tests) / sizeof(tests[0])); i++) for (neg = 0; neg <= 1; neg++) for (below = 0; below <= 1; below++) for (prec = MPFR_PREC_MIN; prec < 200; prec += 3) diff --git a/tests/tout_str.c b/tests/tout_str.c index 37b7e71f7..82362390f 100644 --- a/tests/tout_str.c +++ b/tests/tout_str.c @@ -24,10 +24,7 @@ MA 02111-1307, USA. */ #include <stdlib.h> #include <string.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" FILE *fout; diff --git a/tests/tpow.c b/tests/tpow.c index beea9be20..7ab0cba52 100644 --- a/tests/tpow.c +++ b/tests/tpow.c @@ -21,9 +21,9 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "mpfr.h" -#include "mpfr-impl.h" +#include <float.h> +#include <math.h> + #include "mpfr-test.h" static void @@ -289,11 +289,13 @@ particular_cases (void) exit (1); } -void f(void) +void f (void) { } -static void +void underflows (void); + +void underflows (void) { mpfr_t x, y; diff --git a/tests/tpow3.c b/tests/tpow3.c index 08b91de3d..02010ec69 100644 --- a/tests/tpow3.c +++ b/tests/tpow3.c @@ -23,10 +23,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <limits.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" @@ -41,9 +38,8 @@ main (int argc, char *argv[]) int inexact, compare, compare2; unsigned int n, err; - int p0=2; - int p1=100; - int N=25; + mp_prec_t p0=2, p1=100; + unsigned int N=25; tests_start_mpfr (); diff --git a/tests/trandom.c b/tests/trandom.c index c61c17af2..19d80aa87 100644 --- a/tests/trandom.c +++ b/tests/trandom.c @@ -22,13 +22,11 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <time.h> -#include "gmp.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static void -test_random (unsigned long nbtests, unsigned long prec, int verbose) +test_random (long nbtests, mp_prec_t prec, int verbose) { mpfr_t x; int *tab, size_tab, k; @@ -82,7 +80,7 @@ test_random (unsigned long nbtests, unsigned long prec, int verbose) } static void -test_random2 (unsigned long nbtests, unsigned long prec, int verbose) +test_random2 (long nbtests, mp_prec_t prec, int verbose) { mpfr_t x; int *tab, size_tab, k, sh, xn; @@ -150,7 +148,7 @@ test_random2 (unsigned long nbtests, unsigned long prec, int verbose) } static void -test_urandomb (unsigned long nbtests, unsigned long prec, int verbose) +test_urandomb (long nbtests, mp_prec_t prec, int verbose) { mpfr_t x; int *tab, size_tab, k, sh, xn; @@ -217,7 +215,9 @@ test_urandomb (unsigned long nbtests, unsigned long prec, int verbose) int main (int argc, char *argv[]) { - unsigned long nbtests, prec; int verbose = 0; + long nbtests; + mp_prec_t prec; + int verbose = 0; tests_start_mpfr (); @@ -227,7 +227,7 @@ main (int argc, char *argv[]) nbtests = 10000; if (argc > 1) { - int a = atoi(argv[1]); + long a = atol(argv[1]); if (a != 0) nbtests = a; } @@ -235,7 +235,7 @@ main (int argc, char *argv[]) if (argc <= 2) prec = 1000; else - prec = atoi(argv[2]); + prec = atol(argv[2]); test_random (nbtests, prec, verbose); test_random2 (nbtests, prec, verbose); diff --git a/tests/trint.c b/tests/trint.c index b02b42221..fa7f91f06 100644 --- a/tests/trint.c +++ b/tests/trint.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #if __STDC_VERSION__ >= 199901L diff --git a/tests/tround_prec.c b/tests/tround_prec.c index 0ecf56e34..bc89cfc3e 100644 --- a/tests/tround_prec.c +++ b/tests/tround_prec.c @@ -21,8 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "mpfr.h" + #include "mpfr-test.h" int diff --git a/tests/tset.c b/tests/tset.c index 379c1c623..877becfa7 100644 --- a/tests/tset.c +++ b/tests/tset.c @@ -21,10 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" int diff --git a/tests/tset_d.c b/tests/tset_d.c index af44a8a6b..e5ac12d6b 100644 --- a/tests/tset_d.c +++ b/tests/tset_d.c @@ -23,10 +23,7 @@ MA 02111-1307, USA. */ #include <stdlib.h> #include <float.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" int diff --git a/tests/tset_f.c b/tests/tset_f.c index e3fa5f05c..f61942cb8 100644 --- a/tests/tset_f.c +++ b/tests/tset_f.c @@ -22,8 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <time.h> -#include "gmp.h" -#include "mpfr.h" + #include "mpfr-test.h" int diff --git a/tests/tset_ld.c b/tests/tset_ld.c index 7cb6a461e..d406a3509 100644 --- a/tests/tset_ld.c +++ b/tests/tset_ld.c @@ -23,10 +23,7 @@ MA 02111-1307, USA. */ #include <stdlib.h> #include <float.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static void diff --git a/tests/tset_q.c b/tests/tset_q.c index e95b658a4..2e718ef9c 100644 --- a/tests/tset_q.c +++ b/tests/tset_q.c @@ -22,8 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <time.h> -#include "gmp.h" -#include "mpfr.h" + #include "mpfr-test.h" static void diff --git a/tests/tset_si.c b/tests/tset_si.c index 064e02717..1a0864280 100644 --- a/tests/tset_si.c +++ b/tests/tset_si.c @@ -22,30 +22,26 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" /* FIXME: Comparing against mpfr_get_si/ui is not ideal, it'd be better to have all tests examine the bits in mpfr_t for what should come out. */ - int main (int argc, char *argv[]) { mpfr_t x; - long k, z, d; - unsigned long zl, dl, N; + long k, z, d, N; + unsigned long zl, dl; int inex; tests_start_mpfr (); mpfr_init2 (x, 100); - N = (argc==1) ? 200000 : atoi (argv[1]); + N = (argc==1) ? 200000 : atol (argv[1]); for (k = 1; k <= N; k++) { diff --git a/tests/tset_str.c b/tests/tset_str.c index 13f9cfeb7..be36a1a33 100644 --- a/tests/tset_str.c +++ b/tests/tset_str.c @@ -24,10 +24,7 @@ MA 02111-1307, USA. */ #include <string.h> #include <limits.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define N 30000 diff --git a/tests/tset_z.c b/tests/tset_z.c index a23b4258c..73b3f11f4 100644 --- a/tests/tset_z.c +++ b/tests/tset_z.c @@ -23,10 +23,7 @@ MA 02111-1307, USA. */ #include <stdlib.h> #include <limits.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" diff --git a/tests/tsgn.c b/tests/tsgn.c index dd64cf35b..71c12d61e 100644 --- a/tests/tsgn.c +++ b/tests/tsgn.c @@ -22,12 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include <float.h> -#include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static void diff --git a/tests/tsin.c b/tests/tsin.c index 33cd4d938..7a181a46d 100644 --- a/tests/tsin.c +++ b/tests/tsin.c @@ -21,9 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static void diff --git a/tests/tsin_cos.c b/tests/tsin_cos.c index a94ad2282..e59570fff 100644 --- a/tests/tsin_cos.c +++ b/tests/tsin_cos.c @@ -21,10 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static void diff --git a/tests/tsinh.c b/tests/tsinh.c index 0fccfae23..1739e35c6 100644 --- a/tests/tsinh.c +++ b/tests/tsinh.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define TEST_FUNCTION mpfr_sinh diff --git a/tests/tsqrt.c b/tests/tsqrt.c index c100a37b4..f1900030b 100644 --- a/tests/tsqrt.c +++ b/tests/tsqrt.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define check(a,r) check3(a,r,-1.0) diff --git a/tests/tsqrt_ui.c b/tests/tsqrt_ui.c index 82e564c65..d3ae201a4 100644 --- a/tests/tsqrt_ui.c +++ b/tests/tsqrt_ui.c @@ -22,8 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <time.h> -#include "gmp.h" -#include "mpfr.h" + #include "mpfr-test.h" int maxulp=0; diff --git a/tests/tsub.c b/tests/tsub.c index 2126d6cb2..05f5acd21 100644 --- a/tests/tsub.c +++ b/tests/tsub.c @@ -21,9 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static void diff --git a/tests/tsub1sp.c b/tests/tsub1sp.c index 0be1dd5e8..27a23017c 100644 --- a/tests/tsub1sp.c +++ b/tests/tsub1sp.c @@ -21,7 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "mpfr-impl.h" + #include "mpfr-test.h" void check_special(void); diff --git a/tests/tsub_ui.c b/tests/tsub_ui.c index 298a884cd..d58315fc3 100644 --- a/tests/tsub_ui.c +++ b/tests/tsub_ui.c @@ -23,10 +23,7 @@ MA 02111-1307, USA. */ #include <stdlib.h> #include <float.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define check(x,y,r) check3(x,y,r,0.0) diff --git a/tests/tswap.c b/tests/tswap.c index 06efb5518..5edda71e2 100644 --- a/tests/tswap.c +++ b/tests/tswap.c @@ -21,8 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "mpfr.h" + #include "mpfr-test.h" int diff --git a/tests/ttan.c b/tests/ttan.c index 8f435037a..cbc1c678f 100644 --- a/tests/ttan.c +++ b/tests/ttan.c @@ -21,9 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define TEST_FUNCTION mpfr_tan diff --git a/tests/ttanh.c b/tests/ttanh.c index f27a970f9..15e6f5efd 100644 --- a/tests/ttanh.c +++ b/tests/ttanh.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define TEST_FUNCTION mpfr_tanh diff --git a/tests/ttrunc.c b/tests/ttrunc.c index 347f4000c..f1cf9d20e 100644 --- a/tests/ttrunc.c +++ b/tests/ttrunc.c @@ -21,9 +21,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" #define SIZEX 100 diff --git a/tests/tui_div.c b/tests/tui_div.c index aa1376f45..961dc1f83 100644 --- a/tests/tui_div.c +++ b/tests/tui_div.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" /* checks that y/x gives the same results in double diff --git a/tests/tui_pow.c b/tests/tui_pow.c index d072c2810..249a020e5 100644 --- a/tests/tui_pow.c +++ b/tests/tui_pow.c @@ -23,10 +23,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <limits.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static void @@ -167,9 +164,8 @@ main (int argc, char *argv[]) mp_rnd_t rnd; unsigned int n; - int p0=2; - int p1=100; - int N=20; + mp_prec_t p0=2, p1=100; + unsigned int N=20; mpfr_init2 (z, 38); mpfr_init2 (t, 6); diff --git a/tests/tui_sub.c b/tests/tui_sub.c index 97ab92556..410f41d49 100644 --- a/tests/tui_sub.c +++ b/tests/tui_sub.c @@ -23,10 +23,7 @@ MA 02111-1307, USA. */ #include <stdlib.h> #include <float.h> #include <time.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static void diff --git a/tests/tzeta.c b/tests/tzeta.c index 73005c92a..790e5447b 100644 --- a/tests/tzeta.c +++ b/tests/tzeta.c @@ -22,10 +22,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" -#include "mpfr-impl.h" + #include "mpfr-test.h" static void |