wok annotate mpfr/stuff/mpfr-3.1.2-upstream_fixes-3.patch @ rev 19467

slitaz-i18n: give translations from yad-gtk2 package.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Tue Oct 25 01:31:43 2016 +0300 (2016-10-25)
parents
children
rev   line source
devl547@17581 1 Submitted By: Bruce Dubbs <bdubbs_at_linuxfromscratch_dot_org>
devl547@17581 2 Updated By: Armin K. <krejzi at email dot com>
devl547@17581 3 Date: 2015-02-06
devl547@17581 4 Initial Package Version: 3.1.2
devl547@17581 5 Upstream Status: Already in upstream patch repo
devl547@17581 6 Origin: Upstream
devl547@17581 7 Description: This patch contains patches for several bugs in MPFR.
devl547@17581 8 Note that the patch for configure.ac has been
devl547@17581 9 removed to prevent unneeded regeneration of build
devl547@17581 10 files.
devl547@17581 11 See http://www.mpfr.org/mpfr-current/allpatches
devl547@17581 12
devl547@17581 13 --- a/PATCHES 2013-03-13 16:37:38.000000000 +0100
devl547@17581 14 +++ b/PATCHES 2014-12-31 14:56:02.685641958 +0100
devl547@17581 15 @@ -0,0 +1,11 @@
devl547@17581 16 +strtofr
devl547@17581 17 +vasprintf
devl547@17581 18 +div-overflow
devl547@17581 19 +gmp6-compat
devl547@17581 20 +exp3
devl547@17581 21 +li2-return
devl547@17581 22 +custom_init_set
devl547@17581 23 +printf-alt0
devl547@17581 24 +clang-divby0
devl547@17581 25 +fits-smallneg
devl547@17581 26 +exp_2
devl547@17581 27 --- a/src/div.c 2013-03-13 16:37:33.000000000 +0100
devl547@17581 28 +++ b/src/div.c 2014-12-31 14:56:02.686641971 +0100
devl547@17581 29 @@ -750,7 +750,9 @@
devl547@17581 30 truncate_check_qh:
devl547@17581 31 if (qh)
devl547@17581 32 {
devl547@17581 33 - qexp ++;
devl547@17581 34 + if (MPFR_LIKELY (qexp < MPFR_EXP_MAX))
devl547@17581 35 + qexp ++;
devl547@17581 36 + /* else qexp is now incorrect, but one will still get an overflow */
devl547@17581 37 q0p[q0size - 1] = MPFR_LIMB_HIGHBIT;
devl547@17581 38 }
devl547@17581 39 goto truncate;
devl547@17581 40 @@ -765,7 +767,9 @@
devl547@17581 41 inex = 1; /* always here */
devl547@17581 42 if (mpn_add_1 (q0p, q0p, q0size, MPFR_LIMB_ONE << sh))
devl547@17581 43 {
devl547@17581 44 - qexp ++;
devl547@17581 45 + if (MPFR_LIKELY (qexp < MPFR_EXP_MAX))
devl547@17581 46 + qexp ++;
devl547@17581 47 + /* else qexp is now incorrect, but one will still get an overflow */
devl547@17581 48 q0p[q0size - 1] = MPFR_LIMB_HIGHBIT;
devl547@17581 49 }
devl547@17581 50
devl547@17581 51 --- a/src/exp_2.c 2013-03-13 16:37:28.000000000 +0100
devl547@17581 52 +++ b/src/exp_2.c 2014-12-31 14:56:02.686641971 +0100
devl547@17581 53 @@ -204,7 +204,7 @@
devl547@17581 54 for (k = 0; k < K; k++)
devl547@17581 55 {
devl547@17581 56 mpz_mul (ss, ss, ss);
devl547@17581 57 - exps <<= 1;
devl547@17581 58 + exps *= 2;
devl547@17581 59 exps += mpz_normalize (ss, ss, q);
devl547@17581 60 }
devl547@17581 61 mpfr_set_z (s, ss, MPFR_RNDN);
devl547@17581 62 --- a/src/exp3.c 2013-03-13 16:37:34.000000000 +0100
devl547@17581 63 +++ b/src/exp3.c 2014-12-31 14:56:02.686641971 +0100
devl547@17581 64 @@ -283,7 +283,7 @@
devl547@17581 65 }
devl547@17581 66 }
devl547@17581 67
devl547@17581 68 - if (mpfr_can_round (shift_x > 0 ? t : tmp, realprec, MPFR_RNDD, MPFR_RNDZ,
devl547@17581 69 + if (mpfr_can_round (shift_x > 0 ? t : tmp, realprec, MPFR_RNDN, MPFR_RNDZ,
devl547@17581 70 MPFR_PREC(y) + (rnd_mode == MPFR_RNDN)))
devl547@17581 71 {
devl547@17581 72 inexact = mpfr_set (y, shift_x > 0 ? t : tmp, rnd_mode);
devl547@17581 73 --- a/src/fits_u.h 2013-03-13 16:37:35.000000000 +0100
devl547@17581 74 +++ b/src/fits_u.h 2014-12-31 14:56:02.686641971 +0100
devl547@17581 75 @@ -32,17 +32,20 @@
devl547@17581 76 int res;
devl547@17581 77
devl547@17581 78 if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (f)))
devl547@17581 79 - /* Zero always fit */
devl547@17581 80 - return MPFR_IS_ZERO (f) ? 1 : 0;
devl547@17581 81 - else if (MPFR_IS_NEG (f))
devl547@17581 82 - /* Negative numbers don't fit */
devl547@17581 83 - return 0;
devl547@17581 84 - /* now it fits if
devl547@17581 85 - (a) f <= MAXIMUM
devl547@17581 86 - (b) round(f, prec(slong), rnd) <= MAXIMUM */
devl547@17581 87 + return MPFR_IS_ZERO (f) ? 1 : 0; /* Zero always fits */
devl547@17581 88
devl547@17581 89 e = MPFR_GET_EXP (f);
devl547@17581 90
devl547@17581 91 + if (MPFR_IS_NEG (f))
devl547@17581 92 + return e >= 1 ? 0 /* f <= -1 does not fit */
devl547@17581 93 + : rnd != MPFR_RNDN ? MPFR_IS_LIKE_RNDU (rnd, -1) /* directed mode */
devl547@17581 94 + : e < 0 ? 1 /* f > -1/2 fits in MPFR_RNDN */
devl547@17581 95 + : mpfr_powerof2_raw(f); /* -1/2 fits, -1 < f < -1/2 don't */
devl547@17581 96 +
devl547@17581 97 + /* Now it fits if
devl547@17581 98 + (a) f <= MAXIMUM
devl547@17581 99 + (b) round(f, prec(slong), rnd) <= MAXIMUM */
devl547@17581 100 +
devl547@17581 101 /* first compute prec(MAXIMUM); fits in an int */
devl547@17581 102 for (s = MAXIMUM, prec = 0; s != 0; s /= 2, prec ++);
devl547@17581 103
devl547@17581 104 --- a/src/fits_uintmax.c 2013-03-13 16:37:33.000000000 +0100
devl547@17581 105 +++ b/src/fits_uintmax.c 2014-12-31 14:56:02.686641971 +0100
devl547@17581 106 @@ -27,51 +27,19 @@
devl547@17581 107 #include "mpfr-intmax.h"
devl547@17581 108 #include "mpfr-impl.h"
devl547@17581 109
devl547@17581 110 -#ifdef _MPFR_H_HAVE_INTMAX_T
devl547@17581 111 -
devl547@17581 112 -/* We can't use fits_u.h <= mpfr_cmp_ui */
devl547@17581 113 -int
devl547@17581 114 -mpfr_fits_uintmax_p (mpfr_srcptr f, mpfr_rnd_t rnd)
devl547@17581 115 -{
devl547@17581 116 - mpfr_exp_t e;
devl547@17581 117 - int prec;
devl547@17581 118 - uintmax_t s;
devl547@17581 119 - mpfr_t x;
devl547@17581 120 - int res;
devl547@17581 121 -
devl547@17581 122 - if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (f)))
devl547@17581 123 - /* Zero always fit */
devl547@17581 124 - return MPFR_IS_ZERO (f) ? 1 : 0;
devl547@17581 125 - else if (MPFR_IS_NEG (f))
devl547@17581 126 - /* Negative numbers don't fit */
devl547@17581 127 - return 0;
devl547@17581 128 - /* now it fits if
devl547@17581 129 - (a) f <= MAXIMUM
devl547@17581 130 - (b) round(f, prec(slong), rnd) <= MAXIMUM */
devl547@17581 131 -
devl547@17581 132 - e = MPFR_GET_EXP (f);
devl547@17581 133 +/* Note: though mpfr-impl.h is included in fits_u.h, we also include it
devl547@17581 134 + above so that it gets included even when _MPFR_H_HAVE_INTMAX_T is not
devl547@17581 135 + defined; this is necessary to avoid an empty translation unit, which
devl547@17581 136 + is forbidden by ISO C. Without this, a failing test can be reproduced
devl547@17581 137 + by creating an invalid stdint.h somewhere in the default include path
devl547@17581 138 + and by compiling MPFR with "gcc -ansi -pedantic-errors". */
devl547@17581 139
devl547@17581 140 - /* first compute prec(MAXIMUM); fits in an int */
devl547@17581 141 - for (s = MPFR_UINTMAX_MAX, prec = 0; s != 0; s /= 2, prec ++);
devl547@17581 142 -
devl547@17581 143 - /* MAXIMUM needs prec bits, i.e. MAXIMUM = 2^prec - 1 */
devl547@17581 144 -
devl547@17581 145 - /* if e <= prec - 1, then f < 2^(prec-1) < MAXIMUM */
devl547@17581 146 - if (e <= prec - 1)
devl547@17581 147 - return 1;
devl547@17581 148 -
devl547@17581 149 - /* if e >= prec + 1, then f >= 2^prec > MAXIMUM */
devl547@17581 150 - if (e >= prec + 1)
devl547@17581 151 - return 0;
devl547@17581 152 +#ifdef _MPFR_H_HAVE_INTMAX_T
devl547@17581 153
devl547@17581 154 - MPFR_ASSERTD (e == prec);
devl547@17581 155 +#define FUNCTION mpfr_fits_uintmax_p
devl547@17581 156 +#define MAXIMUM MPFR_UINTMAX_MAX
devl547@17581 157 +#define TYPE uintmax_t
devl547@17581 158
devl547@17581 159 - /* hard case: first round to prec bits, then check */
devl547@17581 160 - mpfr_init2 (x, prec);
devl547@17581 161 - mpfr_set (x, f, rnd);
devl547@17581 162 - res = MPFR_GET_EXP (x) == e;
devl547@17581 163 - mpfr_clear (x);
devl547@17581 164 - return res;
devl547@17581 165 -}
devl547@17581 166 +#include "fits_u.h"
devl547@17581 167
devl547@17581 168 #endif
devl547@17581 169 --- a/src/init2.c 2013-03-13 16:37:32.000000000 +0100
devl547@17581 170 +++ b/src/init2.c 2014-12-31 14:56:02.686641971 +0100
devl547@17581 171 @@ -30,11 +30,11 @@
devl547@17581 172
devl547@17581 173 /* Check if we can represent the number of limbs
devl547@17581 174 * associated to the maximum of mpfr_prec_t*/
devl547@17581 175 - MPFR_ASSERTN( MP_SIZE_T_MAX >= (MPFR_PREC_MAX/BYTES_PER_MP_LIMB) );
devl547@17581 176 + MPFR_ASSERTN( MP_SIZE_T_MAX >= (MPFR_PREC_MAX/MPFR_BYTES_PER_MP_LIMB) );
devl547@17581 177
devl547@17581 178 - /* Check for correct GMP_NUMB_BITS and BYTES_PER_MP_LIMB */
devl547@17581 179 - MPFR_ASSERTN( GMP_NUMB_BITS == BYTES_PER_MP_LIMB * CHAR_BIT
devl547@17581 180 - && sizeof(mp_limb_t) == BYTES_PER_MP_LIMB );
devl547@17581 181 + /* Check for correct GMP_NUMB_BITS and MPFR_BYTES_PER_MP_LIMB */
devl547@17581 182 + MPFR_ASSERTN( GMP_NUMB_BITS == MPFR_BYTES_PER_MP_LIMB * CHAR_BIT
devl547@17581 183 + && sizeof(mp_limb_t) == MPFR_BYTES_PER_MP_LIMB );
devl547@17581 184
devl547@17581 185 MPFR_ASSERTN (mp_bits_per_limb == GMP_NUMB_BITS);
devl547@17581 186
devl547@17581 187 --- a/src/li2.c 2013-03-13 16:37:32.000000000 +0100
devl547@17581 188 +++ b/src/li2.c 2014-12-31 14:56:02.686641971 +0100
devl547@17581 189 @@ -630,5 +630,5 @@
devl547@17581 190 return mpfr_check_range (y, inexact, rnd_mode);
devl547@17581 191 }
devl547@17581 192
devl547@17581 193 - MPFR_ASSERTN (0); /* should never reach this point */
devl547@17581 194 + MPFR_RET_NEVER_GO_HERE ();
devl547@17581 195 }
devl547@17581 196 --- a/src/mpfr-gmp.h 2013-03-13 16:37:32.000000000 +0100
devl547@17581 197 +++ b/src/mpfr-gmp.h 2014-12-31 14:56:02.687641984 +0100
devl547@17581 198 @@ -72,7 +72,6 @@
devl547@17581 199 #endif
devl547@17581 200
devl547@17581 201 /* Define some macros */
devl547@17581 202 -#define BYTES_PER_MP_LIMB (GMP_NUMB_BITS/CHAR_BIT)
devl547@17581 203
devl547@17581 204 #define MP_LIMB_T_MAX (~(mp_limb_t)0)
devl547@17581 205
devl547@17581 206 @@ -96,19 +95,19 @@
devl547@17581 207 #define SHRT_HIGHBIT SHRT_MIN
devl547@17581 208
devl547@17581 209 /* MP_LIMB macros */
devl547@17581 210 -#define MPN_ZERO(dst, n) memset((dst), 0, (n)*BYTES_PER_MP_LIMB)
devl547@17581 211 -#define MPN_COPY_DECR(dst,src,n) memmove((dst),(src),(n)*BYTES_PER_MP_LIMB)
devl547@17581 212 -#define MPN_COPY_INCR(dst,src,n) memmove((dst),(src),(n)*BYTES_PER_MP_LIMB)
devl547@17581 213 +#define MPN_ZERO(dst, n) memset((dst), 0, (n)*MPFR_BYTES_PER_MP_LIMB)
devl547@17581 214 +#define MPN_COPY_DECR(dst,src,n) memmove((dst),(src),(n)*MPFR_BYTES_PER_MP_LIMB)
devl547@17581 215 +#define MPN_COPY_INCR(dst,src,n) memmove((dst),(src),(n)*MPFR_BYTES_PER_MP_LIMB)
devl547@17581 216 #define MPN_COPY(dst,src,n) \
devl547@17581 217 do \
devl547@17581 218 { \
devl547@17581 219 if ((dst) != (src)) \
devl547@17581 220 { \
devl547@17581 221 MPFR_ASSERTD ((char *) (dst) >= (char *) (src) + \
devl547@17581 222 - (n) * BYTES_PER_MP_LIMB || \
devl547@17581 223 + (n) * MPFR_BYTES_PER_MP_LIMB || \
devl547@17581 224 (char *) (src) >= (char *) (dst) + \
devl547@17581 225 - (n) * BYTES_PER_MP_LIMB); \
devl547@17581 226 - memcpy ((dst), (src), (n) * BYTES_PER_MP_LIMB); \
devl547@17581 227 + (n) * MPFR_BYTES_PER_MP_LIMB); \
devl547@17581 228 + memcpy ((dst), (src), (n) * MPFR_BYTES_PER_MP_LIMB); \
devl547@17581 229 } \
devl547@17581 230 } \
devl547@17581 231 while (0)
devl547@17581 232 --- a/src/mpfr.h 2013-03-13 16:37:37.000000000 +0100
devl547@17581 233 +++ b/src/mpfr.h 2014-12-31 14:56:02.687641984 +0100
devl547@17581 234 @@ -27,7 +27,7 @@
devl547@17581 235 #define MPFR_VERSION_MAJOR 3
devl547@17581 236 #define MPFR_VERSION_MINOR 1
devl547@17581 237 #define MPFR_VERSION_PATCHLEVEL 2
devl547@17581 238 -#define MPFR_VERSION_STRING "3.1.2"
devl547@17581 239 +#define MPFR_VERSION_STRING "3.1.2-p11"
devl547@17581 240
devl547@17581 241 /* Macros dealing with MPFR VERSION */
devl547@17581 242 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
devl547@17581 243 @@ -861,7 +861,7 @@
devl547@17581 244 _t = (mpfr_kind_t) _k; \
devl547@17581 245 _s = 1; \
devl547@17581 246 } else { \
devl547@17581 247 - _t = (mpfr_kind_t) -k; \
devl547@17581 248 + _t = (mpfr_kind_t) - _k; \
devl547@17581 249 _s = -1; \
devl547@17581 250 } \
devl547@17581 251 _e = _t == MPFR_REGULAR_KIND ? (e) : \
devl547@17581 252 --- a/src/mpfr-impl.h 2013-03-13 16:37:36.000000000 +0100
devl547@17581 253 +++ b/src/mpfr-impl.h 2014-12-31 14:56:02.687641984 +0100
devl547@17581 254 @@ -191,7 +191,7 @@
devl547@17581 255 # endif
devl547@17581 256 #endif
devl547@17581 257
devl547@17581 258 -
devl547@17581 259 +#define MPFR_BYTES_PER_MP_LIMB (GMP_NUMB_BITS/CHAR_BIT)
devl547@17581 260
devl547@17581 261 /******************************************************
devl547@17581 262 ******************** Check GMP ***********************
devl547@17581 263 @@ -468,8 +468,16 @@
devl547@17581 264 #define MPFR_LIMBS_PER_FLT ((IEEE_FLT_MANT_DIG-1)/GMP_NUMB_BITS+1)
devl547@17581 265
devl547@17581 266 /* Visual C++ doesn't support +1.0/0.0, -1.0/0.0 and 0.0/0.0
devl547@17581 267 - at compile time. */
devl547@17581 268 -#if defined(_MSC_VER) && defined(_WIN32) && (_MSC_VER >= 1200)
devl547@17581 269 + at compile time.
devl547@17581 270 + Clang with -fsanitize=undefined is a bit similar due to a bug:
devl547@17581 271 + http://llvm.org/bugs/show_bug.cgi?id=17381
devl547@17581 272 + but even without its sanitizer, it may be better to use the
devl547@17581 273 + double_zero version until IEEE 754 division by zero is properly
devl547@17581 274 + supported:
devl547@17581 275 + http://llvm.org/bugs/show_bug.cgi?id=17000
devl547@17581 276 +*/
devl547@17581 277 +#if (defined(_MSC_VER) && defined(_WIN32) && (_MSC_VER >= 1200)) || \
devl547@17581 278 + defined(__clang__)
devl547@17581 279 static double double_zero = 0.0;
devl547@17581 280 # define DBL_NAN (double_zero/double_zero)
devl547@17581 281 # define DBL_POS_INF ((double) 1.0/double_zero)
devl547@17581 282 @@ -501,6 +509,8 @@
devl547@17581 283 (with Xcode 2.4.1, i.e. the latest one). */
devl547@17581 284 #define LVALUE(x) (&(x) == &(x) || &(x) != &(x))
devl547@17581 285 #define DOUBLE_ISINF(x) (LVALUE(x) && ((x) > DBL_MAX || (x) < -DBL_MAX))
devl547@17581 286 +/* The DOUBLE_ISNAN(x) macro is also valid on long double x
devl547@17581 287 + (assuming that the compiler isn't too broken). */
devl547@17581 288 #ifdef MPFR_NANISNAN
devl547@17581 289 /* Avoid MIPSpro / IRIX64 / gcc -ffast-math (incorrect) optimizations.
devl547@17581 290 The + must not be replaced by a ||. With gcc -ffast-math, NaN is
devl547@17581 291 @@ -920,7 +930,7 @@
devl547@17581 292 #define MPFR_SET_ALLOC_SIZE(x, n) \
devl547@17581 293 ( ((mp_size_t*) MPFR_MANT(x))[-1] = n)
devl547@17581 294 #define MPFR_MALLOC_SIZE(s) \
devl547@17581 295 - ( sizeof(mpfr_size_limb_t) + BYTES_PER_MP_LIMB * ((size_t) s) )
devl547@17581 296 + ( sizeof(mpfr_size_limb_t) + MPFR_BYTES_PER_MP_LIMB * ((size_t) s) )
devl547@17581 297 #define MPFR_SET_MANT_PTR(x,p) \
devl547@17581 298 (MPFR_MANT(x) = (mp_limb_t*) ((mpfr_size_limb_t*) p + 1))
devl547@17581 299 #define MPFR_GET_REAL_PTR(x) \
devl547@17581 300 @@ -954,7 +964,7 @@
devl547@17581 301 #endif
devl547@17581 302
devl547@17581 303 #define MPFR_TMP_LIMBS_ALLOC(N) \
devl547@17581 304 - ((mp_limb_t *) MPFR_TMP_ALLOC ((size_t) (N) * BYTES_PER_MP_LIMB))
devl547@17581 305 + ((mp_limb_t *) MPFR_TMP_ALLOC ((size_t) (N) * MPFR_BYTES_PER_MP_LIMB))
devl547@17581 306
devl547@17581 307 /* temporary allocate 1 limb at xp, and initialize mpfr variable x */
devl547@17581 308 /* The temporary var doesn't have any size field, but it doesn't matter
devl547@17581 309 --- a/src/mul.c 2013-03-13 16:37:37.000000000 +0100
devl547@17581 310 +++ b/src/mul.c 2014-12-31 14:56:02.688641997 +0100
devl547@17581 311 @@ -106,7 +106,7 @@
devl547@17581 312 MPFR_ASSERTD(tn <= k);
devl547@17581 313
devl547@17581 314 /* Check for no size_t overflow*/
devl547@17581 315 - MPFR_ASSERTD((size_t) k <= ((size_t) -1) / BYTES_PER_MP_LIMB);
devl547@17581 316 + MPFR_ASSERTD((size_t) k <= ((size_t) -1) / MPFR_BYTES_PER_MP_LIMB);
devl547@17581 317 MPFR_TMP_MARK(marker);
devl547@17581 318 tmp = MPFR_TMP_LIMBS_ALLOC (k);
devl547@17581 319
devl547@17581 320 @@ -301,7 +301,7 @@
devl547@17581 321 MPFR_ASSERTD (tn <= k); /* tn <= k, thus no int overflow */
devl547@17581 322
devl547@17581 323 /* Check for no size_t overflow*/
devl547@17581 324 - MPFR_ASSERTD ((size_t) k <= ((size_t) -1) / BYTES_PER_MP_LIMB);
devl547@17581 325 + MPFR_ASSERTD ((size_t) k <= ((size_t) -1) / MPFR_BYTES_PER_MP_LIMB);
devl547@17581 326 MPFR_TMP_MARK (marker);
devl547@17581 327 tmp = MPFR_TMP_LIMBS_ALLOC (k);
devl547@17581 328
devl547@17581 329 --- a/src/stack_interface.c 2013-03-13 16:37:32.000000000 +0100
devl547@17581 330 +++ b/src/stack_interface.c 2014-12-31 14:56:02.688641997 +0100
devl547@17581 331 @@ -26,7 +26,7 @@
devl547@17581 332 size_t
devl547@17581 333 mpfr_custom_get_size (mpfr_prec_t prec)
devl547@17581 334 {
devl547@17581 335 - return MPFR_PREC2LIMBS (prec) * BYTES_PER_MP_LIMB;
devl547@17581 336 + return MPFR_PREC2LIMBS (prec) * MPFR_BYTES_PER_MP_LIMB;
devl547@17581 337 }
devl547@17581 338
devl547@17581 339 #undef mpfr_custom_init
devl547@17581 340 --- a/src/strtofr.c 2013-03-13 16:37:32.000000000 +0100
devl547@17581 341 +++ b/src/strtofr.c 2014-12-31 14:56:02.688641997 +0100
devl547@17581 342 @@ -473,8 +473,10 @@
devl547@17581 343 /* prec bits corresponds to ysize limbs */
devl547@17581 344 ysize_bits = ysize * GMP_NUMB_BITS;
devl547@17581 345 /* and to ysize_bits >= prec > MPFR_PREC (x) bits */
devl547@17581 346 - y = MPFR_TMP_LIMBS_ALLOC (2 * ysize + 1);
devl547@17581 347 - y += ysize; /* y has (ysize+1) allocated limbs */
devl547@17581 348 + /* we need to allocate one more limb to work around bug
devl547@17581 349 + https://gmplib.org/list-archives/gmp-bugs/2013-December/003267.html */
devl547@17581 350 + y = MPFR_TMP_LIMBS_ALLOC (2 * ysize + 2);
devl547@17581 351 + y += ysize; /* y has (ysize+2) allocated limbs */
devl547@17581 352
devl547@17581 353 /* pstr_size is the number of characters we read in pstr->mant
devl547@17581 354 to have at least ysize full limbs.
devl547@17581 355 --- a/src/vasprintf.c 2013-03-13 16:37:37.000000000 +0100
devl547@17581 356 +++ b/src/vasprintf.c 2014-12-31 14:56:02.688641997 +0100
devl547@17581 357 @@ -884,14 +884,18 @@
devl547@17581 358 first digit, we want the exponent for radix two and the decimal
devl547@17581 359 point AFTER the first digit. */
devl547@17581 360 {
devl547@17581 361 - MPFR_ASSERTN (exp > MPFR_EMIN_MIN /4); /* possible overflow */
devl547@17581 362 + /* An integer overflow is normally not possible since MPFR_EXP_MIN
devl547@17581 363 + is twice as large as MPFR_EMIN_MIN. */
devl547@17581 364 + MPFR_ASSERTN (exp > (MPFR_EXP_MIN + 3) / 4);
devl547@17581 365 exp = (exp - 1) * 4;
devl547@17581 366 }
devl547@17581 367 else
devl547@17581 368 /* EXP is the exponent for decimal point BEFORE the first digit, we
devl547@17581 369 want the exponent for decimal point AFTER the first digit. */
devl547@17581 370 {
devl547@17581 371 - MPFR_ASSERTN (exp > MPFR_EMIN_MIN); /* possible overflow */
devl547@17581 372 + /* An integer overflow is normally not possible since MPFR_EXP_MIN
devl547@17581 373 + is twice as large as MPFR_EMIN_MIN. */
devl547@17581 374 + MPFR_ASSERTN (exp > MPFR_EXP_MIN);
devl547@17581 375 --exp;
devl547@17581 376 }
devl547@17581 377 }
devl547@17581 378 @@ -1040,7 +1044,7 @@
devl547@17581 379 }
devl547@17581 380
devl547@17581 381 /* Determine the different parts of the string representation of the regular
devl547@17581 382 - number P when SPEC.SPEC is 'e', 'E', 'g', or 'G'.
devl547@17581 383 + number P when spec.spec is 'e', 'E', 'g', or 'G'.
devl547@17581 384 DEC_INFO contains the previously computed exponent and string or is NULL.
devl547@17581 385
devl547@17581 386 return -1 if some field > INT_MAX */
devl547@17581 387 @@ -1167,7 +1171,7 @@
devl547@17581 388 }
devl547@17581 389
devl547@17581 390 /* Determine the different parts of the string representation of the regular
devl547@17581 391 - number P when SPEC.SPEC is 'f', 'F', 'g', or 'G'.
devl547@17581 392 + number P when spec.spec is 'f', 'F', 'g', or 'G'.
devl547@17581 393 DEC_INFO contains the previously computed exponent and string or is NULL.
devl547@17581 394
devl547@17581 395 return -1 if some field of number_parts is greater than INT_MAX */
devl547@17581 396 @@ -1559,7 +1563,7 @@
devl547@17581 397 /* fractional part */
devl547@17581 398 {
devl547@17581 399 np->point = MPFR_DECIMAL_POINT;
devl547@17581 400 - np->fp_trailing_zeros = (spec.spec == 'g' && spec.spec == 'G') ?
devl547@17581 401 + np->fp_trailing_zeros = (spec.spec == 'g' || spec.spec == 'G') ?
devl547@17581 402 spec.prec - 1 : spec.prec;
devl547@17581 403 }
devl547@17581 404 else if (spec.alt)
devl547@17581 405 --- a/src/version.c 2013-03-13 16:37:34.000000000 +0100
devl547@17581 406 +++ b/src/version.c 2014-12-31 14:56:02.688641997 +0100
devl547@17581 407 @@ -25,5 +25,5 @@
devl547@17581 408 const char *
devl547@17581 409 mpfr_get_version (void)
devl547@17581 410 {
devl547@17581 411 - return "3.1.2";
devl547@17581 412 + return "3.1.2-p11";
devl547@17581 413 }
devl547@17581 414 --- a/tests/tdiv.c 2013-03-13 16:37:44.000000000 +0100
devl547@17581 415 +++ b/tests/tdiv.c 2014-12-31 14:56:02.689642010 +0100
devl547@17581 416 @@ -1104,6 +1104,96 @@
devl547@17581 417 #define RAND_FUNCTION(x) mpfr_random2(x, MPFR_LIMB_SIZE (x), randlimb () % 100, RANDS)
devl547@17581 418 #include "tgeneric.c"
devl547@17581 419
devl547@17581 420 +static void
devl547@17581 421 +test_extreme (void)
devl547@17581 422 +{
devl547@17581 423 + mpfr_t x, y, z;
devl547@17581 424 + mpfr_exp_t emin, emax;
devl547@17581 425 + mpfr_prec_t p[4] = { 8, 32, 64, 256 };
devl547@17581 426 + int xi, yi, zi, j, r;
devl547@17581 427 + unsigned int flags, ex_flags;
devl547@17581 428 +
devl547@17581 429 + emin = mpfr_get_emin ();
devl547@17581 430 + emax = mpfr_get_emax ();
devl547@17581 431 +
devl547@17581 432 + mpfr_set_emin (MPFR_EMIN_MIN);
devl547@17581 433 + mpfr_set_emax (MPFR_EMAX_MAX);
devl547@17581 434 +
devl547@17581 435 + for (xi = 0; xi < 4; xi++)
devl547@17581 436 + {
devl547@17581 437 + mpfr_init2 (x, p[xi]);
devl547@17581 438 + mpfr_setmax (x, MPFR_EMAX_MAX);
devl547@17581 439 + MPFR_ASSERTN (mpfr_check (x));
devl547@17581 440 + for (yi = 0; yi < 4; yi++)
devl547@17581 441 + {
devl547@17581 442 + mpfr_init2 (y, p[yi]);
devl547@17581 443 + mpfr_setmin (y, MPFR_EMIN_MIN);
devl547@17581 444 + for (j = 0; j < 2; j++)
devl547@17581 445 + {
devl547@17581 446 + MPFR_ASSERTN (mpfr_check (y));
devl547@17581 447 + for (zi = 0; zi < 4; zi++)
devl547@17581 448 + {
devl547@17581 449 + mpfr_init2 (z, p[zi]);
devl547@17581 450 + RND_LOOP (r)
devl547@17581 451 + {
devl547@17581 452 + mpfr_clear_flags ();
devl547@17581 453 + mpfr_div (z, x, y, (mpfr_rnd_t) r);
devl547@17581 454 + flags = __gmpfr_flags;
devl547@17581 455 + MPFR_ASSERTN (mpfr_check (z));
devl547@17581 456 + ex_flags = MPFR_FLAGS_OVERFLOW | MPFR_FLAGS_INEXACT;
devl547@17581 457 + if (flags != ex_flags)
devl547@17581 458 + {
devl547@17581 459 + printf ("Bad flags in test_extreme on z = a/b"
devl547@17581 460 + " with %s and\n",
devl547@17581 461 + mpfr_print_rnd_mode ((mpfr_rnd_t) r));
devl547@17581 462 + printf ("a = ");
devl547@17581 463 + mpfr_dump (x);
devl547@17581 464 + printf ("b = ");
devl547@17581 465 + mpfr_dump (y);
devl547@17581 466 + printf ("Expected flags:");
devl547@17581 467 + flags_out (ex_flags);
devl547@17581 468 + printf ("Got flags: ");
devl547@17581 469 + flags_out (flags);
devl547@17581 470 + printf ("z = ");
devl547@17581 471 + mpfr_dump (z);
devl547@17581 472 + exit (1);
devl547@17581 473 + }
devl547@17581 474 + mpfr_clear_flags ();
devl547@17581 475 + mpfr_div (z, y, x, (mpfr_rnd_t) r);
devl547@17581 476 + flags = __gmpfr_flags;
devl547@17581 477 + MPFR_ASSERTN (mpfr_check (z));
devl547@17581 478 + ex_flags = MPFR_FLAGS_UNDERFLOW | MPFR_FLAGS_INEXACT;
devl547@17581 479 + if (flags != ex_flags)
devl547@17581 480 + {
devl547@17581 481 + printf ("Bad flags in test_extreme on z = a/b"
devl547@17581 482 + " with %s and\n",
devl547@17581 483 + mpfr_print_rnd_mode ((mpfr_rnd_t) r));
devl547@17581 484 + printf ("a = ");
devl547@17581 485 + mpfr_dump (y);
devl547@17581 486 + printf ("b = ");
devl547@17581 487 + mpfr_dump (x);
devl547@17581 488 + printf ("Expected flags:");
devl547@17581 489 + flags_out (ex_flags);
devl547@17581 490 + printf ("Got flags: ");
devl547@17581 491 + flags_out (flags);
devl547@17581 492 + printf ("z = ");
devl547@17581 493 + mpfr_dump (z);
devl547@17581 494 + exit (1);
devl547@17581 495 + }
devl547@17581 496 + }
devl547@17581 497 + mpfr_clear (z);
devl547@17581 498 + } /* zi */
devl547@17581 499 + mpfr_nextabove (y);
devl547@17581 500 + } /* j */
devl547@17581 501 + mpfr_clear (y);
devl547@17581 502 + } /* yi */
devl547@17581 503 + mpfr_clear (x);
devl547@17581 504 + } /* xi */
devl547@17581 505 +
devl547@17581 506 + set_emin (emin);
devl547@17581 507 + set_emax (emax);
devl547@17581 508 +}
devl547@17581 509 +
devl547@17581 510 int
devl547@17581 511 main (int argc, char *argv[])
devl547@17581 512 {
devl547@17581 513 @@ -1130,6 +1220,7 @@
devl547@17581 514 test_20070603 ();
devl547@17581 515 test_20070628 ();
devl547@17581 516 test_generic (2, 800, 50);
devl547@17581 517 + test_extreme ();
devl547@17581 518
devl547@17581 519 tests_end_mpfr ();
devl547@17581 520 return 0;
devl547@17581 521 --- a/tests/texp.c 2013-03-13 16:37:44.000000000 +0100
devl547@17581 522 +++ b/tests/texp.c 2014-12-31 14:56:02.689642010 +0100
devl547@17581 523 @@ -150,6 +150,22 @@
devl547@17581 524 exit (1);
devl547@17581 525 }
devl547@17581 526
devl547@17581 527 + mpfr_set_prec (x, 118);
devl547@17581 528 + mpfr_set_str_binary (x, "0.1110010100011101010000111110011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E-86");
devl547@17581 529 + mpfr_set_prec (y, 118);
devl547@17581 530 + mpfr_exp_2 (y, x, MPFR_RNDU);
devl547@17581 531 + mpfr_exp_3 (x, x, MPFR_RNDU);
devl547@17581 532 + if (mpfr_cmp (x, y))
devl547@17581 533 + {
devl547@17581 534 + printf ("mpfr_exp_2 and mpfr_exp_3 differ for prec=118\n");
devl547@17581 535 + printf ("mpfr_exp_2 gives ");
devl547@17581 536 + mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
devl547@17581 537 + printf ("\nmpfr_exp_3 gives ");
devl547@17581 538 + mpfr_out_str (stdout, 2, 0, x, MPFR_RNDN);
devl547@17581 539 + printf ("\n");
devl547@17581 540 + exit (1);
devl547@17581 541 + }
devl547@17581 542 +
devl547@17581 543 mpfr_clear (x);
devl547@17581 544 mpfr_clear (y);
devl547@17581 545 return 0;
devl547@17581 546 --- a/tests/tfits.c 2013-03-13 16:37:45.000000000 +0100
devl547@17581 547 +++ b/tests/tfits.c 2014-12-31 14:56:02.689642010 +0100
devl547@17581 548 @@ -33,155 +33,176 @@
devl547@17581 549 #include "mpfr-intmax.h"
devl547@17581 550 #include "mpfr-test.h"
devl547@17581 551
devl547@17581 552 -#define ERROR1 { printf("Initial error for x="); mpfr_dump(x); exit(1); }
devl547@17581 553 -#define ERROR2 { printf("Error for x="); mpfr_dump(x); exit(1); }
devl547@17581 554 +#define ERROR1(N) \
devl547@17581 555 + do \
devl547@17581 556 + { \
devl547@17581 557 + printf("Error %d for rnd = %s and x = ", N, \
devl547@17581 558 + mpfr_print_rnd_mode ((mpfr_rnd_t) r)); \
devl547@17581 559 + mpfr_dump(x); \
devl547@17581 560 + exit(1); \
devl547@17581 561 + } \
devl547@17581 562 + while (0)
devl547@17581 563
devl547@17581 564 static void check_intmax (void);
devl547@17581 565
devl547@17581 566 int
devl547@17581 567 main (void)
devl547@17581 568 {
devl547@17581 569 - mpfr_t x;
devl547@17581 570 + mpfr_t x, y;
devl547@17581 571 + int i, r;
devl547@17581 572
devl547@17581 573 tests_start_mpfr ();
devl547@17581 574
devl547@17581 575 mpfr_init2 (x, 256);
devl547@17581 576 + mpfr_init2 (y, 8);
devl547@17581 577
devl547@17581 578 - /* Check NAN */
devl547@17581 579 - mpfr_set_nan (x);
devl547@17581 580 - if (mpfr_fits_ulong_p (x, MPFR_RNDN))
devl547@17581 581 - ERROR1;
devl547@17581 582 - if (mpfr_fits_slong_p (x, MPFR_RNDN))
devl547@17581 583 - ERROR1;
devl547@17581 584 - if (mpfr_fits_uint_p (x, MPFR_RNDN))
devl547@17581 585 - ERROR1;
devl547@17581 586 - if (mpfr_fits_sint_p (x, MPFR_RNDN))
devl547@17581 587 - ERROR1;
devl547@17581 588 - if (mpfr_fits_ushort_p (x, MPFR_RNDN))
devl547@17581 589 - ERROR1;
devl547@17581 590 - if (mpfr_fits_sshort_p (x, MPFR_RNDN))
devl547@17581 591 - ERROR1;
devl547@17581 592 -
devl547@17581 593 - /* Check INF */
devl547@17581 594 - mpfr_set_inf (x, 1);
devl547@17581 595 - if (mpfr_fits_ulong_p (x, MPFR_RNDN))
devl547@17581 596 - ERROR1;
devl547@17581 597 - if (mpfr_fits_slong_p (x, MPFR_RNDN))
devl547@17581 598 - ERROR1;
devl547@17581 599 - if (mpfr_fits_uint_p (x, MPFR_RNDN))
devl547@17581 600 - ERROR1;
devl547@17581 601 - if (mpfr_fits_sint_p (x, MPFR_RNDN))
devl547@17581 602 - ERROR1;
devl547@17581 603 - if (mpfr_fits_ushort_p (x, MPFR_RNDN))
devl547@17581 604 - ERROR1;
devl547@17581 605 - if (mpfr_fits_sshort_p (x, MPFR_RNDN))
devl547@17581 606 - ERROR1;
devl547@17581 607 -
devl547@17581 608 - /* Check Zero */
devl547@17581 609 - MPFR_SET_ZERO (x);
devl547@17581 610 - if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
devl547@17581 611 - ERROR2;
devl547@17581 612 - if (!mpfr_fits_slong_p (x, MPFR_RNDN))
devl547@17581 613 - ERROR2;
devl547@17581 614 - if (!mpfr_fits_uint_p (x, MPFR_RNDN))
devl547@17581 615 - ERROR2;
devl547@17581 616 - if (!mpfr_fits_sint_p (x, MPFR_RNDN))
devl547@17581 617 - ERROR2;
devl547@17581 618 - if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
devl547@17581 619 - ERROR2;
devl547@17581 620 - if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
devl547@17581 621 - ERROR2;
devl547@17581 622 -
devl547@17581 623 - /* Check small op */
devl547@17581 624 - mpfr_set_str1 (x, "1@-1");
devl547@17581 625 - if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
devl547@17581 626 - ERROR2;
devl547@17581 627 - if (!mpfr_fits_slong_p (x, MPFR_RNDN))
devl547@17581 628 - ERROR2;
devl547@17581 629 - if (!mpfr_fits_uint_p (x, MPFR_RNDN))
devl547@17581 630 - ERROR2;
devl547@17581 631 - if (!mpfr_fits_sint_p (x, MPFR_RNDN))
devl547@17581 632 - ERROR2;
devl547@17581 633 - if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
devl547@17581 634 - ERROR2;
devl547@17581 635 - if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
devl547@17581 636 - ERROR2;
devl547@17581 637 -
devl547@17581 638 - /* Check 17 */
devl547@17581 639 - mpfr_set_ui (x, 17, MPFR_RNDN);
devl547@17581 640 - if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
devl547@17581 641 - ERROR2;
devl547@17581 642 - if (!mpfr_fits_slong_p (x, MPFR_RNDN))
devl547@17581 643 - ERROR2;
devl547@17581 644 - if (!mpfr_fits_uint_p (x, MPFR_RNDN))
devl547@17581 645 - ERROR2;
devl547@17581 646 - if (!mpfr_fits_sint_p (x, MPFR_RNDN))
devl547@17581 647 - ERROR2;
devl547@17581 648 - if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
devl547@17581 649 - ERROR2;
devl547@17581 650 - if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
devl547@17581 651 - ERROR2;
devl547@17581 652 -
devl547@17581 653 - /* Check all other values */
devl547@17581 654 - mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
devl547@17581 655 - mpfr_mul_2exp (x, x, 1, MPFR_RNDN);
devl547@17581 656 - if (mpfr_fits_ulong_p (x, MPFR_RNDN))
devl547@17581 657 - ERROR1;
devl547@17581 658 - if (mpfr_fits_slong_p (x, MPFR_RNDN))
devl547@17581 659 - ERROR1;
devl547@17581 660 - mpfr_mul_2exp (x, x, 40, MPFR_RNDN);
devl547@17581 661 - if (mpfr_fits_ulong_p (x, MPFR_RNDN))
devl547@17581 662 - ERROR1;
devl547@17581 663 - if (mpfr_fits_uint_p (x, MPFR_RNDN))
devl547@17581 664 - ERROR1;
devl547@17581 665 - if (mpfr_fits_sint_p (x, MPFR_RNDN))
devl547@17581 666 - ERROR1;
devl547@17581 667 - if (mpfr_fits_ushort_p (x, MPFR_RNDN))
devl547@17581 668 - ERROR1;
devl547@17581 669 - if (mpfr_fits_sshort_p (x, MPFR_RNDN))
devl547@17581 670 - ERROR1;
devl547@17581 671 -
devl547@17581 672 - mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
devl547@17581 673 - if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
devl547@17581 674 - ERROR2;
devl547@17581 675 - mpfr_set_ui (x, LONG_MAX, MPFR_RNDN);
devl547@17581 676 - if (!mpfr_fits_slong_p (x, MPFR_RNDN))
devl547@17581 677 - ERROR2;
devl547@17581 678 - mpfr_set_ui (x, UINT_MAX, MPFR_RNDN);
devl547@17581 679 - if (!mpfr_fits_uint_p (x, MPFR_RNDN))
devl547@17581 680 - ERROR2;
devl547@17581 681 - mpfr_set_ui (x, INT_MAX, MPFR_RNDN);
devl547@17581 682 - if (!mpfr_fits_sint_p (x, MPFR_RNDN))
devl547@17581 683 - ERROR2;
devl547@17581 684 - mpfr_set_ui (x, USHRT_MAX, MPFR_RNDN);
devl547@17581 685 - if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
devl547@17581 686 - ERROR2;
devl547@17581 687 - mpfr_set_ui (x, SHRT_MAX, MPFR_RNDN);
devl547@17581 688 - if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
devl547@17581 689 - ERROR2;
devl547@17581 690 -
devl547@17581 691 - mpfr_set_si (x, 1, MPFR_RNDN);
devl547@17581 692 - if (!mpfr_fits_sint_p (x, MPFR_RNDN))
devl547@17581 693 - ERROR2;
devl547@17581 694 - if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
devl547@17581 695 - ERROR2;
devl547@17581 696 -
devl547@17581 697 - /* Check negative value */
devl547@17581 698 - mpfr_set_si (x, -1, MPFR_RNDN);
devl547@17581 699 - if (!mpfr_fits_sint_p (x, MPFR_RNDN))
devl547@17581 700 - ERROR2;
devl547@17581 701 - if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
devl547@17581 702 - ERROR2;
devl547@17581 703 - if (!mpfr_fits_slong_p (x, MPFR_RNDN))
devl547@17581 704 - ERROR2;
devl547@17581 705 - if (mpfr_fits_uint_p (x, MPFR_RNDN))
devl547@17581 706 - ERROR1;
devl547@17581 707 - if (mpfr_fits_ushort_p (x, MPFR_RNDN))
devl547@17581 708 - ERROR1;
devl547@17581 709 - if (mpfr_fits_ulong_p (x, MPFR_RNDN))
devl547@17581 710 - ERROR1;
devl547@17581 711 + RND_LOOP (r)
devl547@17581 712 + {
devl547@17581 713 +
devl547@17581 714 + /* Check NAN */
devl547@17581 715 + mpfr_set_nan (x);
devl547@17581 716 + if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
devl547@17581 717 + ERROR1 (1);
devl547@17581 718 + if (mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
devl547@17581 719 + ERROR1 (2);
devl547@17581 720 + if (mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
devl547@17581 721 + ERROR1 (3);
devl547@17581 722 + if (mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
devl547@17581 723 + ERROR1 (4);
devl547@17581 724 + if (mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
devl547@17581 725 + ERROR1 (5);
devl547@17581 726 + if (mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
devl547@17581 727 + ERROR1 (6);
devl547@17581 728 +
devl547@17581 729 + /* Check INF */
devl547@17581 730 + mpfr_set_inf (x, 1);
devl547@17581 731 + if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
devl547@17581 732 + ERROR1 (7);
devl547@17581 733 + if (mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
devl547@17581 734 + ERROR1 (8);
devl547@17581 735 + if (mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
devl547@17581 736 + ERROR1 (9);
devl547@17581 737 + if (mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
devl547@17581 738 + ERROR1 (10);
devl547@17581 739 + if (mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
devl547@17581 740 + ERROR1 (11);
devl547@17581 741 + if (mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
devl547@17581 742 + ERROR1 (12);
devl547@17581 743 +
devl547@17581 744 + /* Check Zero */
devl547@17581 745 + MPFR_SET_ZERO (x);
devl547@17581 746 + if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
devl547@17581 747 + ERROR1 (13);
devl547@17581 748 + if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
devl547@17581 749 + ERROR1 (14);
devl547@17581 750 + if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
devl547@17581 751 + ERROR1 (15);
devl547@17581 752 + if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
devl547@17581 753 + ERROR1 (16);
devl547@17581 754 + if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
devl547@17581 755 + ERROR1 (17);
devl547@17581 756 + if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
devl547@17581 757 + ERROR1 (18);
devl547@17581 758 +
devl547@17581 759 + /* Check small positive op */
devl547@17581 760 + mpfr_set_str1 (x, "1@-1");
devl547@17581 761 + if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
devl547@17581 762 + ERROR1 (19);
devl547@17581 763 + if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
devl547@17581 764 + ERROR1 (20);
devl547@17581 765 + if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
devl547@17581 766 + ERROR1 (21);
devl547@17581 767 + if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
devl547@17581 768 + ERROR1 (22);
devl547@17581 769 + if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
devl547@17581 770 + ERROR1 (23);
devl547@17581 771 + if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
devl547@17581 772 + ERROR1 (24);
devl547@17581 773 +
devl547@17581 774 + /* Check 17 */
devl547@17581 775 + mpfr_set_ui (x, 17, MPFR_RNDN);
devl547@17581 776 + if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
devl547@17581 777 + ERROR1 (25);
devl547@17581 778 + if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
devl547@17581 779 + ERROR1 (26);
devl547@17581 780 + if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
devl547@17581 781 + ERROR1 (27);
devl547@17581 782 + if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
devl547@17581 783 + ERROR1 (28);
devl547@17581 784 + if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
devl547@17581 785 + ERROR1 (29);
devl547@17581 786 + if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
devl547@17581 787 + ERROR1 (30);
devl547@17581 788 +
devl547@17581 789 + /* Check all other values */
devl547@17581 790 + mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
devl547@17581 791 + mpfr_mul_2exp (x, x, 1, MPFR_RNDN);
devl547@17581 792 + if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
devl547@17581 793 + ERROR1 (31);
devl547@17581 794 + if (mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
devl547@17581 795 + ERROR1 (32);
devl547@17581 796 + mpfr_mul_2exp (x, x, 40, MPFR_RNDN);
devl547@17581 797 + if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
devl547@17581 798 + ERROR1 (33);
devl547@17581 799 + if (mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
devl547@17581 800 + ERROR1 (34);
devl547@17581 801 + if (mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
devl547@17581 802 + ERROR1 (35);
devl547@17581 803 + if (mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
devl547@17581 804 + ERROR1 (36);
devl547@17581 805 + if (mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
devl547@17581 806 + ERROR1 (37);
devl547@17581 807 +
devl547@17581 808 + mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
devl547@17581 809 + if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
devl547@17581 810 + ERROR1 (38);
devl547@17581 811 + mpfr_set_ui (x, LONG_MAX, MPFR_RNDN);
devl547@17581 812 + if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
devl547@17581 813 + ERROR1 (39);
devl547@17581 814 + mpfr_set_ui (x, UINT_MAX, MPFR_RNDN);
devl547@17581 815 + if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
devl547@17581 816 + ERROR1 (40);
devl547@17581 817 + mpfr_set_ui (x, INT_MAX, MPFR_RNDN);
devl547@17581 818 + if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
devl547@17581 819 + ERROR1 (41);
devl547@17581 820 + mpfr_set_ui (x, USHRT_MAX, MPFR_RNDN);
devl547@17581 821 + if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
devl547@17581 822 + ERROR1 (42);
devl547@17581 823 + mpfr_set_ui (x, SHRT_MAX, MPFR_RNDN);
devl547@17581 824 + if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
devl547@17581 825 + ERROR1 (43);
devl547@17581 826 +
devl547@17581 827 + mpfr_set_si (x, 1, MPFR_RNDN);
devl547@17581 828 + if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
devl547@17581 829 + ERROR1 (44);
devl547@17581 830 + if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
devl547@17581 831 + ERROR1 (45);
devl547@17581 832 +
devl547@17581 833 + /* Check negative op */
devl547@17581 834 + for (i = 1; i <= 4; i++)
devl547@17581 835 + {
devl547@17581 836 + int inv;
devl547@17581 837 +
devl547@17581 838 + mpfr_set_si_2exp (x, -i, -2, MPFR_RNDN);
devl547@17581 839 + mpfr_rint (y, x, (mpfr_rnd_t) r);
devl547@17581 840 + inv = MPFR_NOTZERO (y);
devl547@17581 841 + if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r) ^ inv)
devl547@17581 842 + ERROR1 (46);
devl547@17581 843 + if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
devl547@17581 844 + ERROR1 (47);
devl547@17581 845 + if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r) ^ inv)
devl547@17581 846 + ERROR1 (48);
devl547@17581 847 + if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
devl547@17581 848 + ERROR1 (49);
devl547@17581 849 + if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r) ^ inv)
devl547@17581 850 + ERROR1 (50);
devl547@17581 851 + if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
devl547@17581 852 + ERROR1 (51);
devl547@17581 853 + }
devl547@17581 854 + }
devl547@17581 855
devl547@17581 856 mpfr_clear (x);
devl547@17581 857 + mpfr_clear (y);
devl547@17581 858
devl547@17581 859 check_intmax ();
devl547@17581 860
devl547@17581 861 @@ -189,85 +210,98 @@
devl547@17581 862 return 0;
devl547@17581 863 }
devl547@17581 864
devl547@17581 865 -static void check_intmax (void)
devl547@17581 866 +static void
devl547@17581 867 +check_intmax (void)
devl547@17581 868 {
devl547@17581 869 #ifdef _MPFR_H_HAVE_INTMAX_T
devl547@17581 870 - mpfr_t x;
devl547@17581 871 + mpfr_t x, y;
devl547@17581 872 + int i, r;
devl547@17581 873
devl547@17581 874 - mpfr_init2 (x, sizeof (uintmax_t)*CHAR_BIT);
devl547@17581 875 + mpfr_init2 (x, sizeof (uintmax_t) * CHAR_BIT);
devl547@17581 876 + mpfr_init2 (y, 8);
devl547@17581 877
devl547@17581 878 - /* Check NAN */
devl547@17581 879 - mpfr_set_nan (x);
devl547@17581 880 - if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
devl547@17581 881 - ERROR1;
devl547@17581 882 - if (mpfr_fits_intmax_p (x, MPFR_RNDN))
devl547@17581 883 - ERROR1;
devl547@17581 884 -
devl547@17581 885 - /* Check INF */
devl547@17581 886 - mpfr_set_inf (x, 1);
devl547@17581 887 - if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
devl547@17581 888 - ERROR1;
devl547@17581 889 - if (mpfr_fits_intmax_p (x, MPFR_RNDN))
devl547@17581 890 - ERROR1;
devl547@17581 891 -
devl547@17581 892 - /* Check Zero */
devl547@17581 893 - MPFR_SET_ZERO (x);
devl547@17581 894 - if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
devl547@17581 895 - ERROR2;
devl547@17581 896 - if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
devl547@17581 897 - ERROR2;
devl547@17581 898 -
devl547@17581 899 - /* Check small op */
devl547@17581 900 - mpfr_set_str1 (x, "1@-1");
devl547@17581 901 - if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
devl547@17581 902 - ERROR2;
devl547@17581 903 - if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
devl547@17581 904 - ERROR2;
devl547@17581 905 -
devl547@17581 906 - /* Check 17 */
devl547@17581 907 - mpfr_set_ui (x, 17, MPFR_RNDN);
devl547@17581 908 - if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
devl547@17581 909 - ERROR2;
devl547@17581 910 - if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
devl547@17581 911 - ERROR2;
devl547@17581 912 -
devl547@17581 913 - /* Check hugest */
devl547@17581 914 - mpfr_set_ui_2exp (x, 42, sizeof (uintmax_t) * 32, MPFR_RNDN);
devl547@17581 915 - if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
devl547@17581 916 - ERROR1;
devl547@17581 917 - if (mpfr_fits_intmax_p (x, MPFR_RNDN))
devl547@17581 918 - ERROR1;
devl547@17581 919 -
devl547@17581 920 - /* Check all other values */
devl547@17581 921 - mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
devl547@17581 922 - mpfr_add_ui (x, x, 1, MPFR_RNDN);
devl547@17581 923 - if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
devl547@17581 924 - ERROR1;
devl547@17581 925 - mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
devl547@17581 926 - if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
devl547@17581 927 - ERROR2;
devl547@17581 928 - mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
devl547@17581 929 - mpfr_add_ui (x, x, 1, MPFR_RNDN);
devl547@17581 930 - if (mpfr_fits_intmax_p (x, MPFR_RNDN))
devl547@17581 931 - ERROR1;
devl547@17581 932 - mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
devl547@17581 933 - if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
devl547@17581 934 - ERROR2;
devl547@17581 935 - mpfr_set_sj (x, MPFR_INTMAX_MIN, MPFR_RNDN);
devl547@17581 936 - if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
devl547@17581 937 - ERROR2;
devl547@17581 938 - mpfr_sub_ui (x, x, 1, MPFR_RNDN);
devl547@17581 939 - if (mpfr_fits_intmax_p (x, MPFR_RNDN))
devl547@17581 940 - ERROR1;
devl547@17581 941 -
devl547@17581 942 - /* Check negative value */
devl547@17581 943 - mpfr_set_si (x, -1, MPFR_RNDN);
devl547@17581 944 - if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
devl547@17581 945 - ERROR2;
devl547@17581 946 - if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
devl547@17581 947 - ERROR1;
devl547@17581 948 + RND_LOOP (r)
devl547@17581 949 + {
devl547@17581 950 + /* Check NAN */
devl547@17581 951 + mpfr_set_nan (x);
devl547@17581 952 + if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
devl547@17581 953 + ERROR1 (52);
devl547@17581 954 + if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
devl547@17581 955 + ERROR1 (53);
devl547@17581 956 +
devl547@17581 957 + /* Check INF */
devl547@17581 958 + mpfr_set_inf (x, 1);
devl547@17581 959 + if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
devl547@17581 960 + ERROR1 (54);
devl547@17581 961 + if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
devl547@17581 962 + ERROR1 (55);
devl547@17581 963 +
devl547@17581 964 + /* Check Zero */
devl547@17581 965 + MPFR_SET_ZERO (x);
devl547@17581 966 + if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
devl547@17581 967 + ERROR1 (56);
devl547@17581 968 + if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
devl547@17581 969 + ERROR1 (57);
devl547@17581 970 +
devl547@17581 971 + /* Check positive small op */
devl547@17581 972 + mpfr_set_str1 (x, "1@-1");
devl547@17581 973 + if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
devl547@17581 974 + ERROR1 (58);
devl547@17581 975 + if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
devl547@17581 976 + ERROR1 (59);
devl547@17581 977 +
devl547@17581 978 + /* Check 17 */
devl547@17581 979 + mpfr_set_ui (x, 17, MPFR_RNDN);
devl547@17581 980 + if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
devl547@17581 981 + ERROR1 (60);
devl547@17581 982 + if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
devl547@17581 983 + ERROR1 (61);
devl547@17581 984 +
devl547@17581 985 + /* Check hugest */
devl547@17581 986 + mpfr_set_ui_2exp (x, 42, sizeof (uintmax_t) * 32, MPFR_RNDN);
devl547@17581 987 + if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
devl547@17581 988 + ERROR1 (62);
devl547@17581 989 + if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
devl547@17581 990 + ERROR1 (63);
devl547@17581 991 +
devl547@17581 992 + /* Check all other values */
devl547@17581 993 + mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
devl547@17581 994 + mpfr_add_ui (x, x, 1, MPFR_RNDN);
devl547@17581 995 + if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
devl547@17581 996 + ERROR1 (64);
devl547@17581 997 + mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
devl547@17581 998 + if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
devl547@17581 999 + ERROR1 (65);
devl547@17581 1000 + mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
devl547@17581 1001 + mpfr_add_ui (x, x, 1, MPFR_RNDN);
devl547@17581 1002 + if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
devl547@17581 1003 + ERROR1 (66);
devl547@17581 1004 + mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
devl547@17581 1005 + if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
devl547@17581 1006 + ERROR1 (67);
devl547@17581 1007 + mpfr_set_sj (x, MPFR_INTMAX_MIN, MPFR_RNDN);
devl547@17581 1008 + if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
devl547@17581 1009 + ERROR1 (68);
devl547@17581 1010 + mpfr_sub_ui (x, x, 1, MPFR_RNDN);
devl547@17581 1011 + if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
devl547@17581 1012 + ERROR1 (69);
devl547@17581 1013 +
devl547@17581 1014 + /* Check negative op */
devl547@17581 1015 + for (i = 1; i <= 4; i++)
devl547@17581 1016 + {
devl547@17581 1017 + int inv;
devl547@17581 1018 +
devl547@17581 1019 + mpfr_set_si_2exp (x, -i, -2, MPFR_RNDN);
devl547@17581 1020 + mpfr_rint (y, x, (mpfr_rnd_t) r);
devl547@17581 1021 + inv = MPFR_NOTZERO (y);
devl547@17581 1022 + if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r) ^ inv)
devl547@17581 1023 + ERROR1 (70);
devl547@17581 1024 + if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
devl547@17581 1025 + ERROR1 (71);
devl547@17581 1026 + }
devl547@17581 1027 + }
devl547@17581 1028
devl547@17581 1029 mpfr_clear (x);
devl547@17581 1030 + mpfr_clear (y);
devl547@17581 1031 #endif
devl547@17581 1032 }
devl547@17581 1033 -
devl547@17581 1034 --- a/tests/tget_flt.c 2013-03-13 16:37:44.000000000 +0100
devl547@17581 1035 +++ b/tests/tget_flt.c 2014-12-31 14:56:02.690642023 +0100
devl547@17581 1036 @@ -28,9 +28,17 @@
devl547@17581 1037 main (void)
devl547@17581 1038 {
devl547@17581 1039 mpfr_t x, y;
devl547@17581 1040 - float f, g, infp;
devl547@17581 1041 + float f, g;
devl547@17581 1042 int i;
devl547@17581 1043 +#if !defined(MPFR_ERRDIVZERO)
devl547@17581 1044 + float infp;
devl547@17581 1045 +#endif
devl547@17581 1046
devl547@17581 1047 + tests_start_mpfr ();
devl547@17581 1048 +
devl547@17581 1049 +#if !defined(MPFR_ERRDIVZERO)
devl547@17581 1050 + /* The definition of DBL_POS_INF involves a division by 0. This makes
devl547@17581 1051 + "clang -O2 -fsanitize=undefined -fno-sanitize-recover" fail. */
devl547@17581 1052 infp = (float) DBL_POS_INF;
devl547@17581 1053 if (infp * 0.5 != infp)
devl547@17581 1054 {
devl547@17581 1055 @@ -38,8 +46,7 @@
devl547@17581 1056 fprintf (stderr, "(this is probably a compiler bug, please report)\n");
devl547@17581 1057 exit (1);
devl547@17581 1058 }
devl547@17581 1059 -
devl547@17581 1060 - tests_start_mpfr ();
devl547@17581 1061 +#endif
devl547@17581 1062
devl547@17581 1063 mpfr_init2 (x, 24);
devl547@17581 1064 mpfr_init2 (y, 24);
devl547@17581 1065 @@ -353,6 +360,7 @@
devl547@17581 1066 printf ("expected %.8e, got %.8e\n", g, f);
devl547@17581 1067 exit (1);
devl547@17581 1068 }
devl547@17581 1069 +#if !defined(MPFR_ERRDIVZERO)
devl547@17581 1070 f = mpfr_get_flt (x, MPFR_RNDN); /* first round to 2^128 (even rule),
devl547@17581 1071 thus we should get +Inf */
devl547@17581 1072 g = infp;
devl547@17581 1073 @@ -376,6 +384,7 @@
devl547@17581 1074 printf ("expected %.8e, got %.8e\n", g, f);
devl547@17581 1075 exit (1);
devl547@17581 1076 }
devl547@17581 1077 +#endif
devl547@17581 1078
devl547@17581 1079 mpfr_clear (x);
devl547@17581 1080 mpfr_clear (y);
devl547@17581 1081 --- a/tests/tset_ld.c 2013-03-13 16:37:44.000000000 +0100
devl547@17581 1082 +++ b/tests/tset_ld.c 2014-12-31 14:56:02.690642023 +0100
devl547@17581 1083 @@ -47,8 +47,11 @@
devl547@17581 1084 static int
devl547@17581 1085 Isnan_ld (long double d)
devl547@17581 1086 {
devl547@17581 1087 - double e = (double) d;
devl547@17581 1088 - if (DOUBLE_ISNAN (e))
devl547@17581 1089 + /* Do not convert d to double as this can give an overflow, which
devl547@17581 1090 + may confuse compilers without IEEE 754 support (such as clang
devl547@17581 1091 + -fsanitize=undefined), or trigger a trap if enabled.
devl547@17581 1092 + The DOUBLE_ISNAN macro should work fine on long double. */
devl547@17581 1093 + if (DOUBLE_ISNAN (d))
devl547@17581 1094 return 1;
devl547@17581 1095 LONGDOUBLE_NAN_ACTION (d, goto yes);
devl547@17581 1096 return 0;
devl547@17581 1097 --- a/tests/tsprintf.c 2013-03-13 16:37:44.000000000 +0100
devl547@17581 1098 +++ b/tests/tsprintf.c 2014-12-31 14:56:02.690642023 +0100
devl547@17581 1099 @@ -456,10 +456,16 @@
devl547@17581 1100 check_sprintf ("1.999900 ", "%-#10.7RG", x);
devl547@17581 1101 check_sprintf ("1.9999 ", "%-10.7RG", x);
devl547@17581 1102 mpfr_set_ui (x, 1, MPFR_RNDN);
devl547@17581 1103 + check_sprintf ("1.", "%#.1Rg", x);
devl547@17581 1104 + check_sprintf ("1. ", "%-#5.1Rg", x);
devl547@17581 1105 + check_sprintf (" 1.0", "%#5.2Rg", x);
devl547@17581 1106 check_sprintf ("1.00000000000000000000000000000", "%#.30Rg", x);
devl547@17581 1107 check_sprintf ("1", "%.30Rg", x);
devl547@17581 1108 mpfr_set_ui (x, 0, MPFR_RNDN);
devl547@17581 1109 - check_sprintf ("0.000000000000000000000000000000", "%#.30Rg", x);
devl547@17581 1110 + check_sprintf ("0.", "%#.1Rg", x);
devl547@17581 1111 + check_sprintf ("0. ", "%-#5.1Rg", x);
devl547@17581 1112 + check_sprintf (" 0.0", "%#5.2Rg", x);
devl547@17581 1113 + check_sprintf ("0.00000000000000000000000000000", "%#.30Rg", x);
devl547@17581 1114 check_sprintf ("0", "%.30Rg", x);
devl547@17581 1115
devl547@17581 1116 /* following tests with precision 53 bits */
devl547@17581 1117 @@ -1178,6 +1184,69 @@
devl547@17581 1118 check_emax_aux (MPFR_EMAX_MAX);
devl547@17581 1119 }
devl547@17581 1120
devl547@17581 1121 +static void
devl547@17581 1122 +check_emin_aux (mpfr_exp_t e)
devl547@17581 1123 +{
devl547@17581 1124 + mpfr_t x;
devl547@17581 1125 + char *s1, s2[256];
devl547@17581 1126 + int i;
devl547@17581 1127 + mpfr_exp_t emin;
devl547@17581 1128 + mpz_t ee;
devl547@17581 1129 +
devl547@17581 1130 + MPFR_ASSERTN (e >= LONG_MIN);
devl547@17581 1131 + emin = mpfr_get_emin ();
devl547@17581 1132 + set_emin (e);
devl547@17581 1133 +
devl547@17581 1134 + mpfr_init2 (x, 16);
devl547@17581 1135 + mpz_init (ee);
devl547@17581 1136 +
devl547@17581 1137 + mpfr_setmin (x, e);
devl547@17581 1138 + mpz_set_si (ee, e);
devl547@17581 1139 + mpz_sub_ui (ee, ee, 1);
devl547@17581 1140 +
devl547@17581 1141 + i = mpfr_asprintf (&s1, "%Ra", x);
devl547@17581 1142 + MPFR_ASSERTN (i > 0);
devl547@17581 1143 +
devl547@17581 1144 + gmp_snprintf (s2, 256, "0x1p%Zd", ee);
devl547@17581 1145 +
devl547@17581 1146 + if (strcmp (s1, s2) != 0)
devl547@17581 1147 + {
devl547@17581 1148 + printf ("Error in check_emin_aux for emin = %ld\n", (long) e);
devl547@17581 1149 + printf ("Expected %s\n", s2);
devl547@17581 1150 + printf ("Got %s\n", s1);
devl547@17581 1151 + exit (1);
devl547@17581 1152 + }
devl547@17581 1153 +
devl547@17581 1154 + mpfr_free_str (s1);
devl547@17581 1155 +
devl547@17581 1156 + i = mpfr_asprintf (&s1, "%Rb", x);
devl547@17581 1157 + MPFR_ASSERTN (i > 0);
devl547@17581 1158 +
devl547@17581 1159 + gmp_snprintf (s2, 256, "1p%Zd", ee);
devl547@17581 1160 +
devl547@17581 1161 + if (strcmp (s1, s2) != 0)
devl547@17581 1162 + {
devl547@17581 1163 + printf ("Error in check_emin_aux for emin = %ld\n", (long) e);
devl547@17581 1164 + printf ("Expected %s\n", s2);
devl547@17581 1165 + printf ("Got %s\n", s1);
devl547@17581 1166 + exit (1);
devl547@17581 1167 + }
devl547@17581 1168 +
devl547@17581 1169 + mpfr_free_str (s1);
devl547@17581 1170 +
devl547@17581 1171 + mpfr_clear (x);
devl547@17581 1172 + mpz_clear (ee);
devl547@17581 1173 + set_emin (emin);
devl547@17581 1174 +}
devl547@17581 1175 +
devl547@17581 1176 +static void
devl547@17581 1177 +check_emin (void)
devl547@17581 1178 +{
devl547@17581 1179 + check_emin_aux (-15);
devl547@17581 1180 + check_emin_aux (mpfr_get_emin ());
devl547@17581 1181 + check_emin_aux (MPFR_EMIN_MIN);
devl547@17581 1182 +}
devl547@17581 1183 +
devl547@17581 1184 int
devl547@17581 1185 main (int argc, char **argv)
devl547@17581 1186 {
devl547@17581 1187 @@ -1197,6 +1266,7 @@
devl547@17581 1188 decimal ();
devl547@17581 1189 mixed ();
devl547@17581 1190 check_emax ();
devl547@17581 1191 + check_emin ();
devl547@17581 1192
devl547@17581 1193 #if defined(HAVE_LOCALE_H) && defined(HAVE_SETLOCALE)
devl547@17581 1194 locale_da_DK ();
devl547@17581 1195 --- a/VERSION 2013-03-13 16:37:28.000000000 +0100
devl547@17581 1196 +++ b/VERSION 2014-12-31 14:56:02.690642023 +0100
devl547@17581 1197 @@ -1 +1 @@
devl547@17581 1198 -3.1.2
devl547@17581 1199 +3.1.2-p11