1 Submitted By: Bruce Dubbs <bdubbs_at_linuxfromscratch_dot_org>
3 Initial Package Version: 3.3.3
4 Upstream Status: Already in upstream patch repo
5 Origin: Upstream http://www.mpfr.org/mpfr-current/allpatches
7 Description: This patch contains bug fixes identified upstream.
9 diff -Naurd mpfr-3.1.3-a/PATCHES mpfr-3.1.3-b/PATCHES
10 --- mpfr-3.1.3-a/PATCHES 2015-07-02 10:49:23.950112879 +0000
11 +++ mpfr-3.1.3-b/PATCHES 2015-07-02 10:49:24.042113845 +0000
14 diff -Naurd mpfr-3.1.3-a/VERSION mpfr-3.1.3-b/VERSION
15 --- mpfr-3.1.3-a/VERSION 2015-06-19 19:55:09.000000000 +0000
16 +++ mpfr-3.1.3-b/VERSION 2015-07-02 10:49:24.042113845 +0000
20 diff -Naurd mpfr-3.1.3-a/doc/mpfr.texi mpfr-3.1.3-b/doc/mpfr.texi
21 --- mpfr-3.1.3-a/doc/mpfr.texi 2015-06-19 19:55:11.000000000 +0000
22 +++ mpfr-3.1.3-b/doc/mpfr.texi 2015-07-02 10:49:24.018113593 +0000
24 When the input point is in the closure of the domain of the mathematical
25 function and an input argument is +0 (resp.@: @minus{}0), one considers
26 the limit when the corresponding argument approaches 0 from above
27 -(resp.@: below). If the limit is not defined (e.g., @code{mpfr_log} on
28 -@minus{}0), the behavior is specified in the description of the MPFR function.
29 +(resp.@: below), if possible. If the limit is not defined (e.g.,
30 +@code{mpfr_sqrt} and @code{mpfr_log} on @minus{}0), the behavior is
31 +specified in the description of the MPFR function, but must be consistent
32 +with the rule from the above paragraph (e.g., @code{mpfr_log} on @pom{}0
35 When the result is equal to 0, its sign is determined by considering the
36 limit as if the input point were not in the domain: If one approaches 0
37 from above (resp.@: below), the result is +0 (resp.@: @minus{}0);
38 -for example, @code{mpfr_sin} on +0 gives +0.
39 +for example, @code{mpfr_sin} on @minus{}0 gives @minus{}0 and
40 +@code{mpfr_acos} on 1 gives +0 (in all rounding modes).
41 In the other cases, the sign is specified in the description of the MPFR
42 function; for example @code{mpfr_max} on @minus{}0 and +0 gives +0.
45 @c that advantages in practice), like for any bug fix.
46 Example: @code{mpfr_hypot} on (NaN,0) gives NaN, but @code{mpfr_hypot}
47 on (NaN,+Inf) gives +Inf (as specified in @ref{Special Functions}),
48 -since for any finite input @var{x}, @code{mpfr_hypot} on (@var{x},+Inf)
50 +since for any finite or infinite input @var{x}, @code{mpfr_hypot} on
51 +(@var{x},+Inf) gives +Inf.
53 @node Exceptions, Memory Handling, Floating-Point Values on Special Numbers, MPFR Basics
54 @comment node-name, next, previous, up
56 @deftypefunx int mpfr_add_z (mpfr_t @var{rop}, mpfr_t @var{op1}, mpz_t @var{op2}, mpfr_rnd_t @var{rnd})
57 @deftypefunx int mpfr_add_q (mpfr_t @var{rop}, mpfr_t @var{op1}, mpq_t @var{op2}, mpfr_rnd_t @var{rnd})
58 Set @var{rop} to @math{@var{op1} + @var{op2}} rounded in the direction
59 -@var{rnd}. For types having no signed zero, it is considered unsigned
60 +@var{rnd}. The IEEE-754 rules are used, in particular for signed zeros.
61 +But for types having no signed zeros, 0 is considered unsigned
62 (i.e., (+0) + 0 = (+0) and (@minus{}0) + 0 = (@minus{}0)).
63 The @code{mpfr_add_d} function assumes that the radix of the @code{double} type
64 is a power of 2, with a precision at most that declared by the C implementation
66 @deftypefunx int mpfr_sub_z (mpfr_t @var{rop}, mpfr_t @var{op1}, mpz_t @var{op2}, mpfr_rnd_t @var{rnd})
67 @deftypefunx int mpfr_sub_q (mpfr_t @var{rop}, mpfr_t @var{op1}, mpq_t @var{op2}, mpfr_rnd_t @var{rnd})
68 Set @var{rop} to @math{@var{op1} - @var{op2}} rounded in the direction
69 -@var{rnd}. For types having no signed zero, it is considered unsigned
70 +@var{rnd}. The IEEE-754 rules are used, in particular for signed zeros.
71 +But for types having no signed zeros, 0 is considered unsigned
72 (i.e., (+0) @minus{} 0 = (+0), (@minus{}0) @minus{} 0 = (@minus{}0),
73 0 @minus{} (+0) = (@minus{}0) and 0 @minus{} (@minus{}0) = (+0)).
74 The same restrictions than for @code{mpfr_add_d} apply to @code{mpfr_d_sub}
76 Set @var{rop} to @math{@var{op1} @GMPtimes{} @var{op2}} rounded in the
78 When a result is zero, its sign is the product of the signs of the operands
79 -(for types having no signed zero, it is considered positive).
80 +(for types having no signed zeros, 0 is considered positive).
81 The same restrictions than for @code{mpfr_add_d} apply to @code{mpfr_mul_d}.
85 @deftypefunx int mpfr_div_q (mpfr_t @var{rop}, mpfr_t @var{op1}, mpq_t @var{op2}, mpfr_rnd_t @var{rnd})
86 Set @var{rop} to @math{@var{op1}/@var{op2}} rounded in the direction @var{rnd}.
87 When a result is zero, its sign is the product of the signs of the operands
88 -(for types having no signed zero, it is considered positive).
89 +(for types having no signed zeros, 0 is considered positive).
90 The same restrictions than for @code{mpfr_add_d} apply to @code{mpfr_d_div}
91 and @code{mpfr_div_d}.
93 @@ -1643,15 +1649,18 @@
94 @deftypefun int mpfr_sqrt (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd})
95 @deftypefunx int mpfr_sqrt_ui (mpfr_t @var{rop}, unsigned long int @var{op}, mpfr_rnd_t @var{rnd})
96 Set @var{rop} to @m{\sqrt{@var{op}}, the square root of @var{op}}
97 -rounded in the direction @var{rnd} (set @var{rop} to @minus{}0 if @var{op} is
98 -@minus{}0, to be consistent with the IEEE 754 standard).
99 +rounded in the direction @var{rnd}. Set @var{rop} to @minus{}0 if
100 +@var{op} is @minus{}0, to be consistent with the IEEE 754 standard.
101 Set @var{rop} to NaN if @var{op} is negative.
104 @deftypefun int mpfr_rec_sqrt (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd})
105 Set @var{rop} to @m{1/\sqrt{@var{op}}, the reciprocal square root of @var{op}}
106 -rounded in the direction @var{rnd}. Set @var{rop} to +Inf if @var{op} is
107 -@pom{}0, +0 if @var{op} is +Inf, and NaN if @var{op} is negative.
108 +rounded in the direction @var{rnd}. Set @var{rop} to +Inf if @var{op} is
109 +@pom{}0, +0 if @var{op} is +Inf, and NaN if @var{op} is negative. Warning!
110 +Therefore the result on @minus{}0 is different from the one of the rSqrt
111 +function recommended by the IEEE 754-2008 standard (Section 9.2.1), which
112 +is @minus{}Inf instead of +Inf.
115 @deftypefun int mpfr_cbrt (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd})
116 @@ -1832,7 +1841,9 @@
117 @m{\log_2 @var{op}, log2(@var{op})} or
118 @m{\log_{10} @var{op}, log10(@var{op})}, respectively,
119 rounded in the direction @var{rnd}.
120 -Set @var{rop} to @minus{}Inf if @var{op} is @minus{}0
121 +Set @var{rop} to +0 if @var{op} is 1 (in all rounding modes),
122 +for consistency with the ISO C99 and IEEE 754-2008 standards.
123 +Set @var{rop} to @minus{}Inf if @var{op} is @pom{}0
124 (i.e., the sign of the zero has no influence on the result).
127 @@ -2003,8 +2014,11 @@
128 @deftypefun int mpfr_lngamma (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd})
129 Set @var{rop} to the value of the logarithm of the Gamma function on @var{op},
130 rounded in the direction @var{rnd}.
131 -When @math{@minus{}2@var{k}@minus{}1 @le{} @var{op} @le{} @minus{}2@var{k}},
132 -@var{k} being a non-negative integer, @var{rop} is set to NaN.
133 +When @var{op} is 1 or 2, set @var{rop} to +0 (in all rounding modes).
134 +When @var{op} is an infinity or a nonpositive integer, set @var{rop} to +Inf,
135 +following the general rules on special values.
136 +When @math{@minus{}2@var{k}@minus{}1 < @var{op} < @minus{}2@var{k}},
137 +@var{k} being a nonnegative integer, set @var{rop} to NaN@.
138 See also @code{mpfr_lgamma}.
141 @@ -2012,10 +2026,11 @@
142 Set @var{rop} to the value of the logarithm of the absolute value of the
143 Gamma function on @var{op}, rounded in the direction @var{rnd}. The sign
144 (1 or @minus{}1) of Gamma(@var{op}) is returned in the object pointed to
145 -by @var{signp}. When @var{op} is an infinity or a non-positive integer, set
146 -@var{rop} to +Inf. When @var{op} is NaN, @minus{}Inf or a negative integer,
147 -*@var{signp} is undefined, and when @var{op} is @pom{}0, *@var{signp} is
148 -the sign of the zero.
150 +When @var{op} is 1 or 2, set @var{rop} to +0 (in all rounding modes).
151 +When @var{op} is an infinity or a nonpositive integer, set @var{rop} to +Inf.
152 +When @var{op} is NaN, @minus{}Inf or a negative integer, *@var{signp} is
153 +undefined, and when @var{op} is @pom{}0, *@var{signp} is the sign of the zero.
156 @deftypefun int mpfr_digamma (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd})
157 @@ -2064,7 +2079,10 @@
158 @deftypefunx int mpfr_fms (mpfr_t @var{rop}, mpfr_t @var{op1}, mpfr_t @var{op2}, mpfr_t @var{op3}, mpfr_rnd_t @var{rnd})
159 Set @var{rop} to @math{(@var{op1} @GMPtimes{} @var{op2}) + @var{op3}}
160 (resp.@: @math{(@var{op1} @GMPtimes{} @var{op2}) - @var{op3}})
161 -rounded in the direction @var{rnd}.
162 +rounded in the direction @var{rnd}. Concerning special values (signed zeros,
163 +infinities, NaN), these functions behave like a multiplication followed by a
164 +separate addition or subtraction. That is, the fused operation matters only
168 @deftypefun int mpfr_agm (mpfr_t @var{rop}, mpfr_t @var{op1}, mpfr_t @var{op2}, mpfr_rnd_t @var{rnd})
169 @@ -2089,8 +2107,8 @@
170 i.e., $\sqrt{x^2+y^2}$,
172 rounded in the direction @var{rnd}.
173 -Special values are handled as described in Section F.9.4.3 of
174 -the ISO C99 and IEEE 754-2008 standards:
175 +Special values are handled as described in the ISO C99 (Section F.9.4.3)
176 +and IEEE 754-2008 (Section 9.2.1) standards:
177 If @var{x} or @var{y} is an infinity, then +Inf is returned in @var{rop},
178 even if the other number is NaN.
180 diff -Naurd mpfr-3.1.3-a/doc/mpfr.info mpfr-3.1.3-b/doc/mpfr.info
181 --- mpfr-3.1.3-a/doc/mpfr.info 2015-06-19 19:55:53.000000000 +0000
182 +++ mpfr-3.1.3-b/doc/mpfr.info 2015-07-02 10:49:38.718267817 +0000
184 -This is mpfr.info, produced by makeinfo version 5.2 from mpfr.texi.
185 +This is mpfr.info, produced by makeinfo version 6.0 from mpfr.texi.
187 This manual documents how to install and use the Multiple Precision
188 Floating-Point Reliable Library, version 3.1.3.
190 MPFR Copying Conditions
191 ***********************
193 -The GNU MPFR library (or MPFR for short) is "free"; this means that
194 +The GNU MPFR library (or MPFR for short) is “free”; this means that
195 everyone is free to use it and free to redistribute it on a free basis.
196 The library is not in the public domain; it is copyrighted and there are
197 restrictions on its distribution, but these restrictions are designed to
199 4.2 Nomenclature and Types
200 ==========================
202 -A "floating-point number", or "float" for short, is an arbitrary
203 +A “floating-point number”, or “float” for short, is an arbitrary
204 precision significand (also called mantissa) with a limited precision
205 exponent. The C data type for such objects is ‘mpfr_t’ (internally
206 defined as a one-element array of a structure, and ‘mpfr_ptr’ is the C
208 to the other functions supported by MPFR. Unless documented otherwise,
209 the sign bit of a NaN is unspecified.
211 -The "precision" is the number of bits used to represent the significand
212 +The “precision” is the number of bits used to represent the significand
213 of a floating-point number; the corresponding C data type is
214 ‘mpfr_prec_t’. The precision can be any integer between ‘MPFR_PREC_MIN’
215 and ‘MPFR_PREC_MAX’. In the current implementation, ‘MPFR_PREC_MIN’ is
217 may abort, crash or have undefined behavior (depending on your C
220 -The "rounding mode" specifies the way to round the result of a
221 +The “rounding mode” specifies the way to round the result of a
222 floating-point operation, in case the exact result can not be
223 represented exactly in the destination significand; the corresponding C
224 data type is ‘mpfr_rnd_t’.
225 @@ -499,14 +499,14 @@
226 representable numbers, it is rounded to the one with the least
227 significant bit set to zero. For example, the number 2.5, which is
228 represented by (10.1) in binary, is rounded to (10.0)=2 with a precision
229 -of two bits, and not to (11.0)=3. This rule avoids the "drift"
230 +of two bits, and not to (11.0)=3. This rule avoids the “drift”
231 phenomenon mentioned by Knuth in volume 2 of The Art of Computer
232 Programming (Section 4.2.2).
234 Most MPFR functions take as first argument the destination variable,
235 as second and following arguments the input variables, as last argument
236 a rounding mode, and have a return value of type ‘int’, called the
237 -"ternary value". The value stored in the destination variable is
238 +“ternary value”. The value stored in the destination variable is
239 correctly rounded, i.e., MPFR behaves as if it computed the result with
240 an infinite precision, then rounded it to the precision of this
241 variable. The input variables are regarded as exact (in particular,
242 @@ -572,15 +572,18 @@
243 When the input point is in the closure of the domain of the
244 mathematical function and an input argument is +0 (resp. −0), one
245 considers the limit when the corresponding argument approaches 0 from
246 -above (resp. below). If the limit is not defined (e.g., ‘mpfr_log’ on
247 -−0), the behavior is specified in the description of the MPFR function.
248 +above (resp. below), if possible. If the limit is not defined (e.g.,
249 +‘mpfr_sqrt’ and ‘mpfr_log’ on −0), the behavior is specified in the
250 +description of the MPFR function, but must be consistent with the rule
251 +from the above paragraph (e.g., ‘mpfr_log’ on ±0 gives −Inf).
253 When the result is equal to 0, its sign is determined by considering
254 the limit as if the input point were not in the domain: If one
255 approaches 0 from above (resp. below), the result is +0 (resp. −0); for
256 -example, ‘mpfr_sin’ on +0 gives +0. In the other cases, the sign is
257 -specified in the description of the MPFR function; for example
258 -‘mpfr_max’ on −0 and +0 gives +0.
259 +example, ‘mpfr_sin’ on −0 gives −0 and ‘mpfr_acos’ on 1 gives +0 (in all
260 +rounding modes). In the other cases, the sign is specified in the
261 +description of the MPFR function; for example ‘mpfr_max’ on −0 and +0
264 When the input point is not in the closure of the domain of the
265 function, the result is NaN. Example: ‘mpfr_sqrt’ on −17 gives NaN.
267 numbers; such a case is always explicitly specified in *note MPFR
268 Interface::. Example: ‘mpfr_hypot’ on (NaN,0) gives NaN, but
269 ‘mpfr_hypot’ on (NaN,+Inf) gives +Inf (as specified in *note Special
270 -Functions::), since for any finite input X, ‘mpfr_hypot’ on (X,+Inf)
272 +Functions::), since for any finite or infinite input X, ‘mpfr_hypot’ on
273 +(X,+Inf) gives +Inf.
276 File: mpfr.info, Node: Exceptions, Next: Memory Handling, Prev: Floating-Point Values on Special Numbers, Up: MPFR Basics
277 @@ -1253,8 +1256,9 @@
279 -- Function: int mpfr_add_q (mpfr_t ROP, mpfr_t OP1, mpq_t OP2,
281 - Set ROP to OP1 + OP2 rounded in the direction RND. For types
282 - having no signed zero, it is considered unsigned (i.e., (+0) + 0 =
283 + Set ROP to OP1 + OP2 rounded in the direction RND. The IEEE-754
284 + rules are used, in particular for signed zeros. But for types
285 + having no signed zeros, 0 is considered unsigned (i.e., (+0) + 0 =
286 (+0) and (−0) + 0 = (−0)). The ‘mpfr_add_d’ function assumes that
287 the radix of the ‘double’ type is a power of 2, with a precision at
288 most that declared by the C implementation (macro
289 @@ -1280,8 +1284,9 @@
291 -- Function: int mpfr_sub_q (mpfr_t ROP, mpfr_t OP1, mpq_t OP2,
293 - Set ROP to OP1 - OP2 rounded in the direction RND. For types
294 - having no signed zero, it is considered unsigned (i.e., (+0) − 0 =
295 + Set ROP to OP1 - OP2 rounded in the direction RND. The IEEE-754
296 + rules are used, in particular for signed zeros. But for types
297 + having no signed zeros, 0 is considered unsigned (i.e., (+0) − 0 =
298 (+0), (−0) − 0 = (−0), 0 − (+0) = (−0) and 0 − (−0) = (+0)). The
299 same restrictions than for ‘mpfr_add_d’ apply to ‘mpfr_d_sub’ and
301 @@ -1300,7 +1305,7 @@
303 Set ROP to OP1 times OP2 rounded in the direction RND. When a
304 result is zero, its sign is the product of the signs of the
305 - operands (for types having no signed zero, it is considered
306 + operands (for types having no signed zeros, 0 is considered
307 positive). The same restrictions than for ‘mpfr_add_d’ apply to
310 @@ -1327,21 +1332,24 @@
312 Set ROP to OP1/OP2 rounded in the direction RND. When a result is
313 zero, its sign is the product of the signs of the operands (for
314 - types having no signed zero, it is considered positive). The same
315 + types having no signed zeros, 0 is considered positive). The same
316 restrictions than for ‘mpfr_add_d’ apply to ‘mpfr_d_div’ and
319 -- Function: int mpfr_sqrt (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
320 -- Function: int mpfr_sqrt_ui (mpfr_t ROP, unsigned long int OP,
322 - Set ROP to the square root of OP rounded in the direction RND (set
323 - ROP to −0 if OP is −0, to be consistent with the IEEE 754
324 - standard). Set ROP to NaN if OP is negative.
325 + Set ROP to the square root of OP rounded in the direction RND. Set
326 + ROP to −0 if OP is −0, to be consistent with the IEEE 754 standard.
327 + Set ROP to NaN if OP is negative.
329 -- Function: int mpfr_rec_sqrt (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
330 Set ROP to the reciprocal square root of OP rounded in the
331 direction RND. Set ROP to +Inf if OP is ±0, +0 if OP is +Inf, and
332 - NaN if OP is negative.
333 + NaN if OP is negative. Warning! Therefore the result on −0 is
334 + different from the one of the rSqrt function recommended by the
335 + IEEE 754-2008 standard (Section 9.2.1), which is −Inf instead of
338 -- Function: int mpfr_cbrt (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
339 -- Function: int mpfr_root (mpfr_t ROP, mpfr_t OP, unsigned long int K,
340 @@ -1515,8 +1523,10 @@
341 -- Function: int mpfr_log2 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
342 -- Function: int mpfr_log10 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
343 Set ROP to the natural logarithm of OP, log2(OP) or log10(OP),
344 - respectively, rounded in the direction RND. Set ROP to −Inf if OP
345 - is −0 (i.e., the sign of the zero has no influence on the result).
346 + respectively, rounded in the direction RND. Set ROP to +0 if OP is
347 + 1 (in all rounding modes), for consistency with the ISO C99 and
348 + IEEE 754-2008 standards. Set ROP to −Inf if OP is ±0 (i.e., the
349 + sign of the zero has no influence on the result).
351 -- Function: int mpfr_exp (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
352 -- Function: int mpfr_exp2 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
353 @@ -1649,17 +1659,21 @@
355 -- Function: int mpfr_lngamma (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
356 Set ROP to the value of the logarithm of the Gamma function on OP,
357 - rounded in the direction RND. When −2K−1 <= OP <= −2K, K being a
358 - non-negative integer, ROP is set to NaN. See also ‘mpfr_lgamma’.
359 + rounded in the direction RND. When OP is 1 or 2, set ROP to +0 (in
360 + all rounding modes). When OP is an infinity or a nonpositive
361 + integer, set ROP to +Inf, following the general rules on special
362 + values. When −2K−1 < OP < −2K, K being a nonnegative integer, set
363 + ROP to NaN. See also ‘mpfr_lgamma’.
365 -- Function: int mpfr_lgamma (mpfr_t ROP, int *SIGNP, mpfr_t OP,
367 Set ROP to the value of the logarithm of the absolute value of the
368 Gamma function on OP, rounded in the direction RND. The sign (1 or
369 −1) of Gamma(OP) is returned in the object pointed to by SIGNP.
370 - When OP is an infinity or a non-positive integer, set ROP to +Inf.
371 - When OP is NaN, −Inf or a negative integer, *SIGNP is undefined,
372 - and when OP is ±0, *SIGNP is the sign of the zero.
373 + When OP is 1 or 2, set ROP to +0 (in all rounding modes). When OP
374 + is an infinity or a nonpositive integer, set ROP to +Inf. When OP
375 + is NaN, −Inf or a negative integer, *SIGNP is undefined, and when
376 + OP is ±0, *SIGNP is the sign of the zero.
378 -- Function: int mpfr_digamma (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
379 Set ROP to the value of the Digamma (sometimes also called Psi)
380 @@ -1703,7 +1717,10 @@
381 -- Function: int mpfr_fms (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, mpfr_t
383 Set ROP to (OP1 times OP2) + OP3 (resp. (OP1 times OP2) - OP3)
384 - rounded in the direction RND.
385 + rounded in the direction RND. Concerning special values (signed
386 + zeros, infinities, NaN), these functions behave like a
387 + multiplication followed by a separate addition or subtraction.
388 + That is, the fused operation matters only for rounding.
390 -- Function: int mpfr_agm (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2,
392 @@ -1717,9 +1734,10 @@
394 Set ROP to the Euclidean norm of X and Y, i.e., the square root of
395 the sum of the squares of X and Y, rounded in the direction RND.
396 - Special values are handled as described in Section F.9.4.3 of the
397 - ISO C99 and IEEE 754-2008 standards: If X or Y is an infinity, then
398 - +Inf is returned in ROP, even if the other number is NaN.
399 + Special values are handled as described in the ISO C99 (Section
400 + F.9.4.3) and IEEE 754-2008 (Section 9.2.1) standards: If X or Y is
401 + an infinity, then +Inf is returned in ROP, even if the other number
404 -- Function: int mpfr_ai (mpfr_t ROP, mpfr_t X, mpfr_rnd_t RND)
405 Set ROP to the value of the Airy function Ai on X, rounded in the
406 @@ -2670,7 +2688,7 @@
410 -A "limb" means the part of a multi-precision number that fits in a
411 +A “limb” means the part of a multi-precision number that fits in a
412 single word. Usually a limb contains 32 or 64 bits. The C data type
413 for a limb is ‘mp_limb_t’.
415 @@ -3140,7 +3158,7 @@
418 The purpose of this License is to make a manual, textbook, or other
419 - functional and useful document "free" in the sense of freedom: to
420 + functional and useful document “free” in the sense of freedom: to
421 assure everyone the effective freedom to copy and redistribute it,
422 with or without modifying it, either commercially or
423 noncommercially. Secondarily, this License preserves for the
424 @@ -3655,9 +3673,9 @@
427 * mpfr_abs: Basic Arithmetic Functions.
429 -* mpfr_acos: Special Functions. (line 51)
430 -* mpfr_acosh: Special Functions. (line 115)
432 +* mpfr_acos: Special Functions. (line 53)
433 +* mpfr_acosh: Special Functions. (line 117)
434 * mpfr_add: Basic Arithmetic Functions.
436 * mpfr_add_d: Basic Arithmetic Functions.
437 @@ -3670,15 +3688,15 @@
439 * mpfr_add_z: Basic Arithmetic Functions.
441 -* mpfr_agm: Special Functions. (line 210)
442 -* mpfr_ai: Special Functions. (line 226)
443 -* mpfr_asin: Special Functions. (line 52)
444 -* mpfr_asinh: Special Functions. (line 116)
445 +* mpfr_agm: Special Functions. (line 219)
446 +* mpfr_ai: Special Functions. (line 236)
447 +* mpfr_asin: Special Functions. (line 54)
448 +* mpfr_asinh: Special Functions. (line 118)
449 * mpfr_asprintf: Formatted Output Functions.
451 -* mpfr_atan: Special Functions. (line 53)
452 -* mpfr_atan2: Special Functions. (line 63)
453 -* mpfr_atanh: Special Functions. (line 117)
454 +* mpfr_atan: Special Functions. (line 55)
455 +* mpfr_atan2: Special Functions. (line 65)
456 +* mpfr_atanh: Special Functions. (line 119)
457 * mpfr_buildopt_decimal_p: Miscellaneous Functions.
459 * mpfr_buildopt_gmpinternals_p: Miscellaneous Functions.
460 @@ -3690,7 +3708,7 @@
461 * mpfr_can_round: Rounding Related Functions.
463 * mpfr_cbrt: Basic Arithmetic Functions.
466 * mpfr_ceil: Integer Related Functions.
468 * mpfr_check_range: Exception Related Functions.
469 @@ -3735,18 +3753,18 @@
471 * mpfr_cmp_z: Comparison Functions.
473 -* mpfr_const_catalan: Special Functions. (line 237)
474 -* mpfr_const_euler: Special Functions. (line 236)
475 -* mpfr_const_log2: Special Functions. (line 234)
476 -* mpfr_const_pi: Special Functions. (line 235)
477 +* mpfr_const_catalan: Special Functions. (line 247)
478 +* mpfr_const_euler: Special Functions. (line 246)
479 +* mpfr_const_log2: Special Functions. (line 244)
480 +* mpfr_const_pi: Special Functions. (line 245)
481 * mpfr_copysign: Miscellaneous Functions.
483 -* mpfr_cos: Special Functions. (line 29)
484 -* mpfr_cosh: Special Functions. (line 95)
485 -* mpfr_cot: Special Functions. (line 47)
486 -* mpfr_coth: Special Functions. (line 111)
487 -* mpfr_csc: Special Functions. (line 46)
488 -* mpfr_csch: Special Functions. (line 110)
489 +* mpfr_cos: Special Functions. (line 31)
490 +* mpfr_cosh: Special Functions. (line 97)
491 +* mpfr_cot: Special Functions. (line 49)
492 +* mpfr_coth: Special Functions. (line 113)
493 +* mpfr_csc: Special Functions. (line 48)
494 +* mpfr_csch: Special Functions. (line 112)
495 * mpfr_custom_get_exp: Custom Interface. (line 75)
496 * mpfr_custom_get_kind: Custom Interface. (line 65)
497 * mpfr_custom_get_significand: Custom Interface. (line 70)
498 @@ -3756,47 +3774,47 @@
499 * mpfr_custom_move: Custom Interface. (line 82)
500 * MPFR_DECL_INIT: Initialization Functions.
502 -* mpfr_digamma: Special Functions. (line 166)
503 +* mpfr_digamma: Special Functions. (line 172)
504 * mpfr_dim: Basic Arithmetic Functions.
507 * mpfr_div: Basic Arithmetic Functions.
510 * mpfr_divby0_p: Exception Related Functions.
512 * mpfr_div_2exp: Compatibility with MPF.
514 * mpfr_div_2si: Basic Arithmetic Functions.
517 * mpfr_div_2ui: Basic Arithmetic Functions.
520 * mpfr_div_d: Basic Arithmetic Functions.
523 * mpfr_div_q: Basic Arithmetic Functions.
526 * mpfr_div_si: Basic Arithmetic Functions.
529 * mpfr_div_ui: Basic Arithmetic Functions.
532 * mpfr_div_z: Basic Arithmetic Functions.
535 * mpfr_d_div: Basic Arithmetic Functions.
538 * mpfr_d_sub: Basic Arithmetic Functions.
540 -* mpfr_eint: Special Functions. (line 133)
542 +* mpfr_eint: Special Functions. (line 135)
543 * mpfr_eq: Compatibility with MPF.
545 * mpfr_equal_p: Comparison Functions.
547 * mpfr_erangeflag_p: Exception Related Functions.
549 -* mpfr_erf: Special Functions. (line 177)
550 -* mpfr_erfc: Special Functions. (line 178)
551 -* mpfr_exp: Special Functions. (line 23)
552 -* mpfr_exp10: Special Functions. (line 25)
553 -* mpfr_exp2: Special Functions. (line 24)
554 -* mpfr_expm1: Special Functions. (line 129)
555 -* mpfr_fac_ui: Special Functions. (line 121)
556 +* mpfr_erf: Special Functions. (line 183)
557 +* mpfr_erfc: Special Functions. (line 184)
558 +* mpfr_exp: Special Functions. (line 25)
559 +* mpfr_exp10: Special Functions. (line 27)
560 +* mpfr_exp2: Special Functions. (line 26)
561 +* mpfr_expm1: Special Functions. (line 131)
562 +* mpfr_fac_ui: Special Functions. (line 123)
563 * mpfr_fits_intmax_p: Conversion Functions.
565 * mpfr_fits_sint_p: Conversion Functions.
566 @@ -3815,20 +3833,20 @@
568 * mpfr_floor: Integer Related Functions.
570 -* mpfr_fma: Special Functions. (line 203)
571 +* mpfr_fma: Special Functions. (line 209)
572 * mpfr_fmod: Integer Related Functions.
574 -* mpfr_fms: Special Functions. (line 205)
575 +* mpfr_fms: Special Functions. (line 211)
576 * mpfr_fprintf: Formatted Output Functions.
578 * mpfr_frac: Integer Related Functions.
580 -* mpfr_free_cache: Special Functions. (line 244)
581 +* mpfr_free_cache: Special Functions. (line 254)
582 * mpfr_free_str: Conversion Functions.
584 * mpfr_frexp: Conversion Functions.
586 -* mpfr_gamma: Special Functions. (line 148)
587 +* mpfr_gamma: Special Functions. (line 150)
588 * mpfr_get_d: Conversion Functions.
590 * mpfr_get_decimal64: Conversion Functions.
591 @@ -3887,7 +3905,7 @@
593 * mpfr_greater_p: Comparison Functions.
595 -* mpfr_hypot: Special Functions. (line 218)
596 +* mpfr_hypot: Special Functions. (line 227)
597 * mpfr_inexflag_p: Exception Related Functions.
599 * mpfr_inf_p: Comparison Functions.
600 @@ -3922,21 +3940,21 @@
602 * mpfr_integer_p: Integer Related Functions.
604 -* mpfr_j0: Special Functions. (line 182)
605 -* mpfr_j1: Special Functions. (line 183)
606 -* mpfr_jn: Special Functions. (line 184)
607 +* mpfr_j0: Special Functions. (line 188)
608 +* mpfr_j1: Special Functions. (line 189)
609 +* mpfr_jn: Special Functions. (line 190)
610 * mpfr_lessequal_p: Comparison Functions.
612 * mpfr_lessgreater_p: Comparison Functions.
614 * mpfr_less_p: Comparison Functions.
616 -* mpfr_lgamma: Special Functions. (line 157)
617 -* mpfr_li2: Special Functions. (line 143)
618 -* mpfr_lngamma: Special Functions. (line 152)
619 +* mpfr_lgamma: Special Functions. (line 162)
620 +* mpfr_li2: Special Functions. (line 145)
621 +* mpfr_lngamma: Special Functions. (line 154)
622 * mpfr_log: Special Functions. (line 16)
623 * mpfr_log10: Special Functions. (line 18)
624 -* mpfr_log1p: Special Functions. (line 125)
625 +* mpfr_log1p: Special Functions. (line 127)
626 * mpfr_log2: Special Functions. (line 17)
627 * mpfr_max: Miscellaneous Functions.
629 @@ -3947,29 +3965,29 @@
630 * mpfr_modf: Integer Related Functions.
632 * mpfr_mul: Basic Arithmetic Functions.
635 * mpfr_mul_2exp: Compatibility with MPF.
637 * mpfr_mul_2si: Basic Arithmetic Functions.
640 * mpfr_mul_2ui: Basic Arithmetic Functions.
643 * mpfr_mul_d: Basic Arithmetic Functions.
646 * mpfr_mul_q: Basic Arithmetic Functions.
649 * mpfr_mul_si: Basic Arithmetic Functions.
652 * mpfr_mul_ui: Basic Arithmetic Functions.
655 * mpfr_mul_z: Basic Arithmetic Functions.
658 * mpfr_nanflag_p: Exception Related Functions.
660 * mpfr_nan_p: Comparison Functions.
662 * mpfr_neg: Basic Arithmetic Functions.
665 * mpfr_nextabove: Miscellaneous Functions.
667 * mpfr_nextbelow: Miscellaneous Functions.
668 @@ -3983,13 +4001,13 @@
669 * mpfr_overflow_p: Exception Related Functions.
671 * mpfr_pow: Basic Arithmetic Functions.
674 * mpfr_pow_si: Basic Arithmetic Functions.
677 * mpfr_pow_ui: Basic Arithmetic Functions.
680 * mpfr_pow_z: Basic Arithmetic Functions.
683 * mpfr_prec_round: Rounding Related Functions.
685 * ‘mpfr_prec_t’: Nomenclature and Types.
686 @@ -3999,7 +4017,7 @@
687 * mpfr_print_rnd_mode: Rounding Related Functions.
689 * mpfr_rec_sqrt: Basic Arithmetic Functions.
692 * mpfr_regular_p: Comparison Functions.
694 * mpfr_reldiff: Compatibility with MPF.
695 @@ -4021,11 +4039,11 @@
696 * ‘mpfr_rnd_t’: Nomenclature and Types.
698 * mpfr_root: Basic Arithmetic Functions.
701 * mpfr_round: Integer Related Functions.
703 -* mpfr_sec: Special Functions. (line 45)
704 -* mpfr_sech: Special Functions. (line 109)
705 +* mpfr_sec: Special Functions. (line 47)
706 +* mpfr_sech: Special Functions. (line 111)
707 * mpfr_set: Assignment Functions.
709 * mpfr_setsign: Miscellaneous Functions.
710 @@ -4100,57 +4118,57 @@
712 * mpfr_signbit: Miscellaneous Functions.
714 -* mpfr_sin: Special Functions. (line 30)
715 -* mpfr_sinh: Special Functions. (line 96)
716 -* mpfr_sinh_cosh: Special Functions. (line 101)
717 -* mpfr_sin_cos: Special Functions. (line 35)
718 +* mpfr_sin: Special Functions. (line 32)
719 +* mpfr_sinh: Special Functions. (line 98)
720 +* mpfr_sinh_cosh: Special Functions. (line 103)
721 +* mpfr_sin_cos: Special Functions. (line 37)
722 * mpfr_si_div: Basic Arithmetic Functions.
725 * mpfr_si_sub: Basic Arithmetic Functions.
728 * mpfr_snprintf: Formatted Output Functions.
730 * mpfr_sprintf: Formatted Output Functions.
732 * mpfr_sqr: Basic Arithmetic Functions.
735 * mpfr_sqrt: Basic Arithmetic Functions.
738 * mpfr_sqrt_ui: Basic Arithmetic Functions.
741 * mpfr_strtofr: Assignment Functions.
743 * mpfr_sub: Basic Arithmetic Functions.
746 * mpfr_subnormalize: Exception Related Functions.
748 * mpfr_sub_d: Basic Arithmetic Functions.
751 * mpfr_sub_q: Basic Arithmetic Functions.
754 * mpfr_sub_si: Basic Arithmetic Functions.
757 * mpfr_sub_ui: Basic Arithmetic Functions.
760 * mpfr_sub_z: Basic Arithmetic Functions.
762 -* mpfr_sum: Special Functions. (line 252)
764 +* mpfr_sum: Special Functions. (line 262)
765 * mpfr_swap: Assignment Functions.
767 * ‘mpfr_t’: Nomenclature and Types.
769 -* mpfr_tan: Special Functions. (line 31)
770 -* mpfr_tanh: Special Functions. (line 97)
771 +* mpfr_tan: Special Functions. (line 33)
772 +* mpfr_tanh: Special Functions. (line 99)
773 * mpfr_trunc: Integer Related Functions.
775 * mpfr_ui_div: Basic Arithmetic Functions.
778 * mpfr_ui_pow: Basic Arithmetic Functions.
781 * mpfr_ui_pow_ui: Basic Arithmetic Functions.
784 * mpfr_ui_sub: Basic Arithmetic Functions.
787 * mpfr_underflow_p: Exception Related Functions.
789 * mpfr_unordered_p: Comparison Functions.
790 @@ -4181,61 +4199,61 @@
792 * mpfr_vsprintf: Formatted Output Functions.
794 -* mpfr_y0: Special Functions. (line 193)
795 -* mpfr_y1: Special Functions. (line 194)
796 -* mpfr_yn: Special Functions. (line 195)
797 +* mpfr_y0: Special Functions. (line 199)
798 +* mpfr_y1: Special Functions. (line 200)
799 +* mpfr_yn: Special Functions. (line 201)
800 * mpfr_zero_p: Comparison Functions.
802 -* mpfr_zeta: Special Functions. (line 171)
803 -* mpfr_zeta_ui: Special Functions. (line 172)
804 +* mpfr_zeta: Special Functions. (line 177)
805 +* mpfr_zeta_ui: Special Functions. (line 178)
806 * mpfr_z_sub: Basic Arithmetic Functions.
815 -Node: Introduction to MPFR
\7f3766
816 -Node: Installing MPFR
\7f5880
817 -Node: Reporting Bugs
\7f11323
818 -Node: MPFR Basics
\7f13353
819 -Node: Headers and Libraries
\7f13669
820 -Node: Nomenclature and Types
\7f16828
821 -Node: MPFR Variable Conventions
\7f18874
822 -Node: Rounding Modes
\7f20418
823 -Ref: ternary value
\7f21544
824 -Node: Floating-Point Values on Special Numbers
\7f23526
825 -Node: Exceptions
\7f26572
826 -Node: Memory Handling
\7f29749
827 -Node: MPFR Interface
\7f30894
828 -Node: Initialization Functions
\7f33008
829 -Node: Assignment Functions
\7f40318
830 -Node: Combined Initialization and Assignment Functions
\7f49673
831 -Node: Conversion Functions
\7f50974
832 -Node: Basic Arithmetic Functions
\7f60035
833 -Node: Comparison Functions
\7f69200
834 -Node: Special Functions
\7f72687
835 -Node: Input and Output Functions
\7f86672
836 -Node: Formatted Output Functions
\7f88644
837 -Node: Integer Related Functions
\7f98431
838 -Node: Rounding Related Functions
\7f105051
839 -Node: Miscellaneous Functions
\7f108888
840 -Node: Exception Related Functions
\7f117568
841 -Node: Compatibility with MPF
\7f124386
842 -Node: Custom Interface
\7f127127
843 -Node: Internals
\7f131526
844 -Node: API Compatibility
\7f133066
845 -Node: Type and Macro Changes
\7f134995
846 -Node: Added Functions
\7f137844
847 -Node: Changed Functions
\7f141132
848 -Node: Removed Functions
\7f145545
849 -Node: Other Changes
\7f145973
850 -Node: Contributors
\7f147576
851 -Node: References
\7f150219
852 -Node: GNU Free Documentation License
\7f151973
853 -Node: Concept Index
\7f174562
854 -Node: Function and Type Index
\7f180659
855 +Node: Introduction to MPFR
\7f3770
856 +Node: Installing MPFR
\7f5884
857 +Node: Reporting Bugs
\7f11327
858 +Node: MPFR Basics
\7f13357
859 +Node: Headers and Libraries
\7f13673
860 +Node: Nomenclature and Types
\7f16832
861 +Node: MPFR Variable Conventions
\7f18894
862 +Node: Rounding Modes
\7f20438
863 +Ref: ternary value
\7f21568
864 +Node: Floating-Point Values on Special Numbers
\7f23554
865 +Node: Exceptions
\7f26813
866 +Node: Memory Handling
\7f29990
867 +Node: MPFR Interface
\7f31135
868 +Node: Initialization Functions
\7f33249
869 +Node: Assignment Functions
\7f40559
870 +Node: Combined Initialization and Assignment Functions
\7f49914
871 +Node: Conversion Functions
\7f51215
872 +Node: Basic Arithmetic Functions
\7f60276
873 +Node: Comparison Functions
\7f69777
874 +Node: Special Functions
\7f73264
875 +Node: Input and Output Functions
\7f87862
876 +Node: Formatted Output Functions
\7f89834
877 +Node: Integer Related Functions
\7f99621
878 +Node: Rounding Related Functions
\7f106241
879 +Node: Miscellaneous Functions
\7f110078
880 +Node: Exception Related Functions
\7f118758
881 +Node: Compatibility with MPF
\7f125576
882 +Node: Custom Interface
\7f128317
883 +Node: Internals
\7f132716
884 +Node: API Compatibility
\7f134260
885 +Node: Type and Macro Changes
\7f136189
886 +Node: Added Functions
\7f139038
887 +Node: Changed Functions
\7f142326
888 +Node: Removed Functions
\7f146739
889 +Node: Other Changes
\7f147167
890 +Node: Contributors
\7f148770
891 +Node: References
\7f151413
892 +Node: GNU Free Documentation License
\7f153167
893 +Node: Concept Index
\7f175760
894 +Node: Function and Type Index
\7f181857
898 diff -Naurd mpfr-3.1.3-a/src/lngamma.c mpfr-3.1.3-b/src/lngamma.c
899 --- mpfr-3.1.3-a/src/lngamma.c 2015-06-19 19:55:10.000000000 +0000
900 +++ mpfr-3.1.3-b/src/lngamma.c 2015-07-02 10:49:24.018113593 +0000
901 @@ -603,16 +603,17 @@
902 mpfr_get_prec (y), mpfr_log_prec, y, inex));
905 - if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x)))
906 + if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x) ||
907 + (MPFR_IS_NEG (x) && mpfr_integer_p (x))))
909 - if (MPFR_IS_NAN (x) || MPFR_IS_NEG (x))
910 + if (MPFR_IS_NAN (x))
915 - else /* lngamma(+Inf) = lngamma(+0) = +Inf */
916 + else /* lngamma(+/-Inf) = lngamma(nonpositive integer) = +Inf */
918 - if (MPFR_IS_ZERO (x))
919 + if (!MPFR_IS_INF (x))
927 - /* if x < 0 and -2k-1 <= x <= -2k, then lngamma(x) = NaN */
928 - if (MPFR_IS_NEG (x) && (unit_bit (x) == 0 || mpfr_integer_p (x)))
929 + /* if -2k-1 < x < -2k <= 0, then lngamma(x) = NaN */
930 + if (MPFR_IS_NEG (x) && unit_bit (x) == 0)
934 diff -Naurd mpfr-3.1.3-a/src/mpfr.h mpfr-3.1.3-b/src/mpfr.h
935 --- mpfr-3.1.3-a/src/mpfr.h 2015-06-19 19:55:10.000000000 +0000
936 +++ mpfr-3.1.3-b/src/mpfr.h 2015-07-02 10:49:24.038113803 +0000
938 #define MPFR_VERSION_MAJOR 3
939 #define MPFR_VERSION_MINOR 1
940 #define MPFR_VERSION_PATCHLEVEL 3
941 -#define MPFR_VERSION_STRING "3.1.3"
942 +#define MPFR_VERSION_STRING "3.1.3-p1"
944 /* Macros dealing with MPFR VERSION */
945 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
946 diff -Naurd mpfr-3.1.3-a/src/version.c mpfr-3.1.3-b/src/version.c
947 --- mpfr-3.1.3-a/src/version.c 2015-06-19 19:55:10.000000000 +0000
948 +++ mpfr-3.1.3-b/src/version.c 2015-07-02 10:49:24.042113845 +0000
951 mpfr_get_version (void)
956 diff -Naurd mpfr-3.1.3-a/tests/tlngamma.c mpfr-3.1.3-b/tests/tlngamma.c
957 --- mpfr-3.1.3-a/tests/tlngamma.c 2015-06-19 19:55:10.000000000 +0000
958 +++ mpfr-3.1.3-b/tests/tlngamma.c 2015-07-02 10:49:24.018113593 +0000
972 - mpfr_set_inf (x, -1);
973 + mpfr_set_inf (x, 1);
974 + mpfr_clear_flags ();
975 mpfr_lngamma (y, x, MPFR_RNDN);
976 - if (!mpfr_nan_p (y))
977 + if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 || __gmpfr_flags != 0)
979 - printf ("Error for lngamma(-Inf)\n");
980 + printf ("Error for lngamma(+Inf)\n");
984 - mpfr_set_inf (x, 1);
985 + mpfr_set_inf (x, -1);
986 + mpfr_clear_flags ();
987 mpfr_lngamma (y, x, MPFR_RNDN);
988 - if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0)
989 + if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 || __gmpfr_flags != 0)
991 - printf ("Error for lngamma(+Inf)\n");
992 + printf ("Error for lngamma(-Inf)\n");
996 mpfr_set_ui (x, 0, MPFR_RNDN);
997 + mpfr_clear_flags ();
998 mpfr_lngamma (y, x, MPFR_RNDN);
999 - if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0)
1000 + if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 ||
1001 + __gmpfr_flags != MPFR_FLAGS_DIVBY0)
1003 printf ("Error for lngamma(+0)\n");
1007 mpfr_set_ui (x, 0, MPFR_RNDN);
1008 mpfr_neg (x, x, MPFR_RNDN);
1009 + mpfr_clear_flags ();
1010 mpfr_lngamma (y, x, MPFR_RNDN);
1011 - if (!mpfr_nan_p (y))
1012 + if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 ||
1013 + __gmpfr_flags != MPFR_FLAGS_DIVBY0)
1015 printf ("Error for lngamma(-0)\n");
1019 mpfr_set_ui (x, 1, MPFR_RNDN);
1020 + mpfr_clear_flags ();
1021 mpfr_lngamma (y, x, MPFR_RNDN);
1022 - if (MPFR_IS_NAN (y) || mpfr_cmp_ui (y, 0) || MPFR_IS_NEG (y))
1023 + if (mpfr_cmp_ui0 (y, 0) || MPFR_IS_NEG (y))
1025 printf ("Error for lngamma(1)\n");
1029 - mpfr_set_si (x, -1, MPFR_RNDN);
1030 - mpfr_lngamma (y, x, MPFR_RNDN);
1031 - if (!mpfr_nan_p (y))
1032 + for (i = 1; i <= 5; i++)
1034 - printf ("Error for lngamma(-1)\n");
1038 + mpfr_set_si (x, -i, MPFR_RNDN);
1039 + mpfr_clear_flags ();
1040 + mpfr_lngamma (y, x, MPFR_RNDN);
1041 + if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 ||
1042 + __gmpfr_flags != MPFR_FLAGS_DIVBY0)
1044 + printf ("Error for lngamma(-%d)\n", i);
1049 + mpfr_nextabove (x);
1054 + mpfr_nextbelow (x);
1057 + mpfr_lngamma (y, x, MPFR_RNDN);
1058 + if (!mpfr_nan_p (y))
1060 + printf ("Error for lngamma(-%d%cepsilon)\n", i, c);
1065 mpfr_set_ui (x, 2, MPFR_RNDN);
1066 mpfr_lngamma (y, x, MPFR_RNDN);
1067 - if (MPFR_IS_NAN (y) || mpfr_cmp_ui (y, 0) || MPFR_IS_NEG (y))
1068 + if (mpfr_cmp_ui0 (y, 0) || MPFR_IS_NEG (y))
1070 printf ("Error for lngamma(2)\n");
1073 mpfr_set_str (x, CHECK_X2, 10, MPFR_RNDN);
1074 mpfr_lngamma (y, x, MPFR_RNDN);
1075 mpfr_set_str (x, CHECK_Y2, 10, MPFR_RNDN);
1076 - if (MPFR_IS_NAN (y) || mpfr_cmp (y, x))
1077 + if (mpfr_cmp0 (y, x))
1079 printf ("mpfr_lngamma("CHECK_X2") is wrong:\n"
1082 mpfr_lngamma (y, x, MPFR_RNDU);
1083 mpfr_set_prec (x, 175);
1084 mpfr_set_str_binary (x, "0.1010001100011101101011001101110010100001000001000001110011000001101100001111001001000101011011100100010101011110100111110101010100010011010010000101010111001100011000101111E7");
1085 - if (MPFR_IS_NAN (y) || mpfr_cmp (x, y))
1086 + if (mpfr_cmp0 (x, y))
1088 printf ("Error in mpfr_lngamma (1)\n");
1091 mpfr_lngamma (x, y, MPFR_RNDZ);
1092 mpfr_set_prec (y, 21);
1093 mpfr_set_str_binary (y, "0.111000101000001100101E9");
1094 - if (MPFR_IS_NAN (x) || mpfr_cmp (x, y))
1095 + if (mpfr_cmp0 (x, y))
1097 printf ("Error in mpfr_lngamma (120)\n");
1098 printf ("Expected "); mpfr_print_binary (y); puts ("");
1100 inex = mpfr_lngamma (y, x, MPFR_RNDN);
1101 mpfr_set_prec (x, 206);
1102 mpfr_set_str_binary (x, "0.10000111011000000011100010101001100110001110000111100011000100100110110010001011011110101001111011110110000001010100111011010000000011100110110101100111000111010011110010000100010111101010001101000110101001E13");
1103 - if (MPFR_IS_NAN (y) || mpfr_cmp (x, y))
1104 + if (mpfr_cmp0 (x, y))
1106 printf ("Error in mpfr_lngamma (768)\n");
1109 mpfr_set_str_binary (x, "0.1100E-66");
1110 mpfr_lngamma (y, x, MPFR_RNDN);
1111 mpfr_set_str_binary (x, "0.1100E6");
1112 - if (MPFR_IS_NAN (y) || mpfr_cmp (x, y))
1113 + if (mpfr_cmp0 (x, y))
1115 printf ("Error for lngamma(0.1100E-66)\n");
1118 mpfr_lngamma (y, x, MPFR_RNDN);
1119 mpfr_set_prec (x, 32);
1120 mpfr_set_str_binary (x, "-0.10001000111011111011000010100010E207");
1121 - if (MPFR_IS_NAN (y) || mpfr_cmp (x, y))
1122 + if (mpfr_cmp0 (x, y))
1124 printf ("Error for lngamma(-2^199+0.5)\n");
1126 diff -Naurd mpfr-3.1.3-a/PATCHES mpfr-3.1.3-b/PATCHES
1127 --- mpfr-3.1.3-a/PATCHES 2015-07-02 10:50:08.046573308 +0000
1128 +++ mpfr-3.1.3-b/PATCHES 2015-07-02 10:50:08.126574142 +0000
1130 +muldiv-2exp-overflow
1131 diff -Naurd mpfr-3.1.3-a/VERSION mpfr-3.1.3-b/VERSION
1132 --- mpfr-3.1.3-a/VERSION 2015-07-02 10:49:24.042113845 +0000
1133 +++ mpfr-3.1.3-b/VERSION 2015-07-02 10:50:08.126574142 +0000
1137 diff -Naurd mpfr-3.1.3-a/src/div_2si.c mpfr-3.1.3-b/src/div_2si.c
1138 --- mpfr-3.1.3-a/src/div_2si.c 2015-06-19 19:55:10.000000000 +0000
1139 +++ mpfr-3.1.3-b/src/div_2si.c 2015-07-02 10:50:08.106573933 +0000
1141 rnd_mode = MPFR_RNDZ;
1142 return mpfr_underflow (y, rnd_mode, MPFR_SIGN(y));
1144 - else if (MPFR_UNLIKELY(n < 0 && (__gmpfr_emax < MPFR_EMIN_MIN - n ||
1145 + else if (MPFR_UNLIKELY(n <= 0 && (__gmpfr_emax < MPFR_EMIN_MIN - n ||
1146 exp > __gmpfr_emax + n)) )
1147 return mpfr_overflow (y, rnd_mode, MPFR_SIGN(y));
1149 diff -Naurd mpfr-3.1.3-a/src/div_2ui.c mpfr-3.1.3-b/src/div_2ui.c
1150 --- mpfr-3.1.3-a/src/div_2ui.c 2015-06-19 19:55:10.000000000 +0000
1151 +++ mpfr-3.1.3-b/src/div_2ui.c 2015-07-02 10:50:08.106573933 +0000
1154 ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, inexact));
1156 - if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x)))
1157 + if (MPFR_UNLIKELY (n == 0 || MPFR_IS_SINGULAR (x)))
1158 return mpfr_set (y, x, rnd_mode);
1161 diff -Naurd mpfr-3.1.3-a/src/mpfr.h mpfr-3.1.3-b/src/mpfr.h
1162 --- mpfr-3.1.3-a/src/mpfr.h 2015-07-02 10:49:24.038113803 +0000
1163 +++ mpfr-3.1.3-b/src/mpfr.h 2015-07-02 10:50:08.126574142 +0000
1165 #define MPFR_VERSION_MAJOR 3
1166 #define MPFR_VERSION_MINOR 1
1167 #define MPFR_VERSION_PATCHLEVEL 3
1168 -#define MPFR_VERSION_STRING "3.1.3-p1"
1169 +#define MPFR_VERSION_STRING "3.1.3-p2"
1171 /* Macros dealing with MPFR VERSION */
1172 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
1173 diff -Naurd mpfr-3.1.3-a/src/mul_2si.c mpfr-3.1.3-b/src/mul_2si.c
1174 --- mpfr-3.1.3-a/src/mul_2si.c 2015-06-19 19:55:10.000000000 +0000
1175 +++ mpfr-3.1.3-b/src/mul_2si.c 2015-07-02 10:50:08.106573933 +0000
1178 mpfr_exp_t exp = MPFR_GET_EXP (x);
1179 MPFR_SETRAW (inexact, y, x, exp, rnd_mode);
1180 - if (MPFR_UNLIKELY( n > 0 && (__gmpfr_emax < MPFR_EMIN_MIN + n ||
1181 + if (MPFR_UNLIKELY(n >= 0 && (__gmpfr_emax < MPFR_EMIN_MIN + n ||
1182 exp > __gmpfr_emax - n)))
1183 return mpfr_overflow (y, rnd_mode, MPFR_SIGN(y));
1184 else if (MPFR_UNLIKELY(n < 0 && (__gmpfr_emin > MPFR_EMAX_MAX + n ||
1185 diff -Naurd mpfr-3.1.3-a/src/version.c mpfr-3.1.3-b/src/version.c
1186 --- mpfr-3.1.3-a/src/version.c 2015-07-02 10:49:24.042113845 +0000
1187 +++ mpfr-3.1.3-b/src/version.c 2015-07-02 10:50:08.126574142 +0000
1190 mpfr_get_version (void)
1192 - return "3.1.3-p1";
1193 + return "3.1.3-p2";
1195 diff -Naurd mpfr-3.1.3-a/tests/tmul_2exp.c mpfr-3.1.3-b/tests/tmul_2exp.c
1196 --- mpfr-3.1.3-a/tests/tmul_2exp.c 2015-06-19 19:55:10.000000000 +0000
1197 +++ mpfr-3.1.3-b/tests/tmul_2exp.c 2015-07-02 10:50:08.106573933 +0000
1198 @@ -242,6 +242,76 @@
1199 large (MPFR_EMAX_MAX);
1202 +/* Cases where the function overflows on n = 0 when rounding is like
1203 + away from zero. */
1205 +overflow0 (mpfr_exp_t emax)
1207 + mpfr_exp_t old_emax;
1210 + static char *sop[4] = { "mul_2ui", "mul_2si", "div_2ui", "div_2si" };
1212 + old_emax = mpfr_get_emax ();
1215 + mpfr_init2 (x, 8);
1216 + mpfr_inits2 (6, y1, y2, (mpfr_ptr) 0);
1218 + mpfr_set_inf (x, 1);
1219 + mpfr_nextbelow (x);
1221 + for (neg = 0; neg <= 1; neg++)
1226 + unsigned int flags1, flags2;
1228 + /* Even if there isn't an overflow (rounding ~ toward zero),
1229 + the result is the same as the one of an overflow. */
1230 + inex1 = mpfr_overflow (y1, (mpfr_rnd_t) r, neg ? -1 : 1);
1231 + flags1 = MPFR_FLAGS_INEXACT;
1232 + if (mpfr_inf_p (y1))
1233 + flags1 |= MPFR_FLAGS_OVERFLOW;
1234 + for (op = 0; op < 4; op++)
1236 + mpfr_clear_flags ();
1238 + op == 0 ? mpfr_mul_2ui (y2, x, 0, (mpfr_rnd_t) r) :
1239 + op == 1 ? mpfr_mul_2si (y2, x, 0, (mpfr_rnd_t) r) :
1240 + op == 2 ? mpfr_div_2ui (y2, x, 0, (mpfr_rnd_t) r) :
1241 + op == 3 ? mpfr_div_2si (y2, x, 0, (mpfr_rnd_t) r) :
1242 + (MPFR_ASSERTN (0), 0);
1243 + flags2 = __gmpfr_flags;
1244 + if (!(mpfr_equal_p (y1, y2) &&
1245 + SAME_SIGN (inex1, inex2) &&
1246 + flags1 == flags2))
1248 + printf ("Error in overflow0 for %s, mpfr_%s, emax = %"
1249 + MPFR_EXP_FSPEC "d,\nx = ",
1250 + mpfr_print_rnd_mode ((mpfr_rnd_t) r), sop[op],
1251 + (mpfr_eexp_t) emax);
1253 + printf ("Expected ");
1255 + printf (" with inex = %d, flags =", inex1);
1256 + flags_out (flags1);
1259 + printf (" with inex = %d, flags =", inex2);
1260 + flags_out (flags2);
1265 + mpfr_neg (x, x, MPFR_RNDN);
1268 + mpfr_clears (x, y1, y2, (mpfr_ptr) 0);
1269 + set_emax (old_emax);
1273 main (int argc, char *argv[])
1275 @@ -334,6 +404,11 @@
1279 + if (mpfr_get_emax () != MPFR_EMAX_MAX)
1280 + overflow0 (mpfr_get_emax ());
1281 + overflow0 (MPFR_EMAX_MAX);
1287 diff -Naurd mpfr-3.1.3-a/PATCHES mpfr-3.1.3-b/PATCHES
1288 --- mpfr-3.1.3-a/PATCHES 2015-07-17 08:54:48.592799981 +0000
1289 +++ mpfr-3.1.3-b/PATCHES 2015-07-17 08:54:48.616811495 +0000
1291 +muldiv-2exp-underflow
1292 diff -Naurd mpfr-3.1.3-a/VERSION mpfr-3.1.3-b/VERSION
1293 --- mpfr-3.1.3-a/VERSION 2015-07-02 10:50:08.126574142 +0000
1294 +++ mpfr-3.1.3-b/VERSION 2015-07-17 08:54:48.616811495 +0000
1298 diff -Naurd mpfr-3.1.3-a/src/div_2si.c mpfr-3.1.3-b/src/div_2si.c
1299 --- mpfr-3.1.3-a/src/div_2si.c 2015-07-02 10:50:08.106573933 +0000
1300 +++ mpfr-3.1.3-b/src/div_2si.c 2015-07-17 08:54:48.608807656 +0000
1302 if (rnd_mode == MPFR_RNDN &&
1303 (__gmpfr_emin > MPFR_EMAX_MAX - (n - 1) ||
1304 exp < __gmpfr_emin + (n - 1) ||
1305 - (inexact >= 0 && mpfr_powerof2_raw (y))))
1306 + ((MPFR_IS_NEG (y) ? inexact <= 0 : inexact >= 0) &&
1307 + mpfr_powerof2_raw (y))))
1308 rnd_mode = MPFR_RNDZ;
1309 return mpfr_underflow (y, rnd_mode, MPFR_SIGN(y));
1311 diff -Naurd mpfr-3.1.3-a/src/div_2ui.c mpfr-3.1.3-b/src/div_2ui.c
1312 --- mpfr-3.1.3-a/src/div_2ui.c 2015-07-02 10:50:08.106573933 +0000
1313 +++ mpfr-3.1.3-b/src/div_2ui.c 2015-07-17 08:54:48.608807656 +0000
1315 if (MPFR_UNLIKELY (n >= diffexp)) /* exp - n <= emin - 1 */
1317 if (rnd_mode == MPFR_RNDN &&
1318 - (n > diffexp || (inexact >= 0 && mpfr_powerof2_raw (y))))
1320 + ((MPFR_IS_NEG (y) ? inexact <= 0 : inexact >= 0) &&
1321 + mpfr_powerof2_raw (y))))
1322 rnd_mode = MPFR_RNDZ;
1323 return mpfr_underflow (y, rnd_mode, MPFR_SIGN (y));
1325 diff -Naurd mpfr-3.1.3-a/src/mpfr.h mpfr-3.1.3-b/src/mpfr.h
1326 --- mpfr-3.1.3-a/src/mpfr.h 2015-07-02 10:50:08.126574142 +0000
1327 +++ mpfr-3.1.3-b/src/mpfr.h 2015-07-17 08:54:48.616811495 +0000
1329 #define MPFR_VERSION_MAJOR 3
1330 #define MPFR_VERSION_MINOR 1
1331 #define MPFR_VERSION_PATCHLEVEL 3
1332 -#define MPFR_VERSION_STRING "3.1.3-p2"
1333 +#define MPFR_VERSION_STRING "3.1.3-p3"
1335 /* Macros dealing with MPFR VERSION */
1336 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
1337 diff -Naurd mpfr-3.1.3-a/src/mul_2si.c mpfr-3.1.3-b/src/mul_2si.c
1338 --- mpfr-3.1.3-a/src/mul_2si.c 2015-07-02 10:50:08.106573933 +0000
1339 +++ mpfr-3.1.3-b/src/mul_2si.c 2015-07-17 08:54:48.608807656 +0000
1341 if (rnd_mode == MPFR_RNDN &&
1342 (__gmpfr_emin > MPFR_EMAX_MAX + (n + 1) ||
1343 exp < __gmpfr_emin - (n + 1) ||
1344 - (inexact >= 0 && mpfr_powerof2_raw (y))))
1345 + ((MPFR_IS_NEG (y) ? inexact <= 0 : inexact >= 0) &&
1346 + mpfr_powerof2_raw (y))))
1347 rnd_mode = MPFR_RNDZ;
1348 return mpfr_underflow (y, rnd_mode, MPFR_SIGN(y));
1350 diff -Naurd mpfr-3.1.3-a/src/version.c mpfr-3.1.3-b/src/version.c
1351 --- mpfr-3.1.3-a/src/version.c 2015-07-02 10:50:08.126574142 +0000
1352 +++ mpfr-3.1.3-b/src/version.c 2015-07-17 08:54:48.616811495 +0000
1355 mpfr_get_version (void)
1357 - return "3.1.3-p2";
1358 + return "3.1.3-p3";
1360 diff -Naurd mpfr-3.1.3-a/tests/tmul_2exp.c mpfr-3.1.3-b/tests/tmul_2exp.c
1361 --- mpfr-3.1.3-a/tests/tmul_2exp.c 2015-07-02 10:50:08.106573933 +0000
1362 +++ mpfr-3.1.3-b/tests/tmul_2exp.c 2015-07-17 08:54:48.608807656 +0000
1365 mpfr_t x, y, z1, z2;
1373 unsigned int flags1, flags2;
1375 - /* Test mul_2si(x, e - k), div_2si(x, k - e) and div_2ui(x, k - e)
1376 - * with emin = e, x = 1 + i/16, i in { -1, 0, 1 }, and k = 1 to 4,
1377 - * by comparing the result with the one of a simple division.
1378 + /* Test mul_2si(x, e - k), div_2si(x, k - e) and div_2ui(x, k - e) with
1379 + * emin = e, x = s * (1 + i/16), i in { -1, 0, 1 }, s in { -1, 1 }, and
1380 + * k = 1 to 4, by comparing the result with the one of a simple division.
1382 emin = mpfr_get_emin ();
1384 mpfr_inits2 (8, x, y, (mpfr_ptr) 0);
1385 for (i = 15; i <= 17; i++)
1387 - inex1 = mpfr_set_ui_2exp (x, i, -4, MPFR_RNDN);
1388 - MPFR_ASSERTN (inex1 == 0);
1389 - for (prec = 6; prec >= 3; prec -= 3)
1391 - mpfr_inits2 (prec, z1, z2, (mpfr_ptr) 0);
1393 - for (k = 1; k <= 4; k++)
1395 - /* The following one is assumed to be correct. */
1396 - inex1 = mpfr_mul_2si (y, x, e, MPFR_RNDN);
1397 - MPFR_ASSERTN (inex1 == 0);
1398 - inex1 = mpfr_set_ui (z1, 1 << k, MPFR_RNDN);
1399 - MPFR_ASSERTN (inex1 == 0);
1400 - mpfr_clear_flags ();
1401 - /* Do not use mpfr_div_ui to avoid the optimization
1402 - by mpfr_div_2si. */
1403 - inex1 = mpfr_div (z1, y, z1, (mpfr_rnd_t) rnd);
1404 - flags1 = __gmpfr_flags;
1406 - for (div = 0; div <= 2; div++)
1407 + for (s = 1; s >= -1; s -= 2)
1409 + inex1 = mpfr_set_si_2exp (x, s * i, -4, MPFR_RNDN);
1410 + MPFR_ASSERTN (inex1 == 0);
1411 + for (prec = 6; prec >= 3; prec -= 3)
1413 + mpfr_inits2 (prec, z1, z2, (mpfr_ptr) 0);
1415 + for (k = 1; k <= 4; k++)
1417 + /* The following one is assumed to be correct. */
1418 + inex1 = mpfr_mul_2si (y, x, e, MPFR_RNDN);
1419 + MPFR_ASSERTN (inex1 == 0);
1420 + inex1 = mpfr_set_ui (z1, 1 << k, MPFR_RNDN);
1421 + MPFR_ASSERTN (inex1 == 0);
1422 mpfr_clear_flags ();
1423 - inex2 = div == 0 ?
1424 - mpfr_mul_2si (z2, x, e - k, (mpfr_rnd_t) rnd) : div == 1 ?
1425 - mpfr_div_2si (z2, x, k - e, (mpfr_rnd_t) rnd) :
1426 - mpfr_div_2ui (z2, x, k - e, (mpfr_rnd_t) rnd);
1427 - flags2 = __gmpfr_flags;
1428 - if (flags1 == flags2 && SAME_SIGN (inex1, inex2) &&
1429 - mpfr_equal_p (z1, z2))
1431 - printf ("Error in underflow(");
1432 - if (e == MPFR_EMIN_MIN)
1433 - printf ("MPFR_EMIN_MIN");
1434 - else if (e == emin)
1435 - printf ("default emin");
1436 - else if (e >= LONG_MIN)
1437 - printf ("%ld", (long) e);
1439 - printf ("<LONG_MIN");
1440 - printf (") with mpfr_%s,\nx = %d/16, prec = %d, k = %d, "
1441 - "%s\n", div == 0 ? "mul_2si" : div == 1 ?
1442 - "div_2si" : "div_2ui", i, prec, k,
1443 - mpfr_print_rnd_mode ((mpfr_rnd_t) rnd));
1444 - printf ("Expected ");
1445 - mpfr_out_str (stdout, 16, 0, z1, MPFR_RNDN);
1446 - printf (", inex = %d, flags = %u\n", SIGN (inex1), flags1);
1448 - mpfr_out_str (stdout, 16, 0, z2, MPFR_RNDN);
1449 - printf (", inex = %d, flags = %u\n", SIGN (inex2), flags2);
1453 - mpfr_clears (z1, z2, (mpfr_ptr) 0);
1456 + /* Do not use mpfr_div_ui to avoid the optimization
1457 + by mpfr_div_2si. */
1458 + inex1 = mpfr_div (z1, y, z1, (mpfr_rnd_t) rnd);
1459 + flags1 = __gmpfr_flags;
1461 + for (div = 0; div <= 2; div++)
1463 + mpfr_clear_flags ();
1466 + mpfr_mul_2si (z2, x, e - k, (mpfr_rnd_t) rnd) :
1468 + mpfr_div_2si (z2, x, k - e, (mpfr_rnd_t) rnd) :
1469 + mpfr_div_2ui (z2, x, k - e, (mpfr_rnd_t) rnd);
1470 + flags2 = __gmpfr_flags;
1471 + if (flags1 == flags2 && SAME_SIGN (inex1, inex2) &&
1472 + mpfr_equal_p (z1, z2))
1474 + printf ("Error in underflow(");
1475 + if (e == MPFR_EMIN_MIN)
1476 + printf ("MPFR_EMIN_MIN");
1477 + else if (e == emin)
1478 + printf ("default emin");
1479 + else if (e >= LONG_MIN)
1480 + printf ("%ld", (long) e);
1482 + printf ("<LONG_MIN");
1483 + printf (") with mpfr_%s,\nx = %d/16, prec = %d, k = %d,"
1484 + " %s\n", div == 0 ? "mul_2si" : div == 1 ?
1485 + "div_2si" : "div_2ui", s * i, prec, k,
1486 + mpfr_print_rnd_mode ((mpfr_rnd_t) rnd));
1487 + printf ("Expected ");
1488 + mpfr_out_str (stdout, 16, 0, z1, MPFR_RNDN);
1489 + printf (", inex = %d, flags = %u\n",
1490 + SIGN (inex1), flags1);
1492 + mpfr_out_str (stdout, 16, 0, z2, MPFR_RNDN);
1493 + printf (", inex = %d, flags = %u\n",
1494 + SIGN (inex2), flags2);
1498 + mpfr_clears (z1, z2, (mpfr_ptr) 0);
1501 mpfr_clears (x, y, (mpfr_ptr) 0);
1504 diff -Naurd mpfr-3.1.3-a/PATCHES mpfr-3.1.3-b/PATCHES
1505 --- mpfr-3.1.3-a/PATCHES 2015-07-17 08:58:21.094987384 +0000
1506 +++ mpfr-3.1.3-b/PATCHES 2015-07-17 08:58:21.118986898 +0000
1509 diff -Naurd mpfr-3.1.3-a/VERSION mpfr-3.1.3-b/VERSION
1510 --- mpfr-3.1.3-a/VERSION 2015-07-17 08:54:48.616811495 +0000
1511 +++ mpfr-3.1.3-b/VERSION 2015-07-17 08:58:21.118986898 +0000
1515 diff -Naurd mpfr-3.1.3-a/src/frexp.c mpfr-3.1.3-b/src/frexp.c
1516 --- mpfr-3.1.3-a/src/frexp.c 2015-06-19 19:55:09.000000000 +0000
1517 +++ mpfr-3.1.3-b/src/frexp.c 2015-07-17 08:58:21.106987142 +0000
1519 mpfr_frexp (mpfr_exp_t *exp, mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd)
1522 + unsigned int saved_flags = __gmpfr_flags;
1523 + MPFR_BLOCK_DECL (flags);
1526 + (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd),
1527 + ("y[%Pu]=%.*Rg exp=%" MPFR_EXP_FSPEC "d inex=%d", mpfr_get_prec (y),
1528 + mpfr_log_prec, y, (mpfr_eexp_t) *exp, inex));
1530 if (MPFR_UNLIKELY(MPFR_IS_SINGULAR(x)))
1536 - inex = mpfr_set (y, x, rnd);
1537 + MPFR_BLOCK (flags, inex = mpfr_set (y, x, rnd));
1538 + __gmpfr_flags = saved_flags;
1540 + /* Possible overflow due to the rounding, no possible underflow. */
1542 + if (MPFR_UNLIKELY (MPFR_OVERFLOW (flags)))
1546 + /* An overflow here means that the exponent of y would be larger than
1547 + the one of x, thus x would be rounded to the next power of 2, and
1548 + the returned y should be 1/2 in absolute value, rounded (i.e. with
1549 + possible underflow or overflow). This also implies that x and y are
1550 + different objects, so that the exponent of x has not been lost. */
1551 + MPFR_LOG_MSG (("Internal overflow\n", 0));
1552 + MPFR_ASSERTD (x != y);
1553 + *exp = MPFR_GET_EXP (x) + 1;
1554 + inex2 = mpfr_set_si_2exp (y, MPFR_INT_SIGN (x), -1, rnd);
1555 + MPFR_LOG_MSG (("inex=%d inex2=%d\n", inex, inex2));
1561 *exp = MPFR_GET_EXP (y);
1562 - MPFR_SET_EXP (y, 0);
1563 + /* Do not use MPFR_SET_EXP because the range has not been checked yet. */
1565 return mpfr_check_range (y, inex, rnd);
1567 diff -Naurd mpfr-3.1.3-a/src/mpfr.h mpfr-3.1.3-b/src/mpfr.h
1568 --- mpfr-3.1.3-a/src/mpfr.h 2015-07-17 08:54:48.616811495 +0000
1569 +++ mpfr-3.1.3-b/src/mpfr.h 2015-07-17 08:58:21.114986979 +0000
1571 #define MPFR_VERSION_MAJOR 3
1572 #define MPFR_VERSION_MINOR 1
1573 #define MPFR_VERSION_PATCHLEVEL 3
1574 -#define MPFR_VERSION_STRING "3.1.3-p3"
1575 +#define MPFR_VERSION_STRING "3.1.3-p4"
1577 /* Macros dealing with MPFR VERSION */
1578 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
1579 diff -Naurd mpfr-3.1.3-a/src/version.c mpfr-3.1.3-b/src/version.c
1580 --- mpfr-3.1.3-a/src/version.c 2015-07-17 08:54:48.616811495 +0000
1581 +++ mpfr-3.1.3-b/src/version.c 2015-07-17 08:58:21.118986898 +0000
1584 mpfr_get_version (void)
1586 - return "3.1.3-p3";
1587 + return "3.1.3-p4";
1589 diff -Naurd mpfr-3.1.3-a/tests/tfrexp.c mpfr-3.1.3-b/tests/tfrexp.c
1590 --- mpfr-3.1.3-a/tests/tfrexp.c 2015-06-19 19:55:10.000000000 +0000
1591 +++ mpfr-3.1.3-b/tests/tfrexp.c 2015-07-17 08:58:21.106987142 +0000
1592 @@ -129,12 +129,115 @@
1596 +static void check1 (void)
1598 + mpfr_exp_t emin, emax, e;
1602 + emin = mpfr_get_emin ();
1603 + emax = mpfr_get_emax ();
1604 + set_emin (MPFR_EMIN_MIN);
1605 + set_emax (MPFR_EMAX_MAX);
1607 + mpfr_init2 (x, 7);
1608 + mpfr_inits2 (4, y1, y2, (mpfr_ptr) 0);
1610 + mpfr_set_ui_2exp (x, 1, -2, MPFR_RNDN);
1611 + while (mpfr_regular_p (x))
1613 + /* Test the exponents up to 3 and with the maximum exponent
1614 + (to check potential intermediate overflow). */
1615 + if (MPFR_GET_EXP (x) == 4)
1616 + mpfr_set_exp (x, MPFR_EMAX_MAX);
1617 + e = MPFR_GET_EXP (x);
1618 + for (neg = 0; neg < 2; neg++)
1623 + mpfr_exp_t e1, e2;
1624 + unsigned int flags1, flags2;
1626 + for (red = 0; red < 2; red++)
1630 + /* e1: exponent of the rounded value of x. */
1631 + MPFR_ASSERTN (e1 == e || e1 == e + 1);
1634 + mpfr_clear_flags ();
1636 + mpfr_mul_2ui (y1, x, -e1, (mpfr_rnd_t) r) :
1637 + mpfr_div_2ui (y1, x, e1, (mpfr_rnd_t) r);
1638 + flags1 = __gmpfr_flags;
1642 + inex1 = mpfr_set (y1, x, (mpfr_rnd_t) r);
1643 + e1 = MPFR_IS_INF (y1) ? e + 1 : MPFR_GET_EXP (y1);
1644 + flags1 = inex1 != 0 ? MPFR_FLAGS_INEXACT : 0;
1646 + mpfr_clear_flags ();
1647 + inex2 = mpfr_frexp (&e2, y2, x, (mpfr_rnd_t) r);
1648 + flags2 = __gmpfr_flags;
1649 + set_emin (MPFR_EMIN_MIN);
1650 + set_emax (MPFR_EMAX_MAX);
1651 + if ((!red || e == 0) &&
1652 + (! mpfr_regular_p (y2) || MPFR_GET_EXP (y2) != 0))
1654 + printf ("Error in check1 for %s, red = %d, x = ",
1655 + mpfr_print_rnd_mode ((mpfr_rnd_t) r), red);
1657 + printf ("Expected 1/2 <= |y| < 1, got y = ");
1664 + mpfr_mul_2ui (y2, y2, e2, MPFR_RNDN);
1666 + mpfr_div_2ui (y2, y2, -e2, MPFR_RNDN);
1668 + if (! (SAME_SIGN (inex1, inex2) &&
1669 + mpfr_equal_p (y1, y2) &&
1670 + flags1 == flags2))
1672 + printf ("Error in check1 for %s, red = %d, x = ",
1673 + mpfr_print_rnd_mode ((mpfr_rnd_t) r), red);
1675 + printf ("Expected y1 = ");
1677 + printf ("Got y2 = ");
1679 + printf ("Expected inex ~= %d, got %d\n", inex1, inex2);
1680 + printf ("Expected flags:");
1681 + flags_out (flags1);
1682 + printf ("Got flags: ");
1683 + flags_out (flags2);
1688 + mpfr_neg (x, x, MPFR_RNDN);
1690 + mpfr_nextabove (x);
1693 + mpfr_clears (x, y1, y2, (mpfr_ptr) 0);
1699 main (int argc, char *argv[])
1701 tests_start_mpfr ();