summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mpfr-impl.h159
-rw-r--r--mpfr.h112
-rw-r--r--tests/tconst_pi.c6
-rw-r--r--tests/texp.c54
4 files changed, 172 insertions, 159 deletions
diff --git a/mpfr-impl.h b/mpfr-impl.h
index 15565f3c7..cc7486164 100644
--- a/mpfr-impl.h
+++ b/mpfr-impl.h
@@ -665,20 +665,20 @@ extern unsigned char *mpfr_stack;
/* temporary allocate 1 limb at xp, and initialize mpfr variable x */
/* The temporary var doesn't have any size field, but it doesn't matter
* since only functions dealing with the Heap care about it */
-#define MPFR_TMP_INIT1(xp, x, p) \
- ( MPFR_PREC(x) = (p), \
- MPFR_MANT(x) = (xp), \
- MPFR_SET_POS(x), \
+#define MPFR_TMP_INIT1(xp, x, p) \
+ ( MPFR_PREC(x) = (p), \
+ MPFR_MANT(x) = (xp), \
+ MPFR_SET_POS(x), \
MPFR_SET_INVALID_EXP(x))
-#define MPFR_TMP_INIT(xp, x, p, s) \
- (xp = (mp_ptr) TMP_ALLOC(BYTES_PER_MP_LIMB * ((size_t) s)), \
+#define MPFR_TMP_INIT(xp, x, p, s) \
+ (xp = (mp_ptr) TMP_ALLOC(BYTES_PER_MP_LIMB * ((size_t) s)), \
MPFR_TMP_INIT1(xp, x, p))
-#define MPFR_TMP_INIT_ABS(d, s) \
- ( MPFR_PREC(d) = MPFR_PREC(s), \
- MPFR_MANT(d) = MPFR_MANT(s), \
- MPFR_SET_POS(d), \
+#define MPFR_TMP_INIT_ABS(d, s) \
+ ( MPFR_PREC(d) = MPFR_PREC(s), \
+ MPFR_MANT(d) = MPFR_MANT(s), \
+ MPFR_SET_POS(d), \
MPFR_EXP(d) = MPFR_EXP(s))
@@ -692,8 +692,8 @@ extern unsigned char *mpfr_stack;
#define mpfr_const_euler(_d,_r) mpfr_cache(_d, __gmpfr_cache_const_euler, _r)
#define mpfr_const_catalan(_d,_r) mpfr_cache(_d,__gmpfr_cache_const_catalan,_r)
-#define MPFR_DECL_INIT_CACHE(_cache,_func) \
- mpfr_cache_t MPFR_THREAD_ATTR _cache = \
+#define MPFR_DECL_INIT_CACHE(_cache,_func) \
+ mpfr_cache_t MPFR_THREAD_ATTR _cache = \
{{{{0,MPFR_SIGN_POS,0,(mp_limb_t*)0}},0,_func}}
@@ -737,58 +737,58 @@ extern unsigned char *mpfr_stack;
/* Example: MPFR_SADD_OVERFLOW (c, a, b, long, unsigned long,
* LONG_MIN, LONG_MAX,
* goto overflow, goto underflow); */
-#define MPFR_UADD_OVERFLOW(c,a,b,ACTION_IF_OVERFLOW) \
- do { \
- (c) = (a) + (b); \
- if ((c) < (a)) ACTION_IF_OVERFLOW; \
+#define MPFR_UADD_OVERFLOW(c,a,b,ACTION_IF_OVERFLOW) \
+ do { \
+ (c) = (a) + (b); \
+ if ((c) < (a)) ACTION_IF_OVERFLOW; \
} while (0)
#define MPFR_SADD_OVERFLOW(c,a,b,STYPE,UTYPE,MIN,MAX,ACTION_IF_POS_OVERFLOW,ACTION_IF_NEG_OVERFLOW) \
- do { \
- if ((a) >= 0 && (b) >= 0) { \
- UTYPE uc,ua,ub; \
- ua = (UTYPE) a; ub = (UTYPE) b; \
- MPFR_UADD_OVERFLOW (uc, ua, ub, ACTION_IF_POS_OVERFLOW); \
- if (uc > (UTYPE)(MAX)) ACTION_IF_POS_OVERFLOW; \
- else (c) = (STYPE) uc; \
- } else if ((a) < 0 && (b) < 0) { \
- UTYPE uc,ua,ub; \
- ua = -(UTYPE) a; ub = -(UTYPE) b; \
- MPFR_UADD_OVERFLOW (uc, ua, ub, ACTION_IF_NEG_OVERFLOW); \
- if (uc >= -(UTYPE)(MIN) || uc > (UTYPE)(MAX)) { \
- if (uc == -(UTYPE)(MIN)) (c) = (MIN); \
- else ACTION_IF_NEG_OVERFLOW; } \
- else (c) = -(STYPE) uc; \
- } else (c) = (a) + (b); \
+ do { \
+ if ((a) >= 0 && (b) >= 0) { \
+ UTYPE uc,ua,ub; \
+ ua = (UTYPE) a; ub = (UTYPE) b; \
+ MPFR_UADD_OVERFLOW (uc, ua, ub, ACTION_IF_POS_OVERFLOW); \
+ if (uc > (UTYPE)(MAX)) ACTION_IF_POS_OVERFLOW; \
+ else (c) = (STYPE) uc; \
+ } else if ((a) < 0 && (b) < 0) { \
+ UTYPE uc,ua,ub; \
+ ua = -(UTYPE) a; ub = -(UTYPE) b; \
+ MPFR_UADD_OVERFLOW (uc, ua, ub, ACTION_IF_NEG_OVERFLOW); \
+ if (uc >= -(UTYPE)(MIN) || uc > (UTYPE)(MAX)) { \
+ if (uc == -(UTYPE)(MIN)) (c) = (MIN); \
+ else ACTION_IF_NEG_OVERFLOW; } \
+ else (c) = -(STYPE) uc; \
+ } else (c) = (a) + (b); \
} while (0)
-/* Set a number to 1 (Fast) */
-#define MPFR_SET_ONE(x) \
-do { \
- mp_size_t s = MPFR_LIMB_SIZE(x) - 1;\
- MPFR_SET_POS(x);\
- MPFR_EXP(x) = 1;\
- MPN_ZERO ( MPFR_MANT(x), s);\
- MPFR_MANT(x)[s] = MPFR_LIMB_HIGHBIT;\
+/* Set a number to 1 (Fast) - It doesn't check if 1 is in the exponent range */
+#define MPFR_SET_ONE(x) \
+do { \
+ mp_size_t s = MPFR_LIMB_SIZE(x) - 1; \
+ MPFR_SET_POS(x); \
+ MPFR_EXP(x) = 1; \
+ MPN_ZERO ( MPFR_MANT(x), s); \
+ MPFR_MANT(x)[s] = MPFR_LIMB_HIGHBIT; \
} while (0)
/* Compute s = (-a) % BITS_PER_MP_LIMB
* a is unsigned! Check if it works,
* otherwise tries another way to compute it */
-#define MPFR_UNSIGNED_MINUS_MODULO(s, a) \
- do \
- { \
- if ((UINT_MAX % BITS_PER_MP_LIMB) == (BITS_PER_MP_LIMB-1)) \
- (s) = (-(a)) % BITS_PER_MP_LIMB; \
- else \
- { \
- (s) = (a) % BITS_PER_MP_LIMB; \
- if (s != 0) \
- (s) = BITS_PER_MP_LIMB - (s); \
- } \
- MPFR_ASSERTD ((s) >= 0 && (s) < BITS_PER_MP_LIMB); \
- } \
+#define MPFR_UNSIGNED_MINUS_MODULO(s, a) \
+ do \
+ { \
+ if ((UINT_MAX % BITS_PER_MP_LIMB) == (BITS_PER_MP_LIMB-1)) \
+ (s) = (mpfr_prec_t) (-(a)) % BITS_PER_MP_LIMB; \
+ else \
+ { \
+ (s) = (a) % BITS_PER_MP_LIMB; \
+ if (s != 0) \
+ (s) = BITS_PER_MP_LIMB - (s); \
+ } \
+ MPFR_ASSERTD ((s) >= 0 && (s) < BITS_PER_MP_LIMB); \
+ } \
while (0)
/* Use it only for debug reasons */
@@ -812,6 +812,7 @@ do { \
#define mpfr_get_d1(x) mpfr_get_d(x,__gmpfr_default_rounding_mode)
+/* Store in r the size in bits of the mpz_t z */
#define MPFR_MPZ_SIZEINBASE2(r, z) \
do { \
int _cnt; \
@@ -827,7 +828,7 @@ do { \
******************************************************/
/* See README.dev for details on how to use the macros.
- They are used to make the exponent range to be maximal
+ They are used to set the exponent range to the maximum
temporarily */
typedef struct {
@@ -1085,28 +1086,36 @@ typedef struct {
(err), (prec) + ((rnd)==GMP_RNDN)))
/* Assuming that the function as a taylor expansion which looks like:
- y=f(x) = x + g(x) with |g(x)| <=2^(EXP(x)-err)
- we can quickly set y to x if x is small (ie nearly err > prec(y)+1).
- It assumes that f(x) is not representable exactly as a FP number.
- y is the destination, x the value to set, err the error term,
- dir the direction (=0 => towards 0, =1 => away), rnd the rounding mode.
+ y=o(f(x)) = o(x + g(x)) with |g(x)| <=2^(EXP(x)-err)
+ we can quickly set y to x if x is small (ie err > prec(y)+1) in most
+ cases. It assumes that f(x) is not representable exactly as a FP number.
+ x must not be a singular value (NAN, INF or ZERO).
+
+ y is the destination (a mpfr_t), x the value to set (a mpfr_t),
+ err the error term (a mp_exp_t), dir (an int) is the direction of
+ the commited error (if dir = 0, it rounds towards 0, if dir=1,
+ it rounds away from 0), rnd the rounding mode.
+
It returns from the function a ternary value in case of success.
If you want to free something, you must fill the "extra" field
- in consequences, otherwise put nothing. */
-/* Note: Use mpfr_round_p (faster but less precise) or mpfr_can_round? */
-#define MPFR_FAST_COMPUTE_IF_SMALL_INPUT(y,x,err,dir,rnd,extra) \
- do { \
- mp_exp_t _err = (err); \
- mp_prec_t _prec = MPFR_PREC (y) + ((rnd) == GMP_RNDN); \
- if (_err > 0 && (mpfr_uexp_t) _err > _prec \
- && (dir == 0 \
- || (mpfr_uexp_t) _err > MPFR_PREC (x) \
- || mpfr_can_round ((x), _err, GMP_RNDZ, (rnd), MPFR_PREC (y)))) \
- { \
- int _inexact = mpfr_round_near_x ((y),(x),(dir),(rnd)); \
- extra; \
- return _inexact; \
- } \
+ in consequences, otherwise put nothing in it.
+
+ The test is less restrictive thant necessary, but the function
+ will finish the check itself.
+*/
+#define MPFR_FAST_COMPUTE_IF_SMALL_INPUT(y,x,err,dir,rnd,extra) \
+ do { \
+ mp_exp_t _err = (err); \
+ if (MPFR_UNLIKELY (_err > 0 \
+ && (mpfr_uexp_t) _err > MPFR_PREC (y) + 1)) \
+ { \
+ int _inexact = mpfr_round_near_x ((y),(x),(err),(dir),(rnd)); \
+ if (_inexact != 0) \
+ { \
+ extra; \
+ return _inexact; \
+ } \
+ } \
} while (0)
/******************************************************
@@ -1377,7 +1386,7 @@ __MPFR_DECLSPEC void mpfr_dump_mant _MPFR_PROTO ((const mp_limb_t *,
mp_prec_t));
__MPFR_DECLSPEC int mpfr_round_near_x _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
- int, mp_rnd_t));
+ mp_exp_t, int, mp_rnd_t));
#if defined (__cplusplus)
}
#endif
diff --git a/mpfr.h b/mpfr.h
index a7eacb2c6..60055997c 100644
--- a/mpfr.h
+++ b/mpfr.h
@@ -75,7 +75,7 @@ typedef unsigned long mpfr_prec_t;
/* Definition of precision limits */
#define MPFR_PREC_MIN 2
-#define MPFR_PREC_MAX ((mpfr_prec_t)((~(mpfr_prec_t)0)>>1))
+#define MPFR_PREC_MAX ((mpfr_prec_t)((mpfr_prec_t)(~(mpfr_prec_t)0)>>1))
/* Definition of sign */
typedef int mpfr_sign_t;
@@ -86,7 +86,7 @@ typedef int mpfr_sign_t;
/* Definition of the main structure */
typedef struct {
- mpfr_prec_t _mpfr_prec;
+ mpfr_prec_t _mpfr_prec;
mpfr_sign_t _mpfr_sign;
mp_exp_t _mpfr_exp;
mp_limb_t *_mpfr_d;
@@ -178,7 +178,7 @@ __MPFR_DECLSPEC mp_exp_t mpfr_get_emax_max _MPFR_PROTO ((void));
__MPFR_DECLSPEC void mpfr_set_default_rounding_mode _MPFR_PROTO((mpfr_rnd_t));
__MPFR_DECLSPEC mp_rnd_t mpfr_get_default_rounding_mode _MPFR_PROTO((void));
-__MPFR_DECLSPEC __gmp_const char *
+__MPFR_DECLSPEC __gmp_const char *
mpfr_print_rnd_mode _MPFR_PROTO((mpfr_rnd_t));
__MPFR_DECLSPEC void mpfr_clear_flags _MPFR_PROTO ((void));
@@ -200,23 +200,23 @@ __MPFR_DECLSPEC int mpfr_nanflag_p _MPFR_PROTO ((void));
__MPFR_DECLSPEC int mpfr_inexflag_p _MPFR_PROTO ((void));
__MPFR_DECLSPEC int mpfr_erangeflag_p _MPFR_PROTO ((void));
-__MPFR_DECLSPEC int
+__MPFR_DECLSPEC int
mpfr_check_range _MPFR_PROTO ((mpfr_ptr, int, mpfr_rnd_t));
__MPFR_DECLSPEC void mpfr_init2 _MPFR_PROTO ((mpfr_ptr, mpfr_prec_t));
__MPFR_DECLSPEC void mpfr_init _MPFR_PROTO ((mpfr_ptr));
__MPFR_DECLSPEC void mpfr_clear _MPFR_PROTO ((mpfr_ptr));
-__MPFR_DECLSPEC void
+__MPFR_DECLSPEC void
mpfr_inits2 _MPFR_PROTO ((mp_prec_t, mpfr_ptr, ...)) __MPFR_SENTINEL_ATTR;
-__MPFR_DECLSPEC void
+__MPFR_DECLSPEC void
mpfr_inits _MPFR_PROTO ((mpfr_ptr, ...)) __MPFR_SENTINEL_ATTR;
-__MPFR_DECLSPEC void
+__MPFR_DECLSPEC void
mpfr_clears _MPFR_PROTO ((mpfr_ptr, ...)) __MPFR_SENTINEL_ATTR;
-__MPFR_DECLSPEC int
+__MPFR_DECLSPEC int
mpfr_prec_round _MPFR_PROTO ((mpfr_ptr, mpfr_prec_t, mpfr_rnd_t));
-__MPFR_DECLSPEC int
+__MPFR_DECLSPEC int
mpfr_can_round _MPFR_PROTO ((mpfr_srcptr, mp_exp_t, mpfr_rnd_t, mpfr_rnd_t,
mpfr_prec_t));
@@ -229,37 +229,37 @@ __MPFR_DECLSPEC void mpfr_set_default_prec _MPFR_PROTO((mpfr_prec_t));
__MPFR_DECLSPEC mp_prec_t mpfr_get_default_prec _MPFR_PROTO((void));
__MPFR_DECLSPEC int mpfr_set_d _MPFR_PROTO ((mpfr_ptr, double, mpfr_rnd_t));
-__MPFR_DECLSPEC int
+__MPFR_DECLSPEC int
mpfr_set_ld _MPFR_PROTO ((mpfr_ptr, long double, mpfr_rnd_t));
-__MPFR_DECLSPEC int
+__MPFR_DECLSPEC int
mpfr_set_z _MPFR_PROTO ((mpfr_ptr, mpz_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC void mpfr_set_nan _MPFR_PROTO ((mpfr_ptr));
__MPFR_DECLSPEC void mpfr_set_inf _MPFR_PROTO ((mpfr_ptr, int));
-__MPFR_DECLSPEC int
+__MPFR_DECLSPEC int
mpfr_set_f _MPFR_PROTO ((mpfr_ptr, mpf_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int
mpfr_get_f _MPFR_PROTO ((mpf_ptr, mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_set_si _MPFR_PROTO ((mpfr_ptr, long, mpfr_rnd_t));
-__MPFR_DECLSPEC int
+__MPFR_DECLSPEC int
mpfr_set_ui _MPFR_PROTO ((mpfr_ptr, unsigned long, mpfr_rnd_t));
-__MPFR_DECLSPEC int
+__MPFR_DECLSPEC int
mpfr_set_si_2exp _MPFR_PROTO ((mpfr_ptr, long, mp_exp_t, mpfr_rnd_t));
-__MPFR_DECLSPEC int
+__MPFR_DECLSPEC int
mpfr_set_ui_2exp _MPFR_PROTO ((mpfr_ptr,unsigned long,mp_exp_t,mpfr_rnd_t));
-__MPFR_DECLSPEC int
+__MPFR_DECLSPEC int
mpfr_set_q _MPFR_PROTO ((mpfr_ptr, mpq_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC int
+__MPFR_DECLSPEC int
mpfr_set_str _MPFR_PROTO ((mpfr_ptr, __gmp_const char *, int, mpfr_rnd_t));
-__MPFR_DECLSPEC int
+__MPFR_DECLSPEC int
mpfr_init_set_str _MPFR_PROTO ((mpfr_ptr, __gmp_const char *, int,
mpfr_rnd_t));
-__MPFR_DECLSPEC int
+__MPFR_DECLSPEC int
mpfr_set4 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t, int));
-__MPFR_DECLSPEC int
+__MPFR_DECLSPEC int
mpfr_abs _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC int
+__MPFR_DECLSPEC int
mpfr_set _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC int
+__MPFR_DECLSPEC int
mpfr_copysign _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_neg _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
@@ -271,10 +271,10 @@ __MPFR_DECLSPEC int mpfr_neg _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
#define mpfr_get_sj __gmpfr_mpfr_get_sj
#define mpfr_get_uj __gmpfr_mpfr_get_uj
__MPFR_DECLSPEC int mpfr_set_sj _MPFR_PROTO ((mpfr_t, intmax_t, mpfr_rnd_t));
-__MPFR_DECLSPEC int
+__MPFR_DECLSPEC int
mpfr_set_sj_2exp _MPFR_PROTO ((mpfr_t, intmax_t, intmax_t, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_set_uj _MPFR_PROTO ((mpfr_t, uintmax_t, mpfr_rnd_t));
-__MPFR_DECLSPEC int
+__MPFR_DECLSPEC int
mpfr_set_uj_2exp _MPFR_PROTO ((mpfr_t, uintmax_t, intmax_t, mpfr_rnd_t));
__MPFR_DECLSPEC intmax_t mpfr_get_sj _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC uintmax_t mpfr_get_uj _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
@@ -285,14 +285,14 @@ __MPFR_DECLSPEC double mpfr_get_d _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC long double mpfr_get_ld _MPFR_PROTO ((mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC double mpfr_get_d1 _MPFR_PROTO ((mpfr_srcptr));
-__MPFR_DECLSPEC double mpfr_get_d_2exp _MPFR_PROTO ((long*, mpfr_srcptr,
+__MPFR_DECLSPEC double mpfr_get_d_2exp _MPFR_PROTO ((long*, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC long mpfr_get_si _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC unsigned long mpfr_get_ui _MPFR_PROTO ((mpfr_srcptr,
+__MPFR_DECLSPEC unsigned long mpfr_get_ui _MPFR_PROTO ((mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC char*mpfr_get_str _MPFR_PROTO ((char*, mp_exp_t*, int, size_t,
mpfr_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC void mpfr_get_z _MPFR_PROTO ((mpz_ptr z, mpfr_srcptr f,
+__MPFR_DECLSPEC void mpfr_get_z _MPFR_PROTO ((mpz_ptr z, mpfr_srcptr f,
mpfr_rnd_t));
__MPFR_DECLSPEC void mpfr_free_str _MPFR_PROTO ((char *));
@@ -317,34 +317,34 @@ __MPFR_DECLSPEC size_t mpfr_out_str _MPFR_PROTO ((FILE*, int, size_t,
mpfr_srcptr, mpfr_rnd_t));
#endif
-__MPFR_DECLSPEC int mpfr_pow _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_pow _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_pow_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_pow_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
long int, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_pow_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
unsigned long int, mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_ui_pow_ui _MPFR_PROTO ((mpfr_ptr, unsigned long int,
+__MPFR_DECLSPEC int mpfr_ui_pow_ui _MPFR_PROTO ((mpfr_ptr, unsigned long int,
unsigned long int, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_ui_pow _MPFR_PROTO ((mpfr_ptr, unsigned long int,
mpfr_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_pow_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_pow_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpz_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_sqrt _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_sqrt _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sqrt_ui _MPFR_PROTO ((mpfr_ptr, unsigned long,
mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_add _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_add _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_sub _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_sub _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_mul _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_mul _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_div _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_div _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_add_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_add_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
unsigned long, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sub_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
unsigned long, mpfr_rnd_t));
@@ -363,11 +363,11 @@ __MPFR_DECLSPEC int mpfr_sub_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
long int, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_si_sub _MPFR_PROTO ((mpfr_ptr, long int,
mpfr_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_mul_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_mul_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
long int, mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_div_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_div_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
long int, mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_si_div _MPFR_PROTO ((mpfr_ptr, long int,
+__MPFR_DECLSPEC int mpfr_si_div _MPFR_PROTO ((mpfr_ptr, long int,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sqr _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
@@ -389,7 +389,7 @@ __MPFR_DECLSPEC int mpfr_log1p _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
__MPFR_DECLSPEC int mpfr_exp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_exp2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_exp10 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_exp10 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_expm1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_rnd_t));
@@ -408,7 +408,7 @@ __MPFR_DECLSPEC int mpfr_cmp_si_2exp _MPFR_PROTO ((mpfr_srcptr, long,
mp_exp_t));
__MPFR_DECLSPEC void mpfr_reldiff _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_eq _MPFR_PROTO((mpfr_srcptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_eq _MPFR_PROTO((mpfr_srcptr, mpfr_srcptr,
unsigned long));
__MPFR_DECLSPEC int mpfr_sgn _MPFR_PROTO ((mpfr_srcptr));
@@ -434,7 +434,7 @@ __MPFR_DECLSPEC int mpfr_rint_round _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_rint_trunc _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_rint_ceil _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_rint_ceil _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_rint_floor _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_rnd_t));
@@ -514,21 +514,21 @@ __MPFR_DECLSPEC int mpfr_dim _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
__MPFR_DECLSPEC int mpfr_mul_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpz_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_div_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_div_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpz_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_add_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_add_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpz_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_sub_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_sub_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpz_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_cmp_z _MPFR_PROTO ((mpfr_srcptr, mpz_srcptr));
-__MPFR_DECLSPEC int mpfr_mul_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_mul_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpq_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_div_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_div_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpq_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_add_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_add_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpq_srcptr, mpfr_rnd_t));
-__MPFR_DECLSPEC int mpfr_sub_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
+__MPFR_DECLSPEC int mpfr_sub_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpq_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_cmp_q _MPFR_PROTO ((mpfr_srcptr, mpq_srcptr));
@@ -542,7 +542,7 @@ __MPFR_DECLSPEC int mpfr_sum _MPFR_PROTO ((mpfr_ptr, mpfr_ptr __gmp_const [],
__MPFR_DECLSPEC void mpfr_init_cache _MPFR_PROTO ((mpfr_cache_t,
int(*)(mpfr_ptr,mpfr_rnd_t)));
__MPFR_DECLSPEC void mpfr_clear_cache _MPFR_PROTO ((mpfr_cache_t));
-__MPFR_DECLSPEC int mpfr_cache _MPFR_PROTO ((mpfr_ptr, mpfr_cache_t,
+__MPFR_DECLSPEC int mpfr_cache _MPFR_PROTO ((mpfr_ptr, mpfr_cache_t,
mpfr_rnd_t));
__MPFR_DECLSPEC void mpfr_free_cache _MPFR_PROTO ((void));
@@ -567,12 +567,12 @@ __MPFR_DECLSPEC int mpfr_strtofr _MPFR_PROTO ((mpfr_ptr, __gmp_const char *,
#define __MPFR_EXP_INF ((mp_exp_t)((~((~(unsigned long)0)>>1))+3))
#endif
-#define MPFR_DECL_INIT(_x, _p) \
- mp_limb_t __gmpfr_local_tab_##_x[((_p)-1)/GMP_NUMB_BITS+1]; \
+#define MPFR_DECL_INIT(_x, _p) \
+ mp_limb_t __gmpfr_local_tab_##_x[((_p)-1)/GMP_NUMB_BITS+1]; \
mpfr_t _x = {{(_p),1,__MPFR_EXP_NAN,__gmpfr_local_tab_##_x}}
/* Fast access macros to replace function interface.
- If the USER don't want to use the macro interface, let him make happy
+ If the USER don't want to use the macro interface, let him make happy
even if it produces faster and smaller code. */
#ifndef MPFR_USE_NO_MACRO
@@ -621,12 +621,12 @@ __MPFR_DECLSPEC int mpfr_strtofr _MPFR_PROTO ((mpfr_ptr, __gmp_const char *,
(__builtin_constant_p (_u) && (_u) == 0 ? \
((_f)->_mpfr_sign = 1, \
(_f)->_mpfr_exp = __MPFR_EXP_ZERO, 0): \
- mpfr_set_ui (_f,_u,_r))
+ mpfr_set_ui (_f,_u,_r))
#undef mpfr_set_si
#define mpfr_set_si(_f,_s,_r) \
(__builtin_constant_p (_s) && (_s) >= 0 ? \
mpfr_set_ui ((_f), (_s), (_r)) : \
- mpfr_set_si ((_f), (_s), (_r)))
+ mpfr_set_si ((_f), (_s), (_r)))
#endif
#endif
diff --git a/tests/tconst_pi.c b/tests/tconst_pi.c
index f4a92da05..94796f798 100644
--- a/tests/tconst_pi.c
+++ b/tests/tconst_pi.c
@@ -44,8 +44,10 @@ check_large (void)
}
/* a worst-case to exercise recomputation */
- mpfr_set_prec (x, 33440);
- mpfr_const_pi (x, GMP_RNDZ);
+ if (MPFR_PREC_MAX > 33440) {
+ mpfr_set_prec (x, 33440);
+ mpfr_const_pi (x, GMP_RNDZ);
+ }
mpfr_clears (x, y, NULL);
}
diff --git a/tests/texp.c b/tests/texp.c
index 6b1295e53..62070404b 100644
--- a/tests/texp.c
+++ b/tests/texp.c
@@ -278,32 +278,34 @@ check_special ()
exit (1);
}
/* Check overflow. Corner case of mpfr_exp_3 */
- mpfr_set_prec (x, MPFR_EXP_THRESHOLD+10);
- mpfr_set_str (x,
- "0.1011000101110010000101111111010100001100000001110001100111001101E30",
- 2, GMP_RNDN);
- mpfr_clear_overflow ();
- mpfr_exp (x, x, GMP_RNDD);
- if (!mpfr_overflow_p ())
- {
- printf ("Wrong overflow detection in mpfr_exp_3\n");
- mpfr_dump (x);
- exit (1);
- }
- /* Check underflow. Corner case of mpfr_exp_3 */
- mpfr_set_str (x,
-"-0.1011000101110010000101111111011111010001110011110111100110101100E30",
- 2, GMP_RNDN);
- mpfr_clear_underflow ();
- mpfr_exp (x, x, GMP_RNDN);
- if (!mpfr_underflow_p ())
- {
- printf ("Wrong underflow detection in mpfr_exp_3\n");
- mpfr_dump (x);
- exit (1);
- }
- mpfr_set_prec (x, 53);
-
+ if (MPFR_PREC_MAX > MPFR_EXP_THRESHOLD+10) {
+ mpfr_set_prec (x, MPFR_EXP_THRESHOLD+10);
+ mpfr_set_str (x,
+ "0.1011000101110010000101111111010100001100000001110001100111001101E30",
+ 2, GMP_RNDN);
+ mpfr_clear_overflow ();
+ mpfr_exp (x, x, GMP_RNDD);
+ if (!mpfr_overflow_p ())
+ {
+ printf ("Wrong overflow detection in mpfr_exp_3\n");
+ mpfr_dump (x);
+ exit (1);
+ }
+ /* Check underflow. Corner case of mpfr_exp_3 */
+ mpfr_set_str (x,
+ "-0.1011000101110010000101111111011111010001110011110111100110101100E30",
+ 2, GMP_RNDN);
+ mpfr_clear_underflow ();
+ mpfr_exp (x, x, GMP_RNDN);
+ if (!mpfr_underflow_p ())
+ {
+ printf ("Wrong underflow detection in mpfr_exp_3\n");
+ mpfr_dump (x);
+ exit (1);
+ }
+ mpfr_set_prec (x, 53);
+ }
+
/* check overflow */
emax = mpfr_get_emax ();
set_emax (10);