]>
Commit | Line | Data |
---|---|---|
44c63c96 ML |
1 | Submitted By: Bruce Dubbs <bdubbs_at_linuxfromscratch_dot_org> |
2 | Date: 2015-08-25 | |
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 | |
6 | as of 2015-08-25. | |
7 | Description: This patch contains bug fixes identified upstream. | |
8 | ||
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 | |
12 | @@ -0,0 +1 @@ | |
13 | +lngamma-and-doc | |
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 | |
17 | @@ -1 +1 @@ | |
18 | -3.1.3 | |
19 | +3.1.3-p1 | |
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 | |
23 | @@ -810,13 +810,17 @@ | |
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 | |
33 | +gives @minus{}Inf). | |
34 | ||
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. | |
43 | ||
44 | @@ -832,8 +836,8 @@ | |
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) | |
49 | -gives +Inf. | |
50 | +since for any finite or infinite input @var{x}, @code{mpfr_hypot} on | |
51 | +(@var{x},+Inf) gives +Inf. | |
52 | ||
53 | @node Exceptions, Memory Handling, Floating-Point Values on Special Numbers, MPFR Basics | |
54 | @comment node-name, next, previous, up | |
55 | @@ -1581,7 +1585,8 @@ | |
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 | |
65 | @@ -1599,7 +1604,8 @@ | |
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} | |
75 | @@ -1615,7 +1621,7 @@ | |
76 | Set @var{rop} to @math{@var{op1} @GMPtimes{} @var{op2}} rounded in the | |
77 | direction @var{rnd}. | |
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}. | |
82 | @end deftypefun | |
83 | ||
84 | @@ -1635,7 +1641,7 @@ | |
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}. | |
92 | @end deftypefun | |
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. | |
102 | @end deftypefun | |
103 | ||
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. | |
113 | @end deftypefun | |
114 | ||
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). | |
125 | @end deftypefun | |
126 | ||
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}. | |
139 | @end deftypefun | |
140 | ||
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. | |
149 | +by @var{signp}. | |
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. | |
154 | @end deftypefun | |
155 | ||
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 | |
165 | +for rounding. | |
166 | @end deftypefun | |
167 | ||
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}$, | |
171 | @end tex | |
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. | |
179 | @end deftypefun | |
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 | |
183 | @@ -1,4 +1,4 @@ | |
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. | |
186 | ||
187 | This manual documents how to install and use the Multiple Precision | |
188 | Floating-Point Reliable Library, version 3.1.3. | |
189 | @@ -55,7 +55,7 @@ | |
190 | MPFR Copying Conditions | |
191 | *********************** | |
192 | ||
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 | |
198 | @@ -418,7 +418,7 @@ | |
199 | 4.2 Nomenclature and Types | |
200 | ========================== | |
201 | ||
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 | |
207 | @@ -432,7 +432,7 @@ | |
208 | to the other functions supported by MPFR. Unless documented otherwise, | |
209 | the sign bit of a NaN is unspecified. | |
210 | ||
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 | |
216 | @@ -446,7 +446,7 @@ | |
217 | may abort, crash or have undefined behavior (depending on your C | |
218 | implementation). | |
219 | ||
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). | |
233 | ||
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). | |
252 | ||
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 | |
262 | +gives +0. | |
263 | ||
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. | |
266 | @@ -590,8 +593,8 @@ | |
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) | |
271 | -gives +Inf. | |
272 | +Functions::), since for any finite or infinite input X, ‘mpfr_hypot’ on | |
273 | +(X,+Inf) gives +Inf. | |
274 | ||
275 | \1f | |
276 | File: mpfr.info, Node: Exceptions, Next: Memory Handling, Prev: Floating-Point Values on Special Numbers, Up: MPFR Basics | |
277 | @@ -1253,8 +1256,9 @@ | |
278 | mpfr_rnd_t RND) | |
279 | -- Function: int mpfr_add_q (mpfr_t ROP, mpfr_t OP1, mpq_t OP2, | |
280 | mpfr_rnd_t RND) | |
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 @@ | |
290 | mpfr_rnd_t RND) | |
291 | -- Function: int mpfr_sub_q (mpfr_t ROP, mpfr_t OP1, mpq_t OP2, | |
292 | mpfr_rnd_t RND) | |
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 | |
300 | ‘mpfr_sub_d’. | |
301 | @@ -1300,7 +1305,7 @@ | |
302 | mpfr_rnd_t RND) | |
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 | |
308 | ‘mpfr_mul_d’. | |
309 | ||
310 | @@ -1327,21 +1332,24 @@ | |
311 | mpfr_rnd_t RND) | |
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 | |
317 | ‘mpfr_div_d’. | |
318 | ||
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, | |
321 | mpfr_rnd_t RND) | |
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. | |
328 | ||
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 | |
336 | + +Inf. | |
337 | ||
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). | |
350 | ||
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 @@ | |
354 | ||
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’. | |
364 | ||
365 | -- Function: int mpfr_lgamma (mpfr_t ROP, int *SIGNP, mpfr_t OP, | |
366 | mpfr_rnd_t RND) | |
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. | |
377 | ||
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 | |
382 | OP3, mpfr_rnd_t RND) | |
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. | |
389 | ||
390 | -- Function: int mpfr_agm (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, | |
391 | mpfr_rnd_t RND) | |
392 | @@ -1717,9 +1734,10 @@ | |
393 | RND) | |
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 | |
402 | + is NaN. | |
403 | ||
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 @@ | |
407 | 5.16 Internals | |
408 | ============== | |
409 | ||
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’. | |
414 | ||
415 | @@ -3140,7 +3158,7 @@ | |
416 | 0. PREAMBLE | |
417 | ||
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 @@ | |
425 | * Menu: | |
426 | ||
427 | * mpfr_abs: Basic Arithmetic Functions. | |
428 | - (line 160) | |
429 | -* mpfr_acos: Special Functions. (line 51) | |
430 | -* mpfr_acosh: Special Functions. (line 115) | |
431 | + (line 165) | |
432 | +* mpfr_acos: Special Functions. (line 53) | |
433 | +* mpfr_acosh: Special Functions. (line 117) | |
434 | * mpfr_add: Basic Arithmetic Functions. | |
435 | (line 6) | |
436 | * mpfr_add_d: Basic Arithmetic Functions. | |
437 | @@ -3670,15 +3688,15 @@ | |
438 | (line 8) | |
439 | * mpfr_add_z: Basic Arithmetic Functions. | |
440 | (line 14) | |
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. | |
450 | (line 193) | |
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. | |
458 | (line 162) | |
459 | * mpfr_buildopt_gmpinternals_p: Miscellaneous Functions. | |
460 | @@ -3690,7 +3708,7 @@ | |
461 | * mpfr_can_round: Rounding Related Functions. | |
462 | (line 39) | |
463 | * mpfr_cbrt: Basic Arithmetic Functions. | |
464 | - (line 108) | |
465 | + (line 113) | |
466 | * mpfr_ceil: Integer Related Functions. | |
467 | (line 7) | |
468 | * mpfr_check_range: Exception Related Functions. | |
469 | @@ -3735,18 +3753,18 @@ | |
470 | (line 27) | |
471 | * mpfr_cmp_z: Comparison Functions. | |
472 | (line 11) | |
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. | |
482 | (line 109) | |
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. | |
501 | (line 74) | |
502 | -* mpfr_digamma: Special Functions. (line 166) | |
503 | +* mpfr_digamma: Special Functions. (line 172) | |
504 | * mpfr_dim: Basic Arithmetic Functions. | |
505 | - (line 166) | |
506 | + (line 171) | |
507 | * mpfr_div: Basic Arithmetic Functions. | |
508 | - (line 72) | |
509 | + (line 74) | |
510 | * mpfr_divby0_p: Exception Related Functions. | |
511 | (line 134) | |
512 | * mpfr_div_2exp: Compatibility with MPF. | |
513 | (line 49) | |
514 | * mpfr_div_2si: Basic Arithmetic Functions. | |
515 | - (line 181) | |
516 | + (line 186) | |
517 | * mpfr_div_2ui: Basic Arithmetic Functions. | |
518 | - (line 179) | |
519 | + (line 184) | |
520 | * mpfr_div_d: Basic Arithmetic Functions. | |
521 | - (line 84) | |
522 | + (line 86) | |
523 | * mpfr_div_q: Basic Arithmetic Functions. | |
524 | - (line 88) | |
525 | + (line 90) | |
526 | * mpfr_div_si: Basic Arithmetic Functions. | |
527 | - (line 80) | |
528 | + (line 82) | |
529 | * mpfr_div_ui: Basic Arithmetic Functions. | |
530 | - (line 76) | |
531 | + (line 78) | |
532 | * mpfr_div_z: Basic Arithmetic Functions. | |
533 | - (line 86) | |
534 | + (line 88) | |
535 | * mpfr_d_div: Basic Arithmetic Functions. | |
536 | - (line 82) | |
537 | + (line 84) | |
538 | * mpfr_d_sub: Basic Arithmetic Functions. | |
539 | - (line 35) | |
540 | -* mpfr_eint: Special Functions. (line 133) | |
541 | + (line 36) | |
542 | +* mpfr_eint: Special Functions. (line 135) | |
543 | * mpfr_eq: Compatibility with MPF. | |
544 | (line 28) | |
545 | * mpfr_equal_p: Comparison Functions. | |
546 | (line 59) | |
547 | * mpfr_erangeflag_p: Exception Related Functions. | |
548 | (line 137) | |
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. | |
564 | (line 150) | |
565 | * mpfr_fits_sint_p: Conversion Functions. | |
566 | @@ -3815,20 +3833,20 @@ | |
567 | (line 147) | |
568 | * mpfr_floor: Integer Related Functions. | |
569 | (line 8) | |
570 | -* mpfr_fma: Special Functions. (line 203) | |
571 | +* mpfr_fma: Special Functions. (line 209) | |
572 | * mpfr_fmod: Integer Related Functions. | |
573 | (line 92) | |
574 | -* mpfr_fms: Special Functions. (line 205) | |
575 | +* mpfr_fms: Special Functions. (line 211) | |
576 | * mpfr_fprintf: Formatted Output Functions. | |
577 | (line 157) | |
578 | * mpfr_frac: Integer Related Functions. | |
579 | (line 76) | |
580 | -* mpfr_free_cache: Special Functions. (line 244) | |
581 | +* mpfr_free_cache: Special Functions. (line 254) | |
582 | * mpfr_free_str: Conversion Functions. | |
583 | (line 137) | |
584 | * mpfr_frexp: Conversion Functions. | |
585 | (line 45) | |
586 | -* mpfr_gamma: Special Functions. (line 148) | |
587 | +* mpfr_gamma: Special Functions. (line 150) | |
588 | * mpfr_get_d: Conversion Functions. | |
589 | (line 7) | |
590 | * mpfr_get_decimal64: Conversion Functions. | |
591 | @@ -3887,7 +3905,7 @@ | |
592 | (line 56) | |
593 | * mpfr_greater_p: Comparison Functions. | |
594 | (line 55) | |
595 | -* mpfr_hypot: Special Functions. (line 218) | |
596 | +* mpfr_hypot: Special Functions. (line 227) | |
597 | * mpfr_inexflag_p: Exception Related Functions. | |
598 | (line 136) | |
599 | * mpfr_inf_p: Comparison Functions. | |
600 | @@ -3922,21 +3940,21 @@ | |
601 | (line 31) | |
602 | * mpfr_integer_p: Integer Related Functions. | |
603 | (line 119) | |
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. | |
611 | (line 58) | |
612 | * mpfr_lessgreater_p: Comparison Functions. | |
613 | (line 64) | |
614 | * mpfr_less_p: Comparison Functions. | |
615 | (line 57) | |
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. | |
628 | (line 22) | |
629 | @@ -3947,29 +3965,29 @@ | |
630 | * mpfr_modf: Integer Related Functions. | |
631 | (line 82) | |
632 | * mpfr_mul: Basic Arithmetic Functions. | |
633 | - (line 51) | |
634 | + (line 53) | |
635 | * mpfr_mul_2exp: Compatibility with MPF. | |
636 | (line 47) | |
637 | * mpfr_mul_2si: Basic Arithmetic Functions. | |
638 | - (line 174) | |
639 | + (line 179) | |
640 | * mpfr_mul_2ui: Basic Arithmetic Functions. | |
641 | - (line 172) | |
642 | + (line 177) | |
643 | * mpfr_mul_d: Basic Arithmetic Functions. | |
644 | - (line 57) | |
645 | + (line 59) | |
646 | * mpfr_mul_q: Basic Arithmetic Functions. | |
647 | - (line 61) | |
648 | + (line 63) | |
649 | * mpfr_mul_si: Basic Arithmetic Functions. | |
650 | - (line 55) | |
651 | + (line 57) | |
652 | * mpfr_mul_ui: Basic Arithmetic Functions. | |
653 | - (line 53) | |
654 | + (line 55) | |
655 | * mpfr_mul_z: Basic Arithmetic Functions. | |
656 | - (line 59) | |
657 | + (line 61) | |
658 | * mpfr_nanflag_p: Exception Related Functions. | |
659 | (line 135) | |
660 | * mpfr_nan_p: Comparison Functions. | |
661 | (line 39) | |
662 | * mpfr_neg: Basic Arithmetic Functions. | |
663 | - (line 159) | |
664 | + (line 164) | |
665 | * mpfr_nextabove: Miscellaneous Functions. | |
666 | (line 15) | |
667 | * mpfr_nextbelow: Miscellaneous Functions. | |
668 | @@ -3983,13 +4001,13 @@ | |
669 | * mpfr_overflow_p: Exception Related Functions. | |
670 | (line 133) | |
671 | * mpfr_pow: Basic Arithmetic Functions. | |
672 | - (line 116) | |
673 | + (line 121) | |
674 | * mpfr_pow_si: Basic Arithmetic Functions. | |
675 | - (line 120) | |
676 | + (line 125) | |
677 | * mpfr_pow_ui: Basic Arithmetic Functions. | |
678 | - (line 118) | |
679 | + (line 123) | |
680 | * mpfr_pow_z: Basic Arithmetic Functions. | |
681 | - (line 122) | |
682 | + (line 127) | |
683 | * mpfr_prec_round: Rounding Related Functions. | |
684 | (line 13) | |
685 | * ‘mpfr_prec_t’: Nomenclature and Types. | |
686 | @@ -3999,7 +4017,7 @@ | |
687 | * mpfr_print_rnd_mode: Rounding Related Functions. | |
688 | (line 71) | |
689 | * mpfr_rec_sqrt: Basic Arithmetic Functions. | |
690 | - (line 103) | |
691 | + (line 105) | |
692 | * mpfr_regular_p: Comparison Functions. | |
693 | (line 43) | |
694 | * mpfr_reldiff: Compatibility with MPF. | |
695 | @@ -4021,11 +4039,11 @@ | |
696 | * ‘mpfr_rnd_t’: Nomenclature and Types. | |
697 | (line 34) | |
698 | * mpfr_root: Basic Arithmetic Functions. | |
699 | - (line 109) | |
700 | + (line 114) | |
701 | * mpfr_round: Integer Related Functions. | |
702 | (line 9) | |
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. | |
708 | (line 9) | |
709 | * mpfr_setsign: Miscellaneous Functions. | |
710 | @@ -4100,57 +4118,57 @@ | |
711 | (line 49) | |
712 | * mpfr_signbit: Miscellaneous Functions. | |
713 | (line 99) | |
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. | |
723 | - (line 78) | |
724 | + (line 80) | |
725 | * mpfr_si_sub: Basic Arithmetic Functions. | |
726 | - (line 31) | |
727 | + (line 32) | |
728 | * mpfr_snprintf: Formatted Output Functions. | |
729 | (line 180) | |
730 | * mpfr_sprintf: Formatted Output Functions. | |
731 | (line 170) | |
732 | * mpfr_sqr: Basic Arithmetic Functions. | |
733 | - (line 69) | |
734 | + (line 71) | |
735 | * mpfr_sqrt: Basic Arithmetic Functions. | |
736 | - (line 96) | |
737 | + (line 98) | |
738 | * mpfr_sqrt_ui: Basic Arithmetic Functions. | |
739 | - (line 97) | |
740 | + (line 99) | |
741 | * mpfr_strtofr: Assignment Functions. | |
742 | (line 80) | |
743 | * mpfr_sub: Basic Arithmetic Functions. | |
744 | - (line 25) | |
745 | + (line 26) | |
746 | * mpfr_subnormalize: Exception Related Functions. | |
747 | (line 60) | |
748 | * mpfr_sub_d: Basic Arithmetic Functions. | |
749 | - (line 37) | |
750 | + (line 38) | |
751 | * mpfr_sub_q: Basic Arithmetic Functions. | |
752 | - (line 43) | |
753 | + (line 44) | |
754 | * mpfr_sub_si: Basic Arithmetic Functions. | |
755 | - (line 33) | |
756 | + (line 34) | |
757 | * mpfr_sub_ui: Basic Arithmetic Functions. | |
758 | - (line 29) | |
759 | + (line 30) | |
760 | * mpfr_sub_z: Basic Arithmetic Functions. | |
761 | - (line 41) | |
762 | -* mpfr_sum: Special Functions. (line 252) | |
763 | + (line 42) | |
764 | +* mpfr_sum: Special Functions. (line 262) | |
765 | * mpfr_swap: Assignment Functions. | |
766 | (line 150) | |
767 | * ‘mpfr_t’: Nomenclature and Types. | |
768 | (line 6) | |
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. | |
774 | (line 10) | |
775 | * mpfr_ui_div: Basic Arithmetic Functions. | |
776 | - (line 74) | |
777 | + (line 76) | |
778 | * mpfr_ui_pow: Basic Arithmetic Functions. | |
779 | - (line 126) | |
780 | + (line 131) | |
781 | * mpfr_ui_pow_ui: Basic Arithmetic Functions. | |
782 | - (line 124) | |
783 | + (line 129) | |
784 | * mpfr_ui_sub: Basic Arithmetic Functions. | |
785 | - (line 27) | |
786 | + (line 28) | |
787 | * mpfr_underflow_p: Exception Related Functions. | |
788 | (line 132) | |
789 | * mpfr_unordered_p: Comparison Functions. | |
790 | @@ -4181,61 +4199,61 @@ | |
791 | (line 182) | |
792 | * mpfr_vsprintf: Formatted Output Functions. | |
793 | (line 171) | |
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. | |
801 | (line 42) | |
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. | |
807 | - (line 39) | |
808 | + (line 40) | |
809 | ||
810 | ||
811 | \1f | |
812 | Tag Table: | |
813 | Node: Top\7f775 | |
814 | Node: Copying\7f2007 | |
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 | |
895 | \1f | |
896 | End Tag Table | |
897 | ||
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)); | |
903 | ||
904 | /* special cases */ | |
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)))) | |
908 | { | |
909 | - if (MPFR_IS_NAN (x) || MPFR_IS_NEG (x)) | |
910 | + if (MPFR_IS_NAN (x)) | |
911 | { | |
912 | MPFR_SET_NAN (y); | |
913 | MPFR_RET_NAN; | |
914 | } | |
915 | - else /* lngamma(+Inf) = lngamma(+0) = +Inf */ | |
916 | + else /* lngamma(+/-Inf) = lngamma(nonpositive integer) = +Inf */ | |
917 | { | |
918 | - if (MPFR_IS_ZERO (x)) | |
919 | + if (!MPFR_IS_INF (x)) | |
920 | mpfr_set_divby0 (); | |
921 | MPFR_SET_INF (y); | |
922 | MPFR_SET_POS (y); | |
923 | @@ -620,8 +621,8 @@ | |
924 | } | |
925 | } | |
926 | ||
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) | |
931 | { | |
932 | MPFR_SET_NAN (y); | |
933 | MPFR_RET_NAN; | |
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 | |
937 | @@ -27,7 +27,7 @@ | |
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" | |
943 | ||
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 | |
949 | @@ -25,5 +25,5 @@ | |
950 | const char * | |
951 | mpfr_get_version (void) | |
952 | { | |
953 | - return "3.1.3"; | |
954 | + return "3.1.3-p1"; | |
955 | } | |
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 | |
959 | @@ -33,7 +33,7 @@ | |
960 | special (void) | |
961 | { | |
962 | mpfr_t x, y; | |
963 | - int inex; | |
964 | + int i, inex; | |
965 | ||
966 | mpfr_init (x); | |
967 | mpfr_init (y); | |
968 | @@ -46,25 +46,29 @@ | |
969 | exit (1); | |
970 | } | |
971 | ||
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) | |
978 | { | |
979 | - printf ("Error for lngamma(-Inf)\n"); | |
980 | + printf ("Error for lngamma(+Inf)\n"); | |
981 | exit (1); | |
982 | } | |
983 | ||
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) | |
990 | { | |
991 | - printf ("Error for lngamma(+Inf)\n"); | |
992 | + printf ("Error for lngamma(-Inf)\n"); | |
993 | exit (1); | |
994 | } | |
995 | ||
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) | |
1002 | { | |
1003 | printf ("Error for lngamma(+0)\n"); | |
1004 | exit (1); | |
1005 | @@ -72,32 +76,58 @@ | |
1006 | ||
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) | |
1014 | { | |
1015 | printf ("Error for lngamma(-0)\n"); | |
1016 | exit (1); | |
1017 | } | |
1018 | ||
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)) | |
1024 | { | |
1025 | printf ("Error for lngamma(1)\n"); | |
1026 | exit (1); | |
1027 | } | |
1028 | ||
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++) | |
1033 | { | |
1034 | - printf ("Error for lngamma(-1)\n"); | |
1035 | - exit (1); | |
1036 | + int c; | |
1037 | + | |
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) | |
1043 | + { | |
1044 | + printf ("Error for lngamma(-%d)\n", i); | |
1045 | + exit (1); | |
1046 | + } | |
1047 | + if (i & 1) | |
1048 | + { | |
1049 | + mpfr_nextabove (x); | |
1050 | + c = '+'; | |
1051 | + } | |
1052 | + else | |
1053 | + { | |
1054 | + mpfr_nextbelow (x); | |
1055 | + c = '-'; | |
1056 | + } | |
1057 | + mpfr_lngamma (y, x, MPFR_RNDN); | |
1058 | + if (!mpfr_nan_p (y)) | |
1059 | + { | |
1060 | + printf ("Error for lngamma(-%d%cepsilon)\n", i, c); | |
1061 | + exit (1); | |
1062 | + } | |
1063 | } | |
1064 | ||
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)) | |
1069 | { | |
1070 | printf ("Error for lngamma(2)\n"); | |
1071 | exit (1); | |
1072 | @@ -127,7 +157,7 @@ | |
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)) | |
1078 | { | |
1079 | printf ("mpfr_lngamma("CHECK_X2") is wrong:\n" | |
1080 | "expected "); | |
1081 | @@ -143,7 +173,7 @@ | |
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)) | |
1087 | { | |
1088 | printf ("Error in mpfr_lngamma (1)\n"); | |
1089 | exit (1); | |
1090 | @@ -155,7 +185,7 @@ | |
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)) | |
1096 | { | |
1097 | printf ("Error in mpfr_lngamma (120)\n"); | |
1098 | printf ("Expected "); mpfr_print_binary (y); puts (""); | |
1099 | @@ -169,7 +199,7 @@ | |
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)) | |
1105 | { | |
1106 | printf ("Error in mpfr_lngamma (768)\n"); | |
1107 | exit (1); | |
1108 | @@ -185,7 +215,7 @@ | |
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)) | |
1114 | { | |
1115 | printf ("Error for lngamma(0.1100E-66)\n"); | |
1116 | exit (1); | |
1117 | @@ -199,7 +229,7 @@ | |
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)) | |
1123 | { | |
1124 | printf ("Error for lngamma(-2^199+0.5)\n"); | |
1125 | printf ("Got "); | |
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 | |
1129 | @@ -0,0 +1 @@ | |
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 | |
1134 | @@ -1 +1 @@ | |
1135 | -3.1.3-p1 | |
1136 | +3.1.3-p2 | |
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 | |
1140 | @@ -49,7 +49,7 @@ | |
1141 | rnd_mode = MPFR_RNDZ; | |
1142 | return mpfr_underflow (y, rnd_mode, MPFR_SIGN(y)); | |
1143 | } | |
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)); | |
1148 | ||
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 | |
1152 | @@ -32,7 +32,7 @@ | |
1153 | rnd_mode), | |
1154 | ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, inexact)); | |
1155 | ||
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); | |
1159 | else | |
1160 | { | |
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 | |
1164 | @@ -27,7 +27,7 @@ | |
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" | |
1170 | ||
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 | |
1176 | @@ -39,7 +39,7 @@ | |
1177 | { | |
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 | |
1188 | @@ -25,5 +25,5 @@ | |
1189 | const char * | |
1190 | mpfr_get_version (void) | |
1191 | { | |
1192 | - return "3.1.3-p1"; | |
1193 | + return "3.1.3-p2"; | |
1194 | } | |
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); | |
1200 | } | |
1201 | ||
1202 | +/* Cases where the function overflows on n = 0 when rounding is like | |
1203 | + away from zero. */ | |
1204 | +static void | |
1205 | +overflow0 (mpfr_exp_t emax) | |
1206 | +{ | |
1207 | + mpfr_exp_t old_emax; | |
1208 | + mpfr_t x, y1, y2; | |
1209 | + int neg, r, op; | |
1210 | + static char *sop[4] = { "mul_2ui", "mul_2si", "div_2ui", "div_2si" }; | |
1211 | + | |
1212 | + old_emax = mpfr_get_emax (); | |
1213 | + set_emax (emax); | |
1214 | + | |
1215 | + mpfr_init2 (x, 8); | |
1216 | + mpfr_inits2 (6, y1, y2, (mpfr_ptr) 0); | |
1217 | + | |
1218 | + mpfr_set_inf (x, 1); | |
1219 | + mpfr_nextbelow (x); | |
1220 | + | |
1221 | + for (neg = 0; neg <= 1; neg++) | |
1222 | + { | |
1223 | + RND_LOOP (r) | |
1224 | + { | |
1225 | + int inex1, inex2; | |
1226 | + unsigned int flags1, flags2; | |
1227 | + | |
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++) | |
1235 | + { | |
1236 | + mpfr_clear_flags (); | |
1237 | + inex2 = | |
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)) | |
1247 | + { | |
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); | |
1252 | + mpfr_dump (x); | |
1253 | + printf ("Expected "); | |
1254 | + mpfr_dump (y1); | |
1255 | + printf (" with inex = %d, flags =", inex1); | |
1256 | + flags_out (flags1); | |
1257 | + printf ("Got "); | |
1258 | + mpfr_dump (y2); | |
1259 | + printf (" with inex = %d, flags =", inex2); | |
1260 | + flags_out (flags2); | |
1261 | + exit (1); | |
1262 | + } | |
1263 | + } | |
1264 | + } | |
1265 | + mpfr_neg (x, x, MPFR_RNDN); | |
1266 | + } | |
1267 | + | |
1268 | + mpfr_clears (x, y1, y2, (mpfr_ptr) 0); | |
1269 | + set_emax (old_emax); | |
1270 | +} | |
1271 | + | |
1272 | int | |
1273 | main (int argc, char *argv[]) | |
1274 | { | |
1275 | @@ -334,6 +404,11 @@ | |
1276 | underflow0 (); | |
1277 | large0 (); | |
1278 | ||
1279 | + if (mpfr_get_emax () != MPFR_EMAX_MAX) | |
1280 | + overflow0 (mpfr_get_emax ()); | |
1281 | + overflow0 (MPFR_EMAX_MAX); | |
1282 | + overflow0 (-1); | |
1283 | + | |
1284 | tests_end_mpfr (); | |
1285 | return 0; | |
1286 | } | |
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 | |
1290 | @@ -0,0 +1 @@ | |
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 | |
1295 | @@ -1 +1 @@ | |
1296 | -3.1.3-p2 | |
1297 | +3.1.3-p3 | |
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 | |
1301 | @@ -45,7 +45,8 @@ | |
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)); | |
1310 | } | |
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 | |
1314 | @@ -44,7 +44,9 @@ | |
1315 | if (MPFR_UNLIKELY (n >= diffexp)) /* exp - n <= emin - 1 */ | |
1316 | { | |
1317 | if (rnd_mode == MPFR_RNDN && | |
1318 | - (n > diffexp || (inexact >= 0 && mpfr_powerof2_raw (y)))) | |
1319 | + (n > diffexp || | |
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)); | |
1324 | } | |
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 | |
1328 | @@ -27,7 +27,7 @@ | |
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" | |
1334 | ||
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 | |
1340 | @@ -48,7 +48,8 @@ | |
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)); | |
1349 | } | |
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 | |
1353 | @@ -25,5 +25,5 @@ | |
1354 | const char * | |
1355 | mpfr_get_version (void) | |
1356 | { | |
1357 | - return "3.1.3-p2"; | |
1358 | + return "3.1.3-p3"; | |
1359 | } | |
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 | |
1363 | @@ -50,77 +50,82 @@ | |
1364 | { | |
1365 | mpfr_t x, y, z1, z2; | |
1366 | mpfr_exp_t emin; | |
1367 | - int i, k; | |
1368 | + int i, k, s; | |
1369 | int prec; | |
1370 | int rnd; | |
1371 | int div; | |
1372 | int inex1, inex2; | |
1373 | unsigned int flags1, flags2; | |
1374 | ||
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. | |
1381 | */ | |
1382 | emin = mpfr_get_emin (); | |
1383 | set_emin (e); | |
1384 | mpfr_inits2 (8, x, y, (mpfr_ptr) 0); | |
1385 | for (i = 15; i <= 17; i++) | |
1386 | - { | |
1387 | - inex1 = mpfr_set_ui_2exp (x, i, -4, MPFR_RNDN); | |
1388 | - MPFR_ASSERTN (inex1 == 0); | |
1389 | - for (prec = 6; prec >= 3; prec -= 3) | |
1390 | - { | |
1391 | - mpfr_inits2 (prec, z1, z2, (mpfr_ptr) 0); | |
1392 | - RND_LOOP (rnd) | |
1393 | - for (k = 1; k <= 4; k++) | |
1394 | - { | |
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; | |
1405 | - | |
1406 | - for (div = 0; div <= 2; div++) | |
1407 | + for (s = 1; s >= -1; s -= 2) | |
1408 | + { | |
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) | |
1412 | + { | |
1413 | + mpfr_inits2 (prec, z1, z2, (mpfr_ptr) 0); | |
1414 | + RND_LOOP (rnd) | |
1415 | + for (k = 1; k <= 4; k++) | |
1416 | { | |
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)) | |
1430 | - continue; | |
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); | |
1438 | - else | |
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); | |
1447 | - printf ("Got "); | |
1448 | - mpfr_out_str (stdout, 16, 0, z2, MPFR_RNDN); | |
1449 | - printf (", inex = %d, flags = %u\n", SIGN (inex2), flags2); | |
1450 | - exit (1); | |
1451 | - } /* div */ | |
1452 | - } /* k */ | |
1453 | - mpfr_clears (z1, z2, (mpfr_ptr) 0); | |
1454 | - } /* prec */ | |
1455 | - } /* i */ | |
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; | |
1460 | + | |
1461 | + for (div = 0; div <= 2; div++) | |
1462 | + { | |
1463 | + mpfr_clear_flags (); | |
1464 | + inex2 = | |
1465 | + div == 0 ? | |
1466 | + mpfr_mul_2si (z2, x, e - k, (mpfr_rnd_t) rnd) : | |
1467 | + div == 1 ? | |
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)) | |
1473 | + continue; | |
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); | |
1481 | + else | |
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); | |
1491 | + printf ("Got "); | |
1492 | + mpfr_out_str (stdout, 16, 0, z2, MPFR_RNDN); | |
1493 | + printf (", inex = %d, flags = %u\n", | |
1494 | + SIGN (inex2), flags2); | |
1495 | + exit (1); | |
1496 | + } /* div */ | |
1497 | + } /* k */ | |
1498 | + mpfr_clears (z1, z2, (mpfr_ptr) 0); | |
1499 | + } /* prec */ | |
1500 | + } /* i */ | |
1501 | mpfr_clears (x, y, (mpfr_ptr) 0); | |
1502 | set_emin (emin); | |
1503 | } | |
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 | |
1507 | @@ -0,0 +1 @@ | |
1508 | +frexp | |
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 | |
1512 | @@ -1 +1 @@ | |
1513 | -3.1.3-p3 | |
1514 | +3.1.3-p4 | |
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 | |
1518 | @@ -26,6 +26,13 @@ | |
1519 | mpfr_frexp (mpfr_exp_t *exp, mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) | |
1520 | { | |
1521 | int inex; | |
1522 | + unsigned int saved_flags = __gmpfr_flags; | |
1523 | + MPFR_BLOCK_DECL (flags); | |
1524 | + | |
1525 | + MPFR_LOG_FUNC | |
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)); | |
1529 | ||
1530 | if (MPFR_UNLIKELY(MPFR_IS_SINGULAR(x))) | |
1531 | { | |
1532 | @@ -49,8 +56,32 @@ | |
1533 | } | |
1534 | } | |
1535 | ||
1536 | - inex = mpfr_set (y, x, rnd); | |
1537 | + MPFR_BLOCK (flags, inex = mpfr_set (y, x, rnd)); | |
1538 | + __gmpfr_flags = saved_flags; | |
1539 | + | |
1540 | + /* Possible overflow due to the rounding, no possible underflow. */ | |
1541 | + | |
1542 | + if (MPFR_UNLIKELY (MPFR_OVERFLOW (flags))) | |
1543 | + { | |
1544 | + int inex2; | |
1545 | + | |
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)); | |
1556 | + if (inex2 != 0) | |
1557 | + inex = inex2; | |
1558 | + MPFR_RET (inex); | |
1559 | + } | |
1560 | + | |
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. */ | |
1564 | + MPFR_EXP (y) = 0; | |
1565 | return mpfr_check_range (y, inex, rnd); | |
1566 | } | |
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 | |
1570 | @@ -27,7 +27,7 @@ | |
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" | |
1576 | ||
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 | |
1582 | @@ -25,5 +25,5 @@ | |
1583 | const char * | |
1584 | mpfr_get_version (void) | |
1585 | { | |
1586 | - return "3.1.3-p3"; | |
1587 | + return "3.1.3-p4"; | |
1588 | } | |
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 @@ | |
1593 | mpfr_clear (x); | |
1594 | } | |
1595 | ||
1596 | +static void check1 (void) | |
1597 | +{ | |
1598 | + mpfr_exp_t emin, emax, e; | |
1599 | + mpfr_t x, y1, y2; | |
1600 | + int r, neg, red; | |
1601 | + | |
1602 | + emin = mpfr_get_emin (); | |
1603 | + emax = mpfr_get_emax (); | |
1604 | + set_emin (MPFR_EMIN_MIN); | |
1605 | + set_emax (MPFR_EMAX_MAX); | |
1606 | + | |
1607 | + mpfr_init2 (x, 7); | |
1608 | + mpfr_inits2 (4, y1, y2, (mpfr_ptr) 0); | |
1609 | + | |
1610 | + mpfr_set_ui_2exp (x, 1, -2, MPFR_RNDN); | |
1611 | + while (mpfr_regular_p (x)) | |
1612 | + { | |
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++) | |
1619 | + { | |
1620 | + RND_LOOP (r) | |
1621 | + { | |
1622 | + int inex1, inex2; | |
1623 | + mpfr_exp_t e1, e2; | |
1624 | + unsigned int flags1, flags2; | |
1625 | + | |
1626 | + for (red = 0; red < 2; red++) | |
1627 | + { | |
1628 | + if (red) | |
1629 | + { | |
1630 | + /* e1: exponent of the rounded value of x. */ | |
1631 | + MPFR_ASSERTN (e1 == e || e1 == e + 1); | |
1632 | + set_emin (e); | |
1633 | + set_emax (e); | |
1634 | + mpfr_clear_flags (); | |
1635 | + inex1 = e1 < 0 ? | |
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; | |
1639 | + } | |
1640 | + else | |
1641 | + { | |
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; | |
1645 | + } | |
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)) | |
1653 | + { | |
1654 | + printf ("Error in check1 for %s, red = %d, x = ", | |
1655 | + mpfr_print_rnd_mode ((mpfr_rnd_t) r), red); | |
1656 | + mpfr_dump (x); | |
1657 | + printf ("Expected 1/2 <= |y| < 1, got y = "); | |
1658 | + mpfr_dump (y2); | |
1659 | + exit (1); | |
1660 | + } | |
1661 | + if (!red) | |
1662 | + { | |
1663 | + if (e2 > 0) | |
1664 | + mpfr_mul_2ui (y2, y2, e2, MPFR_RNDN); | |
1665 | + else if (e2 < 0) | |
1666 | + mpfr_div_2ui (y2, y2, -e2, MPFR_RNDN); | |
1667 | + } | |
1668 | + if (! (SAME_SIGN (inex1, inex2) && | |
1669 | + mpfr_equal_p (y1, y2) && | |
1670 | + flags1 == flags2)) | |
1671 | + { | |
1672 | + printf ("Error in check1 for %s, red = %d, x = ", | |
1673 | + mpfr_print_rnd_mode ((mpfr_rnd_t) r), red); | |
1674 | + mpfr_dump (x); | |
1675 | + printf ("Expected y1 = "); | |
1676 | + mpfr_dump (y1); | |
1677 | + printf ("Got y2 = "); | |
1678 | + mpfr_dump (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); | |
1684 | + exit (1); | |
1685 | + } | |
1686 | + } | |
1687 | + } | |
1688 | + mpfr_neg (x, x, MPFR_RNDN); | |
1689 | + } | |
1690 | + mpfr_nextabove (x); | |
1691 | + } | |
1692 | + | |
1693 | + mpfr_clears (x, y1, y2, (mpfr_ptr) 0); | |
1694 | + set_emin (emin); | |
1695 | + set_emax (emax); | |
1696 | +} | |
1697 | + | |
1698 | int | |
1699 | main (int argc, char *argv[]) | |
1700 | { | |
1701 | tests_start_mpfr (); | |
1702 | ||
1703 | check_special (); | |
1704 | + check1 (); | |
1705 | ||
1706 | tests_end_mpfr (); | |
1707 | return 0; |