diff options
-rw-r--r-- | add.c | 39 | ||||
-rw-r--r-- | add_ulp.c | 8 | ||||
-rw-r--r-- | agm.c | 17 | ||||
-rw-r--r-- | cmp.c | 18 | ||||
-rw-r--r-- | cmp_ui.c | 22 | ||||
-rw-r--r-- | div.c | 14 | ||||
-rw-r--r-- | div_2exp.c | 8 | ||||
-rw-r--r-- | div_ui.c | 9 | ||||
-rw-r--r-- | exp.c | 12 | ||||
-rw-r--r-- | get_str.c | 11 | ||||
-rw-r--r-- | log.c | 13 | ||||
-rw-r--r-- | log2.c | 11 | ||||
-rw-r--r-- | mpfr.h | 7 | ||||
-rw-r--r-- | mul.c | 12 | ||||
-rw-r--r-- | mul_2exp.c | 8 | ||||
-rw-r--r-- | mul_ui.c | 8 | ||||
-rw-r--r-- | neg.c | 10 | ||||
-rw-r--r-- | out_str.c | 16 | ||||
-rw-r--r-- | pi.c | 9 | ||||
-rw-r--r-- | pow.c | 11 | ||||
-rw-r--r-- | print_raw.c | 11 | ||||
-rw-r--r-- | print_rnd_mode.c | 5 | ||||
-rw-r--r-- | random.c | 8 | ||||
-rw-r--r-- | rnd_mode.c | 8 | ||||
-rw-r--r-- | round.c | 56 | ||||
-rw-r--r-- | set.c | 11 | ||||
-rw-r--r-- | set_d.c | 26 | ||||
-rw-r--r-- | set_f.c | 11 | ||||
-rw-r--r-- | set_si.c | 7 | ||||
-rw-r--r-- | set_str_raw.c | 6 | ||||
-rw-r--r-- | set_z.c | 11 | ||||
-rw-r--r-- | sqrt.c | 10 | ||||
-rw-r--r-- | sub.c | 32 |
33 files changed, 407 insertions, 58 deletions
@@ -1,9 +1,6 @@ /* (c) PolKA project, Inria Lorraine */ - /* written by Paul Zimmermann, February 1999 */ - -/* to do: - destination may be identical to operands -*/ +/* to do: - destination may be identical to operands */ #include <stdio.h> @@ -11,7 +8,8 @@ #include "gmp-impl.h" #include "mpfr.h" -extern mpfr_sub1(mpfr_ptr, mpfr_srcptr, mpfr_srcptr, unsigned char, int); +extern void mpfr_sub1 _PROTO((mpfr_ptr, mpfr_srcptr, mpfr_srcptr, + unsigned char, int)); /* #define DEBUG2 */ @@ -33,8 +31,18 @@ mp_limb_t *ap0, *ap1; diff_exp is the difference between the exponents of b and c, which is supposed >= 0 */ -void mpfr_add1(a, b, c, rnd_mode, diff_exp) -mpfr_ptr a; mpfr_srcptr b, c; unsigned char rnd_mode; int diff_exp; +void +#if __STDC__ +mpfr_add1(mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, + unsigned char rnd_mode, int diff_exp) +#else +mpfr_add1(a, b, c, rnd_mode, diff_exp) + mpfr_ptr a; + mpfr_srcptr b; + mpfr_srcptr c; + unsigned char rnd_mode; + int diff_exp; +#endif { mp_limb_t *ap, *bp, *cp, cc, c2, c3=0; unsigned int an,bn,cn; int sh,dif,k; TMP_DECL(marker); @@ -409,8 +417,17 @@ printf("b+c="); mpfr_print_raw(a); putchar('\n'); return; } -void mpfr_add(a, b, c, rnd_mode) -mpfr_ptr a; mpfr_srcptr b, c; unsigned char rnd_mode; +void +#if __STDC__ +mpfr_add(mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, + unsigned char rnd_mode) +#else +mpfr_add(a, b, c, rnd_mode) + mpfr_ptr a; + mpfr_srcptr b; + mpfr_srcptr c; + unsigned char rnd_mode; +#endif { int diff_exp; @@ -418,8 +435,8 @@ mpfr_ptr a; mpfr_srcptr b, c; unsigned char rnd_mode; SET_NAN(a); return; } - if (!NOTZERO(b)) return mpfr_set(a, c, rnd_mode); - if (!NOTZERO(c)) return mpfr_set(a, b, rnd_mode); + if (!NOTZERO(b)) { mpfr_set(a, c, rnd_mode); return; } + if (!NOTZERO(c)) { mpfr_set(a, b, rnd_mode); return; } diff_exp = EXP(b)-EXP(c); if (SIGN(b) != SIGN(c)) { /* signs differ, it's a subtraction */ @@ -3,7 +3,13 @@ #include "mpfr.h" /* sets x to x+sign(x)*2^(EXP(x)-PREC(x)) */ -int mpfr_add_one_ulp(mpfr_ptr x) +int +#if __STDC__ +mpfr_add_one_ulp(mpfr_ptr x) +#else +mpfr_add_one_ulp(x) + mpfr_ptr x; +#endif { int xn, sh; mp_limb_t *xp; @@ -5,7 +5,16 @@ #include "mpfr.h" -void mpfr_agm(mpfr_ptr r, mpfr_srcptr a, mpfr_srcptr b, unsigned char rnd_mode) +void +#ifdef __STDC__ +mpfr_agm(mpfr_ptr r, mpfr_srcptr a, mpfr_srcptr b, unsigned char rnd_mode) +#else +mpfr_agm(r, a, b, rnd_mode) + mpfr_ptr r; + mpfr_srcptr a; + mpfr_srcptr b; + unsigned char rnd_mode; +#endif { int i, ntotal, p, q, go_on, no, ulps; double uo, vo; @@ -13,7 +22,7 @@ void mpfr_agm(mpfr_ptr r, mpfr_srcptr a, mpfr_srcptr b, unsigned char rnd_mode) /* I want b>= a */ if (mpfr_cmp(a,b) > 0) - return mpfr_agm(r, b, a, rnd_mode); + { mpfr_agm(r, b, a, rnd_mode); return; } /* If a or b is NaN, the result is NaN */ @@ -57,7 +66,7 @@ void mpfr_agm(mpfr_ptr r, mpfr_srcptr a, mpfr_srcptr b, unsigned char rnd_mode) /* Main loop */ while (go_on==1) { - int can_go_on, err; + int err; err=ceil((3*ntotal+2)*exp(-p*log(2))+3*exp(-p*uo*log(2)/(vo-uo))/log(2)); @@ -95,7 +104,7 @@ void mpfr_agm(mpfr_ptr r, mpfr_srcptr a, mpfr_srcptr b, unsigned char rnd_mode) /* Else, we could have to work with more precision */ else { - int round1, round2, equals; + int round1, round2; mpfr_t res1, res2; mpfr_init2(res1,q); mpfr_init2(res2,q); @@ -21,7 +21,14 @@ of b and c, i.e. one plus the number of bits shifts to align b and c /* #define DEBUG */ -int mpfr_cmp ( mpfr_srcptr b, mpfr_srcptr c ) +int +#if __STDC__ +mpfr_cmp ( mpfr_srcptr b, mpfr_srcptr c ) +#else +mpfr_cmp(b, c) + mpfr_srcptr b; + mpfr_srcptr c; +#endif { long int s, diff_exp; unsigned long bn, cn; @@ -58,7 +65,14 @@ int mpfr_cmp ( mpfr_srcptr b, mpfr_srcptr c ) Assumes b>=c, which implies EXP(b)>=EXP(c). if b=c, returns prec(b). */ -int mpfr_cmp2 ( mpfr_srcptr b, mpfr_srcptr c ) +int +#if __STDC__ +mpfr_cmp2 ( mpfr_srcptr b, mpfr_srcptr c ) +#else +mpfr_cmp2(b, c) + mpfr_srcptr b; + mpfr_srcptr c; +#endif { long int d, bn, cn, k; mp_limb_t *bp, *cp, t, u=0, cc=0; @@ -10,7 +10,16 @@ a negative value if b<i*2^f, zero if b=i*2^f */ -int mpfr_cmp_ui_2exp ( mpfr_srcptr b, unsigned long int i, int f ) + +int +#if __STDC__ +mpfr_cmp_ui_2exp ( mpfr_srcptr b, unsigned long int i, int f ) +#else +mpfr_cmp_ui_2exp (b, i, f) + mpfr_srcptr b; + unsigned long int i; + int f; +#endif { int e, k, bn; mp_limb_t c, *bp; @@ -43,7 +52,16 @@ int mpfr_cmp_ui_2exp ( mpfr_srcptr b, unsigned long int i, int f ) a negative value if b<i*2^f, zero if b=i*2^f */ -int mpfr_cmp_si_2exp ( mpfr_srcptr b, long int i, int f ) + +int +#if __STDC__ +mpfr_cmp_si_2exp ( mpfr_srcptr b, long int i, int f ) +#else +mpfr_cmp_si_2exp(b, i, f) + mpfr_srcptr b; + long int i; + int f; +#endif { int e, k, bn, si; mp_limb_t c, *bp; @@ -8,11 +8,19 @@ /* q <- n/d using Goldschmidt's iteration returns 0 iff result is exact */ -int mpfr_div(Q, n, d, rnd_mode) -mpfr_ptr Q; mpfr_srcptr n, d; unsigned char rnd_mode; +int +#if __STDC__ +mpfr_div(mpfr_ptr Q, mpfr_srcptr n, mpfr_srcptr d, unsigned char rnd_mode) +#else +mpfr_div(Q, n, d, rnd_mode) + mpfr_ptr Q; + mpfr_srcptr n; + mpfr_srcptr d; + unsigned char rnd_mode; +#endif { mpfr_t eps, tmp, one; mp_limb_t cc; mpfr_ptr q; - int expd, i, prec, precq, sh, guard, err, maxprec, exact=0; + int expd, i, prec, precq, err, maxprec, exact=0; TMP_DECL(marker); if (FLAG_NAN(n) || FLAG_NAN(d)) { SET_NAN(Q); return 1; } diff --git a/div_2exp.c b/div_2exp.c index 944892782..961c5d33d 100644 --- a/div_2exp.c +++ b/div_2exp.c @@ -4,7 +4,15 @@ #include "mpfr.h" void +#if __STDC__ mpfr_div_2exp(mpfr_ptr y, mpfr_srcptr x, unsigned long int n, unsigned char rnd_mode) +#else +mpfr_div_2exp(y, x, n, rnd_mode) + mpfr_ptr y; + mpfr_srcptr x; + unsigned long int n; + unsigned char rnd_mode; +#endif { /* Important particular case */ if (y != x) mpfr_set(y, x, rnd_mode); @@ -8,7 +8,15 @@ /* returns 0 if result exact, non-zero otherwise */ int +#ifdef __STDC__ mpfr_div_ui(mpfr_ptr y, mpfr_srcptr x, unsigned long u, unsigned char rnd_mode) +#else +mpfr_div_ui(y, x, u, rnd_mode) + mpfr_ptr y; + mpfr_srcptr x; + unsigned long u; + unsigned char rnd_mode; +#endif { int xn, yn, dif, sh, i; mp_limb_t *xp, *yp, c, d; @@ -84,4 +92,5 @@ printf("y="); mpfr_print_raw(y); putchar('\n'); } return 1; } + return 0; /* to prevent warning from gcc */ } @@ -12,9 +12,17 @@ where x = n*log(2)+(2^K)*r number of operations = O(K+prec(r)/K) */ -int mpfr_exp(mpfr_ptr y, mpfr_srcptr x, unsigned char rnd_mode) +int +#if __STDC__ +mpfr_exp(mpfr_ptr y, mpfr_srcptr x, unsigned char rnd_mode) +#else +mpfr_exp(y, x, rnd_mode) + mpfr_ptr y; + mpfr_srcptr x; + unsigned char rnd_mode; +#endif { - int n, expx, K, precy, q, k, l, expr, err; mp_limb_t xp; + int n, expx, K, precy, q, k, l, expr, err; mpfr_t r, s, t; if (FLAG_NAN(x)) { SET_NAN(y); return 1; } @@ -13,9 +13,18 @@ For op = 3.1416 we get str = "31416" and expptr=1. */ - +#if __STDC__ char *mpfr_get_str(char *str, mp_exp_t *expptr, int base, size_t n, mpfr_srcptr op, unsigned char rnd_mode) +#else +char *mpfr_get_str(str, expptr, base, n, op, rnd_mode) + char *str; + mp_exp_t *expptr; + int base; + size_t n; + mpfr_srcptr op; + unsigned char rnd_mode; +#endif { double d; long e, q, neg, p, err, prec, sh; mpfr_t a, b; mpz_t bz; char *str0; unsigned char rnd1; int f, pow2; @@ -16,10 +16,19 @@ */ -void mpfr_log(mpfr_ptr r, mpfr_srcptr a, unsigned char rnd_mode) { +void +#if __STDC__ +mpfr_log(mpfr_ptr r, mpfr_srcptr a, unsigned char rnd_mode) +#else +mpfr_log() + mpfr_ptr r; + mpfr_srcptr a; + unsigned char rnd_mode; +#endif +{ int p, m, q, bool, err; mpfr_t cst, rapport, agm, tmp1, tmp2, s, mm; - double x, ref; + double ref; /* If a is NaN, the result is NaN */ if (FLAG_NAN(a)) @@ -21,7 +21,12 @@ int _mpfr_log2_prec=0; /* precision of stored value */ Then 2^N*log(2)-S'(N) <= N-1+2/N <= N for N>=2. */ -void mpfr_log2(x, rnd_mode) mpfr_ptr x; unsigned char rnd_mode; +void +#if __STDC__ +mpfr_log2(mpfr_ptr x, unsigned char rnd_mode) +#else +mpfr_log2(x, rnd_mode) mpfr_ptr x; unsigned char rnd_mode; +#endif { int N, oldN, k, precx; mpz_t s, t, u; @@ -31,7 +36,9 @@ void mpfr_log2(x, rnd_mode) mpfr_ptr x; unsigned char rnd_mode; if (precx <= _mpfr_log2_prec) { if (rnd_mode==GMP_RNDZ || rnd_mode==GMP_RNDD || mpfr_can_round(_mpfr_log2, _mpfr_log2_prec, GMP_RNDZ, rnd_mode, precx)) - return mpfr_set(x, _mpfr_log2, rnd_mode); + { + mpfr_set(x, _mpfr_log2, rnd_mode); return; + } } /* need to recompute */ @@ -125,8 +125,11 @@ void mpfr_div_2exp _PROTO((mpfr_ptr, mpfr_srcptr, unsigned long int,unsigned cha void mpfr_set_prec _PROTO((mpfr_ptr, unsigned long int)); extern mp_size_t __gmp_default_fp_bit_precision; extern char __gmp_default_rounding_mode; -char *mpfr_print_rnd_mode(unsigned char rnd_mode); - +char *mpfr_print_rnd_mode(unsigned char); +void mpfr_neg _PROTO((mpfr_t, mpfr_t, unsigned char)); +int mpfr_sub_one_ulp _PROTO((mpfr_ptr x)); +int mpfr_div_ui _PROTO((mpfr_ptr y, mpfr_srcptr x, unsigned long u, unsigned char rnd_mode)); +unsigned long int mpfr_get_prec _PROTO((mpfr_t x)); #define mpfr_init(x) mpfr_init2(x, __gmp_default_fp_bit_precision) #define mpfr_cmp_ui(b,i) mpfr_cmp_ui_2exp(b,i,0) @@ -10,8 +10,16 @@ [current complexity is O(PREC(b)*PREC(c))] */ -void mpfr_mul(a, b, c, rnd_mode) -mpfr_ptr a; mpfr_srcptr b, c; unsigned char rnd_mode; +void +#if __STDC__ +mpfr_mul(mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, unsigned char rnd_mode) +#else +mpfr_mul(a, b, c, rnd_mode) + mpfr_ptr a; + mpfr_srcptr b; + mpfr_srcptr c; + unsigned char rnd_mode; +#endif { unsigned int bn, cn, an, k; int cc; mp_limb_t *ap=MANT(a), *bp=MANT(b), *cp=MANT(c), *tmp, b1; diff --git a/mul_2exp.c b/mul_2exp.c index 9953dd44d..db4be64c2 100644 --- a/mul_2exp.c +++ b/mul_2exp.c @@ -4,7 +4,15 @@ #include "mpfr.h" void +#if __STDC__ mpfr_mul_2exp(mpfr_ptr y, mpfr_srcptr x, unsigned long int n, unsigned char rnd_mode) +#else +mpfr_mul_2exp(y, x, n, rnd_mode) + mpfr_ptr y; + mpfr_srcptr x; + unsigned long int n; + unsigned char rnd_mode; +#endif { /* Important particular case */ if (y != x) mpfr_set(y, x, rnd_mode); @@ -5,7 +5,15 @@ #include "mpfr.h" void +#if __STDC__ mpfr_mul_ui(mpfr_ptr y, mpfr_srcptr x, unsigned long u, unsigned char RND_MODE) +#else +mpfr_mul_ui() + mpfr_ptr y; + mpfr_srcptr x; + unsigned long u; + unsigned char RND_MODE; +#endif { mp_limb_t carry, *my, *old_my; unsigned long c; unsigned long xsize, ysize, cnt, dif; @@ -3,7 +3,15 @@ #include "gmp-impl.h" #include "mpfr.h" -void mpfr_neg(mpfr_t a, mpfr_t b, unsigned char rnd_mode) +void +#if __STDC__ +mpfr_neg(mpfr_t a, mpfr_t b, unsigned char rnd_mode) +#else +mpfr_neg(a, b, rnd_mode) + mpfr_t a; + mpfr_t b; + unsigned char rnd_mode; +#endif { CHANGE_SIGN(b); if (a != b) { @@ -4,8 +4,18 @@ #include "gmp-impl.h" #include "mpfr.h" -size_t mpfr_out_str (FILE *stream, int base, size_t n_digits, mpfr_srcptr op, - unsigned char rnd_mode) +size_t +#if __STDC__ +mpfr_out_str (FILE *stream, int base, size_t n_digits, mpfr_srcptr op, + unsigned char rnd_mode) +#else +mpfr_out_str (stream, base, n_digits, op, rnd_mode) + FILE *stream; + int base; + size_t n_digits; + mpfr_srcptr op; + unsigned char rnd_mode; +#endif { char *s,*s0; size_t l; mp_exp_t e; @@ -24,7 +34,7 @@ size_t mpfr_out_str (FILE *stream, int base, size_t n_digits, mpfr_srcptr op, fputs(s, stream); /* rest of mantissa */ if (e) { fputc((base>10) ? '@' : 'e', stream); l++; - sprintf(s, "%d", e); + sprintf(s, "%ld", e); l += strlen(s); fprintf(stream, "%s", s); } @@ -35,7 +35,14 @@ so Pi*16^N-S'(N) <= N+1 (as 1/4/N^2 < 1) #include "longlong.h" #include "mpfr.h" -void mpfr_pi(x, rnd_mode) mpfr_ptr x; unsigned char rnd_mode; +void +#if __STDC__ +mpfr_pi(mpfr_ptr x, unsigned char rnd_mode) +#else +mpfr_pi(x, rnd_mode) + mpfr_ptr x; + unsigned char rnd_mode; +#endif { int N, oldN, n, prec; mpz_t pi, num, den, d3, d2, tmp; mpfr_t y; @@ -3,7 +3,16 @@ #include "mpfr.h" /* sets x to y^n */ -void mpfr_pow_ui (mpfr_ptr x, mpfr_srcptr y, unsigned int n, unsigned char rnd) +void +#if __STDC__ +mpfr_pow_ui (mpfr_ptr x, mpfr_srcptr y, unsigned int n, unsigned char rnd) +#else +mpfr_pow_ui (x, y, n, rnd) + mpfr_ptr x; + mpfr_srcptr y; + unsigned int n; + unsigned char rnd; +#endif { int i; diff --git a/print_raw.c b/print_raw.c index 4c6db45e1..beb61f22e 100644 --- a/print_raw.c +++ b/print_raw.c @@ -4,7 +4,13 @@ #include "mpfr.h" void +#if __STDC__ mpfr_get_str_raw(char *digit_ptr, mpfr_srcptr x) +#else +mpfr_get_str_raw(digit_ptr, x) + char *digit_ptr; + mpfr_srcptr x; +#endif { mp_limb_t *mx, wd, t; long ex, sx, k, l, p; @@ -34,7 +40,12 @@ mpfr_get_str_raw(char *digit_ptr, mpfr_srcptr x) } void +#if __STDC__ mpfr_print_raw(mpfr_srcptr x) +#else +mpfr_print_raw(x) + mpfr_srcptr x; +#endif { char *str; diff --git a/print_rnd_mode.c b/print_rnd_mode.c index 0fdb27032..44f78cfcc 100644 --- a/print_rnd_mode.c +++ b/print_rnd_mode.c @@ -4,7 +4,12 @@ #include "mpfr.h" char * +#if __STDC__ mpfr_print_rnd_mode(unsigned char rnd_mode) +#else +mpfr_print_rnd_mode(rnd_mode) + unsigned char rnd_mode; +#endif { switch (rnd_mode) { @@ -6,8 +6,16 @@ /* Computes a random mpfr in [0, 1[ with precision PREC */ +extern long random _PROTO((void)); +extern int srandom _PROTO((unsigned int)); + void +#if __STDC__ mpfr_random(mpfr_ptr x) +#else +mpfr_random(x) + mpfr_ptr x; +#endif { mp_limb_t *xp; unsigned long xs, i, cnt; diff --git a/rnd_mode.c b/rnd_mode.c index ad48ce95c..1c2e720b5 100644 --- a/rnd_mode.c +++ b/rnd_mode.c @@ -64,7 +64,13 @@ char *out; #endif /* sets the machine rounding mode to the value rnd_mode */ -void mpfr_set_machine_rnd_mode(unsigned char rnd_mode) +void +#if __STDC__ +mpfr_set_machine_rnd_mode(unsigned char rnd_mode) +#else +mpfr_set_machine_rnd_mode(rnd_mode) + unsigned char rnd_mode; +#endif { switch (rnd_mode) { case GMP_RNDN: TONEAREST; break; @@ -13,8 +13,18 @@ Does *not* modify anything. */ -int mpfr_round_raw2(mp_limb_t *xp, unsigned long xn, char neg, char rnd, - unsigned long prec) +int +#if __STDC__ +mpfr_round_raw2(mp_limb_t *xp, unsigned long xn, char neg, char rnd, + unsigned long prec) +#else +mpfr_round_raw2(xp, xn, neg, rnd, prec) + mp_limb_t *xp; + unsigned long xn; + char neg; + char rnd; + unsigned long prec; +#endif { unsigned long mask, nw; long wd; char rw; short l; @@ -76,8 +86,17 @@ int mpfr_round_raw2(mp_limb_t *xp, unsigned long xn, char neg, char rnd, /* puts in y the value of xp (which has xsize limbs) rounded to precision xprec and direction RND_MODE */ int +#if __STDC__ mpfr_round_raw(mp_limb_t *y, mp_limb_t *xp, char RND_MODE, long xsize, unsigned long xprec) +#else +mpfr_round_raw(y, xp, RND_MODE, xsize, xprec) + mp_limb_t *y; + mp_limb_t *xp; + char RND_MODE; + long xsize; + unsigned long xprec; +#endif { unsigned long nw, mask; char negative = 0, rw, carry = 0; @@ -114,7 +133,14 @@ mpfr_round_raw(mp_limb_t *y, mp_limb_t *xp, char RND_MODE, } void +#if __STDC__ mpfr_round(mpfr_t x, char RND_MODE, unsigned long prec) +#else +mpfr_round(x, RND_MODE, prec) + mpfr_t x; + char RND_MODE; + unsigned long prec; +#endif { mp_limb_t *tmp; int carry; unsigned long nw, xn; @@ -149,17 +175,39 @@ mpfr_round(mpfr_t x, char RND_MODE, unsigned long prec) Side effects: none. */ -int mpfr_can_round(b, err, rnd1, rnd2, prec) mpfr_t b; unsigned long err; -unsigned char rnd1, rnd2; unsigned long prec; + +int +#if __STDC__ +mpfr_can_round(mpfr_t b, unsigned long err, unsigned char rnd1, + unsigned char rnd2, unsigned long prec) +#else +mpfr_can_round(b, err, rnd1, rnd2, prec) + mpfr_t b; + unsigned long err; + unsigned char rnd1; + unsigned char rnd2; + unsigned long prec; +#endif { return mpfr_can_round_raw(MANT(b), (PREC(b) - 1)/BITS_PER_MP_LIMB + 1, SIGN(b), err, rnd1, rnd2, prec); } int +#if __STDC__ mpfr_can_round_raw(mp_limb_t *bp, unsigned long bn, char neg, unsigned long err, unsigned char rnd1, unsigned char rnd2, unsigned long prec) +#else +mpfr_can_round_raw(bp, bn, neg, err, rnd1, rnd2, prec) + mp_limb_t *bp; + unsigned long bn; + char neg; + unsigned long err; + unsigned char rnd1; + unsigned char rnd2; + unsigned long prec; +#endif { int k, k1, l, l1, tn; mp_limb_t cc, cc2, *tmp; TMP_DECL(marker); @@ -3,8 +3,15 @@ #include "gmp-impl.h" #include "mpfr.h" -void mpfr_set(a, b, rnd_mode) -mpfr_ptr a; mpfr_srcptr b; unsigned char rnd_mode; +void +#if __STDC__ +mpfr_set(mpfr_ptr a, mpfr_srcptr b, unsigned char rnd_mode) +#else +mpfr_set(a, b, rnd_mode) + mpfr_ptr a; + mpfr_srcptr b; + unsigned char rnd_mode; +#endif { int carry, an, preca = PREC(a), sh; mp_limb_t *ap = MANT(a); @@ -1,4 +1,8 @@ -#include <math.h> /* for isnan */ +#if __GNUC__ /* gcc "patched" headers seem to omit isnan... */ +extern int isnan(double); +#endif +#include <math.h> /* for isnan and NaN */ + #include "gmp.h" #include "gmp-impl.h" #include "longlong.h" @@ -206,7 +210,14 @@ __mpfr_scale2 (d, exp) /* End of part included from gmp */ void +#if __STDC__ mpfr_set_d(mpfr_t r, double d, unsigned char rnd_mode) +#else +mpfr_set_d(r, d, rnd_mode) + mpfr_t r; + double d; + unsigned char rnd_mode; +#endif { int signd, sizer; unsigned int cnt; @@ -237,7 +248,13 @@ mpfr_set_d(mpfr_t r, double d, unsigned char rnd_mode) } double +#if __STDC__ mpfr_get_d2(mpfr_srcptr src, long e) +#else +mpfr_get_d2(src, e) + mpfr_srcptr(src); + long e; +#endif { double res; mp_size_t size, i, n_limbs_to_use; @@ -276,8 +293,13 @@ mpfr_get_d2(mpfr_srcptr src, long e) } double +#if __STDC__ mpfr_get_d(mpfr_srcptr src) +#else +mpfr_get_d(src) + mpfr_srcptr src; +#endif { - mpfr_get_d2(src, EXP(src)); + return mpfr_get_d2(src, EXP(src)); } @@ -4,7 +4,16 @@ #include "longlong.h" #include "mpfr.h" -void mpfr_set_f(mpfr_ptr y, mpf_srcptr x, unsigned long prec, char rnd_mode) +void +#if __STDC__ +mpfr_set_f(mpfr_ptr y, mpf_srcptr x, unsigned long prec, char rnd_mode) +#else +mpfr_set_f(y, x, prec, rnd_mode) + mpfr_ptr y; + mpf_srcptr x; + unsigned long prec; + char rnd_mode; +#endif { mp_limb_t *my, *mx; unsigned long cnt, sx, sy; @@ -5,7 +5,14 @@ #include "mpfr.h" void +#if __STDC__ mpfr_set_si(mpfr_ptr x, long i, unsigned char rnd_mode) +#else +mpfr_set_si(x, i, rnd_mode) + mpfr_ptr x; + long i; + unsigned char rnd_mode; +#endif { unsigned long xn, ai, cnt; diff --git a/set_str_raw.c b/set_str_raw.c index 478346b40..46414b0a3 100644 --- a/set_str_raw.c +++ b/set_str_raw.c @@ -15,7 +15,13 @@ to hold all the bits of str. */ void +#if __STDC__ mpfr_set_str_raw(mpfr_ptr x, char *str) +#else +mpfr_set_str_raw(x, str) + mpfr_ptr x; + char *str; +#endif { char *str2, *str0, negative = 0; unsigned long j, l, k = 0, xsize, cnt; mp_limb_t *xp; @@ -4,8 +4,15 @@ #include "mpfr.h" /* set f to the integer z */ -int mpfr_set_z (f, z, rnd) mpfr_ptr f; mpz_srcptr z; -unsigned char rnd; +int +#if __STDC__ +mpfr_set_z (mpfr_ptr f, mpz_srcptr z, unsigned char rnd) +#else +mpfr_set_z (f, z, rnd) + mpfr_ptr f; + mpz_srcptr z; + unsigned char rnd; +#endif { int fn, zn, k, dif, sign_z, sh; mp_limb_t *fp = MANT(f), cc, c2; @@ -4,7 +4,15 @@ #include "gmp-impl.h" #include "mpfr.h" -void mpfr_sqrt(mpfr_ptr X, mpfr_srcptr a, unsigned char rnd_mode) +void +#if __STDC__ +mpfr_sqrt(mpfr_ptr X, mpfr_srcptr a, unsigned char rnd_mode) +#else +mpfr_sqrt(X, a, rnd_mode) + mpfr_ptr X; + mpfr_srcptr a; + unsigned char rnd_mode; +#endif { int p, q, err, i, e, n; mpfr_t t, u; mpfr_ptr x; @@ -5,8 +5,16 @@ /* #define DEBUG2 */ -void mpfr_sub(a, b, c, rnd_mode) -mpfr_ptr a; mpfr_srcptr b, c; unsigned char rnd_mode; +void +#if __STDC__ +mpfr_sub(mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, unsigned char rnd_mode) +#else +mpfr_sub(a, b, c, rnd_mode) + mpfr_ptr a; + mpfr_srcptr b; + mpfr_srcptr c; + unsigned char rnd_mode; +#endif { if (FLAG_NAN(b) || FLAG_NAN(c)) { SET_NAN(a); return; } if (b==c) { SET_ZERO(a); return; } @@ -19,7 +27,12 @@ mpfr_ptr a; mpfr_srcptr b, c; unsigned char rnd_mode; to the left minus ap[0]..ap[n-1], with 0 <= sh < mp_bits_per_limb, and returns the borrow. */ -mp_limb_t mpn_sub_lshift_n (ap, bp, n, sh, an) mp_limb_t *ap, *bp; int n,sh,an; +mp_limb_t +#if __STDC__ +mpn_sub_lshift_n (mp_limb_t *ap, mp_limb_t *bp, int n, int sh, int an) +#else +mpn_sub_lshift_n (ap, bp, n, sh, an) mp_limb_t *ap, *bp; int n,sh,an; +#endif { mp_limb_t c, bh; @@ -35,8 +48,17 @@ mp_limb_t mpn_sub_lshift_n (ap, bp, n, sh, an) mp_limb_t *ap, *bp; int n,sh,an; } /* signs of b and c differ, abs(b)>=abs(c), diff_exp>=0 */ -void mpfr_sub1(a, b, c, rnd_mode, diff_exp) -mpfr_t a, b, c; unsigned char rnd_mode; int diff_exp; +void +#if __STDC__ +mpfr_sub1(mpfr_t a, mpfr_t b, mpfr_t c, unsigned char rnd_mode, int diff_exp) +#else +mpfr_sub1(a, b, c, rnd_mode, diff_exp) + mpfr_t a; + mpfr_t b; + mpfr_t c; + unsigned char rnd_mode; + int diff_exp; +#endif { mp_limb_t *ap, *bp, *cp, cc, c2; unsigned int an,bn,cn; int sh,dif,k,cancel,cancel1,cancel2; |