1 /* mpfr.h -- Include file for mpfr.
3 Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
4 Contributed by the Arenaire and Caramel projects, INRIA.
6 This file is part of the GNU MPFR Library.
8 The GNU MPFR Library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
13 The GNU MPFR Library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see
20 http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
21 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
26 /* Define MPFR version number */
27 #define MPFR_VERSION_MAJOR 3
28 #define MPFR_VERSION_MINOR 1
29 #define MPFR_VERSION_PATCHLEVEL 0
30 #define MPFR_VERSION_STRING "3.1.0"
32 /* Macros dealing with MPFR VERSION */
33 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
34 #define MPFR_VERSION \
35 MPFR_VERSION_NUM(MPFR_VERSION_MAJOR,MPFR_VERSION_MINOR,MPFR_VERSION_PATCHLEVEL)
37 /* Check if GMP is included, and try to include it (Works with local GMP) */
42 /* Avoid some problems with macro expansion if the user defines macros
43 with the same name as keywords. By convention, identifiers and macro
44 names starting with mpfr_ are reserved by MPFR. */
45 typedef void mpfr_void;
47 typedef unsigned int mpfr_uint;
48 typedef long mpfr_long;
49 typedef unsigned long mpfr_ulong;
50 typedef size_t mpfr_size_t;
52 /* Definition of rounding modes (DON'T USE MPFR_RNDNA!).
53 Warning! Changing the contents of this enum should be seen as an
54 interface change since the old and the new types are not compatible
55 (the integer type compatible with the enumerated type can even change,
56 see ISO C99, 6.7.2.2#4), and in Makefile.am, AGE should be set to 0.
58 MPFR_RNDU must appear just before MPFR_RNDD (see
59 MPFR_IS_RNDUTEST_OR_RNDDNOTTEST in mpfr-impl.h).
61 MPFR_RNDF has been added, though not implemented yet, in order to avoid
62 to break the ABI once faithful rounding gets implemented.
64 If you change the order of the rounding modes, please update the routines
65 in texceptions.c which assume 0=RNDN, 1=RNDZ, 2=RNDU, 3=RNDD, 4=RNDA.
68 MPFR_RNDN=0, /* round to nearest, with ties to even */
69 MPFR_RNDZ, /* round toward zero */
70 MPFR_RNDU, /* round toward +Inf */
71 MPFR_RNDD, /* round toward -Inf */
72 MPFR_RNDA, /* round away from zero */
73 MPFR_RNDF, /* faithful rounding (not implemented yet) */
74 MPFR_RNDNA=-1 /* round to nearest, with ties away from zero (mpfr_round) */
77 /* kept for compatibility with MPFR 2.4.x and before */
78 #define GMP_RNDN MPFR_RNDN
79 #define GMP_RNDZ MPFR_RNDZ
80 #define GMP_RNDU MPFR_RNDU
81 #define GMP_RNDD MPFR_RNDD
83 /* Note: With the following default choices for _MPFR_PREC_FORMAT and
84 _MPFR_EXP_FORMAT, mpfr_exp_t will be the same as [mp_exp_t] (at least
87 /* Define precision: 1 (short), 2 (int) or 3 (long) (DON'T USE IT!) */
88 #ifndef _MPFR_PREC_FORMAT
89 # if __GMP_MP_SIZE_T_INT == 1
90 # define _MPFR_PREC_FORMAT 2
92 # define _MPFR_PREC_FORMAT 3
96 /* Define exponent: 1 (short), 2 (int), 3 (long) or 4 (intmax_t)
98 #ifndef _MPFR_EXP_FORMAT
99 # define _MPFR_EXP_FORMAT _MPFR_PREC_FORMAT
102 #if _MPFR_PREC_FORMAT > _MPFR_EXP_FORMAT
103 # error "mpfr_prec_t must not be larger than mpfr_exp_t"
106 /* Let's make mpfr_prec_t signed in order to avoid problems due to the
107 usual arithmetic conversions when mixing mpfr_prec_t and mpfr_exp_t
108 in an expression (for error analysis) if casts are forgotten. */
109 #if _MPFR_PREC_FORMAT == 1
110 typedef short mpfr_prec_t;
111 typedef unsigned short mpfr_uprec_t;
112 #elif _MPFR_PREC_FORMAT == 2
113 typedef int mpfr_prec_t;
114 typedef unsigned int mpfr_uprec_t;
115 #elif _MPFR_PREC_FORMAT == 3
116 typedef long mpfr_prec_t;
117 typedef unsigned long mpfr_uprec_t;
119 # error "Invalid MPFR Prec format"
122 /* Definition of precision limits without needing <limits.h> */
123 /* Note: the casts allows the expression to yield the wanted behavior
124 for _MPFR_PREC_FORMAT == 1 (due to integer promotion rules). */
125 #define MPFR_PREC_MIN 2
126 #define MPFR_PREC_MAX ((mpfr_prec_t)((mpfr_uprec_t)(~(mpfr_uprec_t)0)>>1))
128 /* Definition of sign */
129 typedef int mpfr_sign_t;
131 /* Definition of the exponent. _MPFR_EXP_FORMAT must be large enough
132 so that mpfr_exp_t has at least 32 bits. */
133 #if _MPFR_EXP_FORMAT == 1
134 typedef short mpfr_exp_t;
135 typedef unsigned short mpfr_uexp_t;
136 #elif _MPFR_EXP_FORMAT == 2
137 typedef int mpfr_exp_t;
138 typedef unsigned int mpfr_uexp_t;
139 #elif _MPFR_EXP_FORMAT == 3
140 typedef long mpfr_exp_t;
141 typedef unsigned long mpfr_uexp_t;
142 #elif _MPFR_EXP_FORMAT == 4
143 /* Note: in this case, intmax_t and uintmax_t must be defined before
144 the inclusion of mpfr.h (we do not include <stdint.h> here because
145 of some non-ISO C99 implementations that support these types). */
146 typedef intmax_t mpfr_exp_t;
147 typedef uintmax_t mpfr_uexp_t;
149 # error "Invalid MPFR Exp format"
152 /* Definition of the standard exponent limits */
153 #define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((mpfr_ulong) 1 << 30) - 1))
154 #define MPFR_EMIN_DEFAULT (-(MPFR_EMAX_DEFAULT))
156 /* DON'T USE THIS! (For MPFR-public macros only, see below.)
157 The mpfr_sgn macro uses the fact that __MPFR_EXP_NAN and __MPFR_EXP_ZERO
158 are the smallest values. */
159 #define __MPFR_EXP_MAX ((mpfr_exp_t) (((mpfr_uexp_t) -1) >> 1))
160 #define __MPFR_EXP_NAN (1 - __MPFR_EXP_MAX)
161 #define __MPFR_EXP_ZERO (0 - __MPFR_EXP_MAX)
162 #define __MPFR_EXP_INF (2 - __MPFR_EXP_MAX)
164 /* Definition of the main structure */
166 mpfr_prec_t _mpfr_prec;
167 mpfr_sign_t _mpfr_sign;
168 mpfr_exp_t _mpfr_exp;
172 /* Compatibility with previous types of MPFR */
174 # define mp_rnd_t mpfr_rnd_t
177 # define mp_prec_t mpfr_prec_t
181 The represented number is
182 _sign*(_d[k-1]/B+_d[k-2]/B^2+...+_d[0]/B^k)*2^_exp
183 where k=ceil(_mp_prec/GMP_NUMB_BITS) and B=2^GMP_NUMB_BITS.
185 For the msb (most significant bit) normalized representation, we must have
186 _d[k-1]>=B/2, unless the number is singular.
188 We must also have the last k*GMP_NUMB_BITS-_prec bits set to zero.
191 typedef __mpfr_struct mpfr_t[1];
192 typedef __mpfr_struct *mpfr_ptr;
193 typedef __gmp_const __mpfr_struct *mpfr_srcptr;
195 /* For those who need a direct and fast access to the sign field.
196 However it is not in the API, thus use it at your own risk: it might
197 not be supported, or change name, in further versions!
198 Unfortunately, it must be defined here (instead of MPFR's internal
199 header file mpfr-impl.h) because it is used by some macros below.
201 #define MPFR_SIGN(x) ((x)->_mpfr_sign)
203 /* Stack interface */
206 MPFR_INF_KIND = 1, MPFR_ZERO_KIND = 2, MPFR_REGULAR_KIND = 3
210 + size_t: Standard size_t
211 + __GMP_ATTRIBUTE_PURE Attribute for math functions.
212 + __GMP_NOTHROW For C++: can't throw .
213 + __GMP_EXTERN_INLINE Attribute for inline function.
214 * __gmp_const const (Supports for K&R compiler only for mpfr.h).
215 + __GMP_DECLSPEC_EXPORT compiling to go into a DLL
216 + __GMP_DECLSPEC_IMPORT compiling to go into a application
218 /* Extra MPFR defines */
219 #define __MPFR_SENTINEL_ATTR
220 #if defined (__GNUC__)
222 # undef __MPFR_SENTINEL_ATTR
223 # define __MPFR_SENTINEL_ATTR __attribute__ ((sentinel))
227 /* Prototypes: Support of K&R compiler */
228 #if defined (__GMP_PROTO)
229 # define _MPFR_PROTO __GMP_PROTO
230 #elif defined (__STDC__) || defined (__cplusplus)
231 # define _MPFR_PROTO(x) x
233 # define _MPFR_PROTO(x) ()
235 /* Support for WINDOWS Dll:
236 Check if we are inside a MPFR build, and if so export the functions.
237 Otherwise does the same thing as GMP */
238 #if defined(__MPFR_WITHIN_MPFR) && __GMP_LIBGMP_DLL
239 # define __MPFR_DECLSPEC __GMP_DECLSPEC_EXPORT
241 # define __MPFR_DECLSPEC __GMP_DECLSPEC
244 /* Use MPFR_DEPRECATED to mark MPFR functions, types or variables as
245 deprecated. Code inspired by Apache Subversion's svn_types.h file. */
246 #if defined(__GNUC__) && \
247 (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
248 # define MPFR_DEPRECATED __attribute__ ((deprecated))
249 #elif defined(_MSC_VER) && _MSC_VER >= 1300
250 # define MPFR_DEPRECATED __declspec(deprecated)
252 # define MPFR_DEPRECATED
255 /* Note: In order to be declared, some functions need a specific
256 system header to be included *before* "mpfr.h". If the user
257 forgets to include the header, the MPFR function prototype in
258 the user object file is not correct. To avoid wrong results,
259 we raise a linker error in that case by changing their internal
260 name in the library (prefixed by __gmpfr instead of mpfr). See
261 the lines of the form "#define mpfr_xxx __gmpfr_xxx" below. */
263 #if defined (__cplusplus)
267 __MPFR_DECLSPEC __gmp_const char * mpfr_get_version _MPFR_PROTO ((void));
268 __MPFR_DECLSPEC __gmp_const char * mpfr_get_patches _MPFR_PROTO ((void));
269 __MPFR_DECLSPEC int mpfr_buildopt_tls_p _MPFR_PROTO ((void));
270 __MPFR_DECLSPEC int mpfr_buildopt_decimal_p _MPFR_PROTO ((void));
271 __MPFR_DECLSPEC int mpfr_buildopt_gmpinternals_p _MPFR_PROTO ((void));
272 __MPFR_DECLSPEC __gmp_const char * mpfr_buildopt_tune_case _MPFR_PROTO ((void));
274 __MPFR_DECLSPEC mpfr_exp_t mpfr_get_emin _MPFR_PROTO ((void));
275 __MPFR_DECLSPEC int mpfr_set_emin _MPFR_PROTO ((mpfr_exp_t));
276 __MPFR_DECLSPEC mpfr_exp_t mpfr_get_emin_min _MPFR_PROTO ((void));
277 __MPFR_DECLSPEC mpfr_exp_t mpfr_get_emin_max _MPFR_PROTO ((void));
278 __MPFR_DECLSPEC mpfr_exp_t mpfr_get_emax _MPFR_PROTO ((void));
279 __MPFR_DECLSPEC int mpfr_set_emax _MPFR_PROTO ((mpfr_exp_t));
280 __MPFR_DECLSPEC mpfr_exp_t mpfr_get_emax_min _MPFR_PROTO ((void));
281 __MPFR_DECLSPEC mpfr_exp_t mpfr_get_emax_max _MPFR_PROTO ((void));
283 __MPFR_DECLSPEC void mpfr_set_default_rounding_mode _MPFR_PROTO((mpfr_rnd_t));
284 __MPFR_DECLSPEC mpfr_rnd_t mpfr_get_default_rounding_mode _MPFR_PROTO((void));
285 __MPFR_DECLSPEC __gmp_const char *
286 mpfr_print_rnd_mode _MPFR_PROTO((mpfr_rnd_t));
288 __MPFR_DECLSPEC void mpfr_clear_flags _MPFR_PROTO ((void));
289 __MPFR_DECLSPEC void mpfr_clear_underflow _MPFR_PROTO ((void));
290 __MPFR_DECLSPEC void mpfr_clear_overflow _MPFR_PROTO ((void));
291 __MPFR_DECLSPEC void mpfr_clear_divby0 _MPFR_PROTO ((void));
292 __MPFR_DECLSPEC void mpfr_clear_nanflag _MPFR_PROTO ((void));
293 __MPFR_DECLSPEC void mpfr_clear_inexflag _MPFR_PROTO ((void));
294 __MPFR_DECLSPEC void mpfr_clear_erangeflag _MPFR_PROTO ((void));
296 __MPFR_DECLSPEC void mpfr_set_underflow _MPFR_PROTO ((void));
297 __MPFR_DECLSPEC void mpfr_set_overflow _MPFR_PROTO ((void));
298 __MPFR_DECLSPEC void mpfr_set_divby0 _MPFR_PROTO ((void));
299 __MPFR_DECLSPEC void mpfr_set_nanflag _MPFR_PROTO ((void));
300 __MPFR_DECLSPEC void mpfr_set_inexflag _MPFR_PROTO ((void));
301 __MPFR_DECLSPEC void mpfr_set_erangeflag _MPFR_PROTO ((void));
303 __MPFR_DECLSPEC int mpfr_underflow_p _MPFR_PROTO ((void));
304 __MPFR_DECLSPEC int mpfr_overflow_p _MPFR_PROTO ((void));
305 __MPFR_DECLSPEC int mpfr_divby0_p _MPFR_PROTO ((void));
306 __MPFR_DECLSPEC int mpfr_nanflag_p _MPFR_PROTO ((void));
307 __MPFR_DECLSPEC int mpfr_inexflag_p _MPFR_PROTO ((void));
308 __MPFR_DECLSPEC int mpfr_erangeflag_p _MPFR_PROTO ((void));
311 mpfr_check_range _MPFR_PROTO ((mpfr_ptr, int, mpfr_rnd_t));
313 __MPFR_DECLSPEC void mpfr_init2 _MPFR_PROTO ((mpfr_ptr, mpfr_prec_t));
314 __MPFR_DECLSPEC void mpfr_init _MPFR_PROTO ((mpfr_ptr));
315 __MPFR_DECLSPEC void mpfr_clear _MPFR_PROTO ((mpfr_ptr));
318 mpfr_inits2 _MPFR_PROTO ((mpfr_prec_t, mpfr_ptr, ...)) __MPFR_SENTINEL_ATTR;
320 mpfr_inits _MPFR_PROTO ((mpfr_ptr, ...)) __MPFR_SENTINEL_ATTR;
322 mpfr_clears _MPFR_PROTO ((mpfr_ptr, ...)) __MPFR_SENTINEL_ATTR;
325 mpfr_prec_round _MPFR_PROTO ((mpfr_ptr, mpfr_prec_t, mpfr_rnd_t));
327 mpfr_can_round _MPFR_PROTO ((mpfr_srcptr, mpfr_exp_t, mpfr_rnd_t, mpfr_rnd_t,
329 __MPFR_DECLSPEC mpfr_prec_t mpfr_min_prec _MPFR_PROTO ((mpfr_srcptr));
331 __MPFR_DECLSPEC mpfr_exp_t mpfr_get_exp _MPFR_PROTO ((mpfr_srcptr));
332 __MPFR_DECLSPEC int mpfr_set_exp _MPFR_PROTO ((mpfr_ptr, mpfr_exp_t));
333 __MPFR_DECLSPEC mpfr_prec_t mpfr_get_prec _MPFR_PROTO((mpfr_srcptr));
334 __MPFR_DECLSPEC void mpfr_set_prec _MPFR_PROTO((mpfr_ptr, mpfr_prec_t));
335 __MPFR_DECLSPEC void mpfr_set_prec_raw _MPFR_PROTO((mpfr_ptr, mpfr_prec_t));
336 __MPFR_DECLSPEC void mpfr_set_default_prec _MPFR_PROTO((mpfr_prec_t));
337 __MPFR_DECLSPEC mpfr_prec_t mpfr_get_default_prec _MPFR_PROTO((void));
339 __MPFR_DECLSPEC int mpfr_set_d _MPFR_PROTO ((mpfr_ptr, double, mpfr_rnd_t));
340 __MPFR_DECLSPEC int mpfr_set_flt _MPFR_PROTO ((mpfr_ptr, float, mpfr_rnd_t));
341 #ifdef MPFR_WANT_DECIMAL_FLOATS
342 __MPFR_DECLSPEC int mpfr_set_decimal64 _MPFR_PROTO ((mpfr_ptr, _Decimal64,
346 mpfr_set_ld _MPFR_PROTO ((mpfr_ptr, long double, mpfr_rnd_t));
348 mpfr_set_z _MPFR_PROTO ((mpfr_ptr, mpz_srcptr, mpfr_rnd_t));
350 mpfr_set_z_2exp _MPFR_PROTO ((mpfr_ptr, mpz_srcptr, mpfr_exp_t, mpfr_rnd_t));
351 __MPFR_DECLSPEC void mpfr_set_nan _MPFR_PROTO ((mpfr_ptr));
352 __MPFR_DECLSPEC void mpfr_set_inf _MPFR_PROTO ((mpfr_ptr, int));
353 __MPFR_DECLSPEC void mpfr_set_zero _MPFR_PROTO ((mpfr_ptr, int));
355 mpfr_set_f _MPFR_PROTO ((mpfr_ptr, mpf_srcptr, mpfr_rnd_t));
357 mpfr_get_f _MPFR_PROTO ((mpf_ptr, mpfr_srcptr, mpfr_rnd_t));
358 __MPFR_DECLSPEC int mpfr_set_si _MPFR_PROTO ((mpfr_ptr, long, mpfr_rnd_t));
360 mpfr_set_ui _MPFR_PROTO ((mpfr_ptr, unsigned long, mpfr_rnd_t));
362 mpfr_set_si_2exp _MPFR_PROTO ((mpfr_ptr, long, mpfr_exp_t, mpfr_rnd_t));
364 mpfr_set_ui_2exp _MPFR_PROTO ((mpfr_ptr,unsigned long,mpfr_exp_t,mpfr_rnd_t));
366 mpfr_set_q _MPFR_PROTO ((mpfr_ptr, mpq_srcptr, mpfr_rnd_t));
368 mpfr_set_str _MPFR_PROTO ((mpfr_ptr, __gmp_const char *, int, mpfr_rnd_t));
370 mpfr_init_set_str _MPFR_PROTO ((mpfr_ptr, __gmp_const char *, int,
373 mpfr_set4 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t, int));
375 mpfr_abs _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
377 mpfr_set _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
378 __MPFR_DECLSPEC int mpfr_neg _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
379 __MPFR_DECLSPEC int mpfr_signbit _MPFR_PROTO ((mpfr_srcptr));
381 mpfr_setsign _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, int, mpfr_rnd_t));
383 mpfr_copysign _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t));
385 __MPFR_DECLSPEC mpfr_exp_t mpfr_get_z_2exp _MPFR_PROTO ((mpz_ptr, mpfr_srcptr));
386 __MPFR_DECLSPEC float mpfr_get_flt _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
387 __MPFR_DECLSPEC double mpfr_get_d _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
388 #ifdef MPFR_WANT_DECIMAL_FLOATS
389 __MPFR_DECLSPEC _Decimal64 mpfr_get_decimal64 _MPFR_PROTO ((mpfr_srcptr,
392 __MPFR_DECLSPEC long double mpfr_get_ld _MPFR_PROTO ((mpfr_srcptr,
394 __MPFR_DECLSPEC double mpfr_get_d1 _MPFR_PROTO ((mpfr_srcptr));
395 __MPFR_DECLSPEC double mpfr_get_d_2exp _MPFR_PROTO ((long*, mpfr_srcptr,
397 __MPFR_DECLSPEC long double mpfr_get_ld_2exp _MPFR_PROTO ((long*, mpfr_srcptr,
399 __MPFR_DECLSPEC int mpfr_frexp _MPFR_PROTO ((mpfr_exp_t*, mpfr_ptr,
400 mpfr_srcptr, mpfr_rnd_t));
401 __MPFR_DECLSPEC long mpfr_get_si _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
402 __MPFR_DECLSPEC unsigned long mpfr_get_ui _MPFR_PROTO ((mpfr_srcptr,
404 __MPFR_DECLSPEC char*mpfr_get_str _MPFR_PROTO ((char*, mpfr_exp_t*, int, size_t,
405 mpfr_srcptr, mpfr_rnd_t));
406 __MPFR_DECLSPEC int mpfr_get_z _MPFR_PROTO ((mpz_ptr z, mpfr_srcptr f,
409 __MPFR_DECLSPEC void mpfr_free_str _MPFR_PROTO ((char *));
411 __MPFR_DECLSPEC int mpfr_urandom _MPFR_PROTO ((mpfr_ptr, gmp_randstate_t,
413 __MPFR_DECLSPEC int mpfr_grandom _MPFR_PROTO ((mpfr_ptr, mpfr_ptr, gmp_randstate_t,
415 __MPFR_DECLSPEC int mpfr_urandomb _MPFR_PROTO ((mpfr_ptr, gmp_randstate_t));
417 __MPFR_DECLSPEC void mpfr_nextabove _MPFR_PROTO ((mpfr_ptr));
418 __MPFR_DECLSPEC void mpfr_nextbelow _MPFR_PROTO ((mpfr_ptr));
419 __MPFR_DECLSPEC void mpfr_nexttoward _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr));
421 __MPFR_DECLSPEC int mpfr_printf _MPFR_PROTO ((__gmp_const char*, ...));
422 __MPFR_DECLSPEC int mpfr_asprintf _MPFR_PROTO ((char**, __gmp_const char*,
424 __MPFR_DECLSPEC int mpfr_sprintf _MPFR_PROTO ((char*, __gmp_const char*,
426 __MPFR_DECLSPEC int mpfr_snprintf _MPFR_PROTO ((char*, size_t,
427 __gmp_const char*, ...));
429 __MPFR_DECLSPEC int mpfr_pow _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
430 mpfr_srcptr, mpfr_rnd_t));
431 __MPFR_DECLSPEC int mpfr_pow_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
432 long int, mpfr_rnd_t));
433 __MPFR_DECLSPEC int mpfr_pow_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
434 unsigned long int, mpfr_rnd_t));
435 __MPFR_DECLSPEC int mpfr_ui_pow_ui _MPFR_PROTO ((mpfr_ptr, unsigned long int,
436 unsigned long int, mpfr_rnd_t));
437 __MPFR_DECLSPEC int mpfr_ui_pow _MPFR_PROTO ((mpfr_ptr, unsigned long int,
438 mpfr_srcptr, mpfr_rnd_t));
439 __MPFR_DECLSPEC int mpfr_pow_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
440 mpz_srcptr, mpfr_rnd_t));
442 __MPFR_DECLSPEC int mpfr_sqrt _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
444 __MPFR_DECLSPEC int mpfr_sqrt_ui _MPFR_PROTO ((mpfr_ptr, unsigned long,
446 __MPFR_DECLSPEC int mpfr_rec_sqrt _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
449 __MPFR_DECLSPEC int mpfr_add _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
450 mpfr_srcptr, mpfr_rnd_t));
451 __MPFR_DECLSPEC int mpfr_sub _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
452 mpfr_srcptr, mpfr_rnd_t));
453 __MPFR_DECLSPEC int mpfr_mul _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
454 mpfr_srcptr, mpfr_rnd_t));
455 __MPFR_DECLSPEC int mpfr_div _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
456 mpfr_srcptr, mpfr_rnd_t));
458 __MPFR_DECLSPEC int mpfr_add_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
459 unsigned long, mpfr_rnd_t));
460 __MPFR_DECLSPEC int mpfr_sub_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
461 unsigned long, mpfr_rnd_t));
462 __MPFR_DECLSPEC int mpfr_ui_sub _MPFR_PROTO ((mpfr_ptr, unsigned long,
463 mpfr_srcptr, mpfr_rnd_t));
464 __MPFR_DECLSPEC int mpfr_mul_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
465 unsigned long, mpfr_rnd_t));
466 __MPFR_DECLSPEC int mpfr_div_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
467 unsigned long, mpfr_rnd_t));
468 __MPFR_DECLSPEC int mpfr_ui_div _MPFR_PROTO ((mpfr_ptr, unsigned long,
469 mpfr_srcptr, mpfr_rnd_t));
471 __MPFR_DECLSPEC int mpfr_add_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
472 long int, mpfr_rnd_t));
473 __MPFR_DECLSPEC int mpfr_sub_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
474 long int, mpfr_rnd_t));
475 __MPFR_DECLSPEC int mpfr_si_sub _MPFR_PROTO ((mpfr_ptr, long int,
476 mpfr_srcptr, mpfr_rnd_t));
477 __MPFR_DECLSPEC int mpfr_mul_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
478 long int, mpfr_rnd_t));
479 __MPFR_DECLSPEC int mpfr_div_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
480 long int, mpfr_rnd_t));
481 __MPFR_DECLSPEC int mpfr_si_div _MPFR_PROTO ((mpfr_ptr, long int,
482 mpfr_srcptr, mpfr_rnd_t));
484 __MPFR_DECLSPEC int mpfr_add_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
485 double, mpfr_rnd_t));
486 __MPFR_DECLSPEC int mpfr_sub_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
487 double, mpfr_rnd_t));
488 __MPFR_DECLSPEC int mpfr_d_sub _MPFR_PROTO ((mpfr_ptr, double,
489 mpfr_srcptr, mpfr_rnd_t));
490 __MPFR_DECLSPEC int mpfr_mul_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
491 double, mpfr_rnd_t));
492 __MPFR_DECLSPEC int mpfr_div_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
493 double, mpfr_rnd_t));
494 __MPFR_DECLSPEC int mpfr_d_div _MPFR_PROTO ((mpfr_ptr, double,
495 mpfr_srcptr, mpfr_rnd_t));
497 __MPFR_DECLSPEC int mpfr_sqr _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
499 __MPFR_DECLSPEC int mpfr_const_pi _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
500 __MPFR_DECLSPEC int mpfr_const_log2 _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
501 __MPFR_DECLSPEC int mpfr_const_euler _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
502 __MPFR_DECLSPEC int mpfr_const_catalan _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
504 __MPFR_DECLSPEC int mpfr_agm _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
507 __MPFR_DECLSPEC int mpfr_log _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
508 __MPFR_DECLSPEC int mpfr_log2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
509 __MPFR_DECLSPEC int mpfr_log10 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
511 __MPFR_DECLSPEC int mpfr_log1p _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
514 __MPFR_DECLSPEC int mpfr_exp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
515 __MPFR_DECLSPEC int mpfr_exp2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
516 __MPFR_DECLSPEC int mpfr_exp10 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
518 __MPFR_DECLSPEC int mpfr_expm1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
520 __MPFR_DECLSPEC int mpfr_eint _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
521 __MPFR_DECLSPEC int mpfr_li2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
523 __MPFR_DECLSPEC int mpfr_cmp _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
524 __MPFR_DECLSPEC int mpfr_cmp3 _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr, int));
525 __MPFR_DECLSPEC int mpfr_cmp_d _MPFR_PROTO ((mpfr_srcptr, double));
526 __MPFR_DECLSPEC int mpfr_cmp_ld _MPFR_PROTO ((mpfr_srcptr, long double));
527 __MPFR_DECLSPEC int mpfr_cmpabs _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
528 __MPFR_DECLSPEC int mpfr_cmp_ui _MPFR_PROTO ((mpfr_srcptr, unsigned long));
529 __MPFR_DECLSPEC int mpfr_cmp_si _MPFR_PROTO ((mpfr_srcptr, long));
530 __MPFR_DECLSPEC int mpfr_cmp_ui_2exp _MPFR_PROTO ((mpfr_srcptr, unsigned long,
532 __MPFR_DECLSPEC int mpfr_cmp_si_2exp _MPFR_PROTO ((mpfr_srcptr, long,
534 __MPFR_DECLSPEC void mpfr_reldiff _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
535 mpfr_srcptr, mpfr_rnd_t));
536 __MPFR_DECLSPEC int mpfr_eq _MPFR_PROTO((mpfr_srcptr, mpfr_srcptr,
538 __MPFR_DECLSPEC int mpfr_sgn _MPFR_PROTO ((mpfr_srcptr));
540 __MPFR_DECLSPEC int mpfr_mul_2exp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
541 unsigned long, mpfr_rnd_t));
542 __MPFR_DECLSPEC int mpfr_div_2exp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
543 unsigned long, mpfr_rnd_t));
544 __MPFR_DECLSPEC int mpfr_mul_2ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
545 unsigned long, mpfr_rnd_t));
546 __MPFR_DECLSPEC int mpfr_div_2ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
547 unsigned long, mpfr_rnd_t));
548 __MPFR_DECLSPEC int mpfr_mul_2si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
550 __MPFR_DECLSPEC int mpfr_div_2si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
553 __MPFR_DECLSPEC int mpfr_rint _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
554 __MPFR_DECLSPEC int mpfr_round _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
555 __MPFR_DECLSPEC int mpfr_trunc _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
556 __MPFR_DECLSPEC int mpfr_ceil _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
557 __MPFR_DECLSPEC int mpfr_floor _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
558 __MPFR_DECLSPEC int mpfr_rint_round _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
560 __MPFR_DECLSPEC int mpfr_rint_trunc _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
562 __MPFR_DECLSPEC int mpfr_rint_ceil _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
564 __MPFR_DECLSPEC int mpfr_rint_floor _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
566 __MPFR_DECLSPEC int mpfr_frac _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
567 __MPFR_DECLSPEC int mpfr_modf _MPFR_PROTO ((mpfr_ptr, mpfr_ptr, mpfr_srcptr,
569 __MPFR_DECLSPEC int mpfr_remquo _MPFR_PROTO ((mpfr_ptr, long*, mpfr_srcptr,
570 mpfr_srcptr, mpfr_rnd_t));
571 __MPFR_DECLSPEC int mpfr_remainder _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
572 mpfr_srcptr, mpfr_rnd_t));
573 __MPFR_DECLSPEC int mpfr_fmod _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
574 mpfr_srcptr, mpfr_rnd_t));
576 __MPFR_DECLSPEC int mpfr_fits_ulong_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
577 __MPFR_DECLSPEC int mpfr_fits_slong_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
578 __MPFR_DECLSPEC int mpfr_fits_uint_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
579 __MPFR_DECLSPEC int mpfr_fits_sint_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
580 __MPFR_DECLSPEC int mpfr_fits_ushort_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
581 __MPFR_DECLSPEC int mpfr_fits_sshort_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
582 __MPFR_DECLSPEC int mpfr_fits_uintmax_p _MPFR_PROTO((mpfr_srcptr,mpfr_rnd_t));
583 __MPFR_DECLSPEC int mpfr_fits_intmax_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
585 __MPFR_DECLSPEC void mpfr_extract _MPFR_PROTO ((mpz_ptr, mpfr_srcptr,
587 __MPFR_DECLSPEC void mpfr_swap _MPFR_PROTO ((mpfr_ptr, mpfr_ptr));
588 __MPFR_DECLSPEC void mpfr_dump _MPFR_PROTO ((mpfr_srcptr));
590 __MPFR_DECLSPEC int mpfr_nan_p _MPFR_PROTO((mpfr_srcptr));
591 __MPFR_DECLSPEC int mpfr_inf_p _MPFR_PROTO((mpfr_srcptr));
592 __MPFR_DECLSPEC int mpfr_number_p _MPFR_PROTO((mpfr_srcptr));
593 __MPFR_DECLSPEC int mpfr_integer_p _MPFR_PROTO ((mpfr_srcptr));
594 __MPFR_DECLSPEC int mpfr_zero_p _MPFR_PROTO ((mpfr_srcptr));
595 __MPFR_DECLSPEC int mpfr_regular_p _MPFR_PROTO ((mpfr_srcptr));
597 __MPFR_DECLSPEC int mpfr_greater_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
598 __MPFR_DECLSPEC int mpfr_greaterequal_p _MPFR_PROTO ((mpfr_srcptr,
600 __MPFR_DECLSPEC int mpfr_less_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
601 __MPFR_DECLSPEC int mpfr_lessequal_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
602 __MPFR_DECLSPEC int mpfr_lessgreater_p _MPFR_PROTO((mpfr_srcptr,mpfr_srcptr));
603 __MPFR_DECLSPEC int mpfr_equal_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
604 __MPFR_DECLSPEC int mpfr_unordered_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
606 __MPFR_DECLSPEC int mpfr_atanh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
607 __MPFR_DECLSPEC int mpfr_acosh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
608 __MPFR_DECLSPEC int mpfr_asinh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
609 __MPFR_DECLSPEC int mpfr_cosh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
610 __MPFR_DECLSPEC int mpfr_sinh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
611 __MPFR_DECLSPEC int mpfr_tanh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
612 __MPFR_DECLSPEC int mpfr_sinh_cosh _MPFR_PROTO ((mpfr_ptr, mpfr_ptr,
613 mpfr_srcptr, mpfr_rnd_t));
615 __MPFR_DECLSPEC int mpfr_sech _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
616 __MPFR_DECLSPEC int mpfr_csch _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
617 __MPFR_DECLSPEC int mpfr_coth _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
619 __MPFR_DECLSPEC int mpfr_acos _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
620 __MPFR_DECLSPEC int mpfr_asin _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
621 __MPFR_DECLSPEC int mpfr_atan _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
622 __MPFR_DECLSPEC int mpfr_sin _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
623 __MPFR_DECLSPEC int mpfr_sin_cos _MPFR_PROTO ((mpfr_ptr, mpfr_ptr,
624 mpfr_srcptr, mpfr_rnd_t));
625 __MPFR_DECLSPEC int mpfr_cos _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
626 __MPFR_DECLSPEC int mpfr_tan _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
627 __MPFR_DECLSPEC int mpfr_atan2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_srcptr,
629 __MPFR_DECLSPEC int mpfr_sec _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
630 __MPFR_DECLSPEC int mpfr_csc _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
631 __MPFR_DECLSPEC int mpfr_cot _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
633 __MPFR_DECLSPEC int mpfr_hypot _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
634 mpfr_srcptr, mpfr_rnd_t));
635 __MPFR_DECLSPEC int mpfr_erf _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
636 __MPFR_DECLSPEC int mpfr_erfc _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
637 __MPFR_DECLSPEC int mpfr_cbrt _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
638 __MPFR_DECLSPEC int mpfr_root _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,unsigned long,mpfr_rnd_t));
639 __MPFR_DECLSPEC int mpfr_gamma _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
640 __MPFR_DECLSPEC int mpfr_lngamma _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
641 __MPFR_DECLSPEC int mpfr_lgamma _MPFR_PROTO((mpfr_ptr,int*,mpfr_srcptr,mpfr_rnd_t));
642 __MPFR_DECLSPEC int mpfr_digamma _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
643 __MPFR_DECLSPEC int mpfr_zeta _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
644 __MPFR_DECLSPEC int mpfr_zeta_ui _MPFR_PROTO ((mpfr_ptr,unsigned long,mpfr_rnd_t));
645 __MPFR_DECLSPEC int mpfr_fac_ui _MPFR_PROTO ((mpfr_ptr, unsigned long int,
647 __MPFR_DECLSPEC int mpfr_j0 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
648 __MPFR_DECLSPEC int mpfr_j1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
649 __MPFR_DECLSPEC int mpfr_jn _MPFR_PROTO ((mpfr_ptr, long, mpfr_srcptr,
651 __MPFR_DECLSPEC int mpfr_y0 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
652 __MPFR_DECLSPEC int mpfr_y1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
653 __MPFR_DECLSPEC int mpfr_yn _MPFR_PROTO ((mpfr_ptr, long, mpfr_srcptr,
656 __MPFR_DECLSPEC int mpfr_ai _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
658 __MPFR_DECLSPEC int mpfr_min _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
660 __MPFR_DECLSPEC int mpfr_max _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
662 __MPFR_DECLSPEC int mpfr_dim _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
665 __MPFR_DECLSPEC int mpfr_mul_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
666 mpz_srcptr, mpfr_rnd_t));
667 __MPFR_DECLSPEC int mpfr_div_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
668 mpz_srcptr, mpfr_rnd_t));
669 __MPFR_DECLSPEC int mpfr_add_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
670 mpz_srcptr, mpfr_rnd_t));
671 __MPFR_DECLSPEC int mpfr_sub_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
672 mpz_srcptr, mpfr_rnd_t));
673 __MPFR_DECLSPEC int mpfr_z_sub _MPFR_PROTO ((mpfr_ptr, mpz_srcptr,
674 mpfr_srcptr, mpfr_rnd_t));
675 __MPFR_DECLSPEC int mpfr_cmp_z _MPFR_PROTO ((mpfr_srcptr, mpz_srcptr));
677 __MPFR_DECLSPEC int mpfr_mul_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
678 mpq_srcptr, mpfr_rnd_t));
679 __MPFR_DECLSPEC int mpfr_div_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
680 mpq_srcptr, mpfr_rnd_t));
681 __MPFR_DECLSPEC int mpfr_add_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
682 mpq_srcptr, mpfr_rnd_t));
683 __MPFR_DECLSPEC int mpfr_sub_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
684 mpq_srcptr, mpfr_rnd_t));
685 __MPFR_DECLSPEC int mpfr_cmp_q _MPFR_PROTO ((mpfr_srcptr, mpq_srcptr));
687 __MPFR_DECLSPEC int mpfr_cmp_f _MPFR_PROTO ((mpfr_srcptr, mpf_srcptr));
689 __MPFR_DECLSPEC int mpfr_fma _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
690 mpfr_srcptr, mpfr_rnd_t));
691 __MPFR_DECLSPEC int mpfr_fms _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
692 mpfr_srcptr, mpfr_rnd_t));
693 __MPFR_DECLSPEC int mpfr_sum _MPFR_PROTO ((mpfr_ptr, mpfr_ptr *__gmp_const,
694 unsigned long, mpfr_rnd_t));
696 __MPFR_DECLSPEC void mpfr_free_cache _MPFR_PROTO ((void));
698 __MPFR_DECLSPEC int mpfr_subnormalize _MPFR_PROTO ((mpfr_ptr, int,
701 __MPFR_DECLSPEC int mpfr_strtofr _MPFR_PROTO ((mpfr_ptr, __gmp_const char *,
702 char **, int, mpfr_rnd_t));
704 __MPFR_DECLSPEC size_t mpfr_custom_get_size _MPFR_PROTO ((mpfr_prec_t));
705 __MPFR_DECLSPEC void mpfr_custom_init _MPFR_PROTO ((void *, mpfr_prec_t));
706 __MPFR_DECLSPEC void * mpfr_custom_get_significand _MPFR_PROTO ((mpfr_srcptr));
707 __MPFR_DECLSPEC mpfr_exp_t mpfr_custom_get_exp _MPFR_PROTO ((mpfr_srcptr));
708 __MPFR_DECLSPEC void mpfr_custom_move _MPFR_PROTO ((mpfr_ptr, void *));
709 __MPFR_DECLSPEC void mpfr_custom_init_set _MPFR_PROTO ((mpfr_ptr, int,
710 mpfr_exp_t, mpfr_prec_t, void *));
711 __MPFR_DECLSPEC int mpfr_custom_get_kind _MPFR_PROTO ((mpfr_srcptr));
713 #if defined (__cplusplus)
717 /* Define MPFR_USE_EXTENSION to avoid "gcc -pedantic" warnings. */
718 #ifndef MPFR_EXTENSION
719 # if defined(MPFR_USE_EXTENSION)
720 # define MPFR_EXTENSION __extension__
722 # define MPFR_EXTENSION
726 /* Warning! This macro doesn't work with K&R C (e.g., compare the "gcc -E"
727 output with and without -traditional) and shouldn't be used internally.
728 For public use only, but see the MPFR manual. */
729 #define MPFR_DECL_INIT(_x, _p) \
730 MPFR_EXTENSION mp_limb_t __gmpfr_local_tab_##_x[((_p)-1)/GMP_NUMB_BITS+1]; \
731 MPFR_EXTENSION mpfr_t _x = {{(_p),1,__MPFR_EXP_NAN,__gmpfr_local_tab_##_x}}
733 /* Fast access macros to replace function interface.
734 If the USER don't want to use the macro interface, let him make happy
735 even if it produces faster and smaller code. */
736 #ifndef MPFR_USE_NO_MACRO
738 /* Inlining theses functions is both faster and smaller */
739 #define mpfr_nan_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_NAN)
740 #define mpfr_inf_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_INF)
741 #define mpfr_zero_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_ZERO)
742 #define mpfr_regular_p(_x) ((_x)->_mpfr_exp > __MPFR_EXP_INF)
743 #define mpfr_sgn(_x) \
744 ((_x)->_mpfr_exp < __MPFR_EXP_INF ? \
745 (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (mpfr_void) 0), 0 : \
748 /* Prevent them from using as lvalues */
749 #define MPFR_VALUE_OF(x) (0 ? (x) : (x))
750 #define mpfr_get_prec(_x) MPFR_VALUE_OF((_x)->_mpfr_prec)
751 #define mpfr_get_exp(_x) MPFR_VALUE_OF((_x)->_mpfr_exp)
752 /* Note: if need be, the MPFR_VALUE_OF can be used for other expressions
753 (of any type). Thanks to Wojtek Lerch and Tim Rentsch for the idea. */
755 #define mpfr_round(a,b) mpfr_rint((a), (b), MPFR_RNDNA)
756 #define mpfr_trunc(a,b) mpfr_rint((a), (b), MPFR_RNDZ)
757 #define mpfr_ceil(a,b) mpfr_rint((a), (b), MPFR_RNDU)
758 #define mpfr_floor(a,b) mpfr_rint((a), (b), MPFR_RNDD)
760 #define mpfr_cmp_ui(b,i) mpfr_cmp_ui_2exp((b),(i),0)
761 #define mpfr_cmp_si(b,i) mpfr_cmp_si_2exp((b),(i),0)
762 #define mpfr_set(a,b,r) mpfr_set4(a,b,r,MPFR_SIGN(b))
763 #define mpfr_abs(a,b,r) mpfr_set4(a,b,r,1)
764 #define mpfr_copysign(a,b,c,r) mpfr_set4(a,b,r,MPFR_SIGN(c))
765 #define mpfr_setsign(a,b,s,r) mpfr_set4(a,b,r,(s) ? -1 : 1)
766 #define mpfr_signbit(x) (MPFR_SIGN(x) < 0)
767 #define mpfr_cmp(b, c) mpfr_cmp3(b, c, 1)
768 #define mpfr_mul_2exp(y,x,n,r) mpfr_mul_2ui((y),(x),(n),(r))
769 #define mpfr_div_2exp(y,x,n,r) mpfr_div_2ui((y),(x),(n),(r))
772 /* When using GCC, optimize certain common comparisons and affectations.
773 + Remove ICC since it defines __GNUC__ but produces a
774 huge number of warnings if you use this code.
775 VL: I couldn't reproduce a single warning when enabling these macros
776 with icc 10.1 20080212 on Itanium. But with this version, __ICC isn't
777 defined (__INTEL_COMPILER is, though), so that these macros are enabled
778 anyway. Checking with other ICC versions is needed. Possibly detect
779 whether warnings are produced or not with a configure test.
780 + Remove C++ too, since it complains too much. */
781 /* Added casts to improve robustness in case of undefined behavior and
782 compiler extensions based on UB (in particular -fwrapv). MPFR doesn't
783 use such extensions, but these macros will be used by 3rd-party code,
784 where such extensions may be required.
785 Moreover casts to unsigned long have been added to avoid warnings in
786 programs that use MPFR and are compiled with -Wconversion; such casts
787 are OK since if X is a constant expression, then (unsigned long) X is
788 also a constant expression, so that the optimizations still work. The
789 warnings are probably related to the following two bugs:
790 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210
791 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470 (possibly a variant)
792 and the casts could be removed once these bugs are fixed.
793 Casts shouldn't be used on the generic calls (to the ..._2exp functions),
794 where implicit conversions are performed. Indeed, having at least one
795 implicit conversion in the macro allows the compiler to emit diagnostics
796 when normally expected, for instance in the following call:
797 mpfr_set_ui (x, "foo", MPFR_RNDN);
798 If this is not possible (for future macros), one of the tricks described
799 on http://groups.google.com/group/comp.std.c/msg/e92abd24bf9eaf7b could
801 #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus)
804 /* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0.
805 But warning! mpfr_sgn is specified as a macro in the API, thus the macro
806 mustn't be used if side effects are possible, like here. */
807 #define mpfr_cmp_ui(_f,_u) \
808 (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ? \
810 mpfr_cmp_ui_2exp ((_f), (_u), 0))
812 #define mpfr_cmp_si(_f,_s) \
813 (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \
814 mpfr_cmp_ui ((_f), (mpfr_ulong) (mpfr_long) (_s)) : \
815 mpfr_cmp_si_2exp ((_f), (_s), 0))
816 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
818 #define mpfr_set_ui(_f,_u,_r) \
819 (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ? \
821 mpfr_ptr _p = (_f); \
822 _p->_mpfr_sign = 1; \
823 _p->_mpfr_exp = __MPFR_EXP_ZERO; \
824 (mpfr_void) (_r); 0; }) : \
825 mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
828 #define mpfr_set_si(_f,_s,_r) \
829 (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \
830 mpfr_set_ui ((_f), (mpfr_ulong) (mpfr_long) (_s), (_r)) : \
831 mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
835 /* Macro version of mpfr_stack interface for fast access */
836 #define mpfr_custom_get_size(p) ((mpfr_size_t) \
837 (((p)+GMP_NUMB_BITS-1)/GMP_NUMB_BITS*sizeof (mp_limb_t)))
838 #define mpfr_custom_init(m,p) do {} while (0)
839 #define mpfr_custom_get_significand(x) ((mpfr_void*)((x)->_mpfr_d))
840 #define mpfr_custom_get_exp(x) ((x)->_mpfr_exp)
841 #define mpfr_custom_move(x,m) do { ((x)->_mpfr_d = (mp_limb_t*)(m)); } while (0)
842 #define mpfr_custom_init_set(x,k,e,p,m) do { \
849 _t = (mpfr_kind_t) _k; \
852 _t = (mpfr_kind_t) -k; \
855 _e = _t == MPFR_REGULAR_KIND ? (e) : \
856 _t == MPFR_NAN_KIND ? __MPFR_EXP_NAN : \
857 _t == MPFR_INF_KIND ? __MPFR_EXP_INF : __MPFR_EXP_ZERO; \
858 _x->_mpfr_prec = (p); \
859 _x->_mpfr_sign = _s; \
860 _x->_mpfr_exp = _e; \
861 _x->_mpfr_d = (mp_limb_t*) (m); \
863 #define mpfr_custom_get_kind(x) \
864 ( (x)->_mpfr_exp > __MPFR_EXP_INF ? \
865 (mpfr_int) MPFR_REGULAR_KIND * MPFR_SIGN (x) \
866 : (x)->_mpfr_exp == __MPFR_EXP_INF ? \
867 (mpfr_int) MPFR_INF_KIND * MPFR_SIGN (x) \
868 : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (mpfr_int) MPFR_NAN_KIND \
869 : (mpfr_int) MPFR_ZERO_KIND * MPFR_SIGN (x) )
872 #endif /* MPFR_USE_NO_MACRO */
874 /* Theses are defined to be macros */
875 #define mpfr_init_set_si(x, i, rnd) \
876 ( mpfr_init(x), mpfr_set_si((x), (i), (rnd)) )
877 #define mpfr_init_set_ui(x, i, rnd) \
878 ( mpfr_init(x), mpfr_set_ui((x), (i), (rnd)) )
879 #define mpfr_init_set_d(x, d, rnd) \
880 ( mpfr_init(x), mpfr_set_d((x), (d), (rnd)) )
881 #define mpfr_init_set_ld(x, d, rnd) \
882 ( mpfr_init(x), mpfr_set_ld((x), (d), (rnd)) )
883 #define mpfr_init_set_z(x, i, rnd) \
884 ( mpfr_init(x), mpfr_set_z((x), (i), (rnd)) )
885 #define mpfr_init_set_q(x, i, rnd) \
886 ( mpfr_init(x), mpfr_set_q((x), (i), (rnd)) )
887 #define mpfr_init_set(x, y, rnd) \
888 ( mpfr_init(x), mpfr_set((x), (y), (rnd)) )
889 #define mpfr_init_set_f(x, y, rnd) \
890 ( mpfr_init(x), mpfr_set_f((x), (y), (rnd)) )
892 /* Compatibility layer -- obsolete functions and macros */
893 /* Note: it is not possible to output warnings, unless one defines
894 * a deprecated variable and uses it, e.g.
895 * MPFR_DEPRECATED extern int mpfr_deprecated_feature;
896 * #define MPFR_EMIN_MIN ((void)mpfr_deprecated_feature,mpfr_get_emin_min())
897 * (the cast to void avoids a warning because the left-hand operand
900 #define mpfr_cmp_abs mpfr_cmpabs
901 #define mpfr_round_prec(x,r,p) mpfr_prec_round(x,p,r)
902 #define __gmp_default_rounding_mode (mpfr_get_default_rounding_mode())
903 #define __mpfr_emin (mpfr_get_emin())
904 #define __mpfr_emax (mpfr_get_emax())
905 #define __mpfr_default_fp_bit_precision (mpfr_get_default_fp_bit_precision())
906 #define MPFR_EMIN_MIN mpfr_get_emin_min()
907 #define MPFR_EMIN_MAX mpfr_get_emin_max()
908 #define MPFR_EMAX_MIN mpfr_get_emax_min()
909 #define MPFR_EMAX_MAX mpfr_get_emax_max()
910 #define mpfr_version (mpfr_get_version())
912 # define mpz_set_fr mpfr_get_z
914 #define mpfr_add_one_ulp(x,r) \
915 (mpfr_sgn (x) > 0 ? mpfr_nextabove (x) : mpfr_nextbelow (x))
916 #define mpfr_sub_one_ulp(x,r) \
917 (mpfr_sgn (x) > 0 ? mpfr_nextbelow (x) : mpfr_nextabove (x))
918 #define mpfr_get_z_exp mpfr_get_z_2exp
919 #define mpfr_custom_get_mantissa mpfr_custom_get_significand
921 #endif /* __MPFR_H */
924 /* Check if <stdint.h> / <inttypes.h> is included or if the user
925 explicitly wants intmax_t. Automatical detection is done by
927 - INTMAX_C and UINTMAX_C, but not if the compiler is a C++ one
928 (as suggested by Patrick Pelissier) because the test does not
929 work well in this case. See:
930 http://websympa.loria.fr/wwsympa/arc/mpfr/2010-02/msg00025.html
931 We do not check INTMAX_MAX and UINTMAX_MAX because under Solaris,
932 these macros are always defined by <limits.h> (i.e. even when
933 <stdint.h> and <inttypes.h> are not included).
934 - _STDINT_H (defined by the glibc), _STDINT_H_ (defined under
935 Mac OS X) and _STDINT (defined under MS Visual Studio), but
936 this test may not work with all implementations.
937 Portable software should not rely on these tests.
939 #if (defined (INTMAX_C) && defined (UINTMAX_C) && !defined(__cplusplus)) || \
940 defined (MPFR_USE_INTMAX_T) || \
941 defined (_STDINT_H) || defined (_STDINT_H_) || defined (_STDINT)
942 # ifndef _MPFR_H_HAVE_INTMAX_T
943 # define _MPFR_H_HAVE_INTMAX_T 1
945 #if defined (__cplusplus)
949 #define mpfr_set_sj __gmpfr_set_sj
950 #define mpfr_set_sj_2exp __gmpfr_set_sj_2exp
951 #define mpfr_set_uj __gmpfr_set_uj
952 #define mpfr_set_uj_2exp __gmpfr_set_uj_2exp
953 #define mpfr_get_sj __gmpfr_mpfr_get_sj
954 #define mpfr_get_uj __gmpfr_mpfr_get_uj
955 __MPFR_DECLSPEC int mpfr_set_sj _MPFR_PROTO ((mpfr_t, intmax_t, mpfr_rnd_t));
957 mpfr_set_sj_2exp _MPFR_PROTO ((mpfr_t, intmax_t, intmax_t, mpfr_rnd_t));
958 __MPFR_DECLSPEC int mpfr_set_uj _MPFR_PROTO ((mpfr_t, uintmax_t, mpfr_rnd_t));
960 mpfr_set_uj_2exp _MPFR_PROTO ((mpfr_t, uintmax_t, intmax_t, mpfr_rnd_t));
961 __MPFR_DECLSPEC intmax_t mpfr_get_sj _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
962 __MPFR_DECLSPEC uintmax_t mpfr_get_uj _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
964 #if defined (__cplusplus)
968 # endif /* _MPFR_H_HAVE_INTMAX_T */
972 /* Check if <stdio.h> has been included or if the user wants FILE */
973 #if defined (_GMP_H_HAVE_FILE) || defined (MPFR_USE_FILE)
974 # ifndef _MPFR_H_HAVE_FILE
975 # define _MPFR_H_HAVE_FILE 1
977 #if defined (__cplusplus)
981 #define mpfr_inp_str __gmpfr_inp_str
982 #define mpfr_out_str __gmpfr_out_str
983 __MPFR_DECLSPEC size_t mpfr_inp_str _MPFR_PROTO ((mpfr_ptr, FILE*, int,
985 __MPFR_DECLSPEC size_t mpfr_out_str _MPFR_PROTO ((FILE*, int, size_t,
986 mpfr_srcptr, mpfr_rnd_t));
987 #define mpfr_fprintf __gmpfr_fprintf
988 __MPFR_DECLSPEC int mpfr_fprintf _MPFR_PROTO ((FILE*, __gmp_const char*,
991 #if defined (__cplusplus)
995 # endif /* _MPFR_H_HAVE_FILE */
999 /* check if <stdarg.h> has been included or if the user wants va_list */
1000 #if defined (_GMP_H_HAVE_VA_LIST) || defined (MPFR_USE_VA_LIST)
1001 # ifndef _MPFR_H_HAVE_VA_LIST
1002 # define _MPFR_H_HAVE_VA_LIST 1
1004 #if defined (__cplusplus)
1008 #define mpfr_vprintf __gmpfr_vprintf
1009 #define mpfr_vasprintf __gmpfr_vasprintf
1010 #define mpfr_vsprintf __gmpfr_vsprintf
1011 #define mpfr_vsnprintf __gmpfr_vsnprintf
1012 __MPFR_DECLSPEC int mpfr_vprintf _MPFR_PROTO ((__gmp_const char*, va_list));
1013 __MPFR_DECLSPEC int mpfr_vasprintf _MPFR_PROTO ((char**, __gmp_const char*,
1015 __MPFR_DECLSPEC int mpfr_vsprintf _MPFR_PROTO ((char*, __gmp_const char*,
1017 __MPFR_DECLSPEC int mpfr_vsnprintf _MPFR_PROTO ((char*, size_t,
1018 __gmp_const char*, va_list));
1020 #if defined (__cplusplus)
1024 # endif /* _MPFR_H_HAVE_VA_LIST */
1028 /* check if <stdarg.h> has been included and if FILE is available
1030 #if defined (_MPFR_H_HAVE_VA_LIST) && defined (_MPFR_H_HAVE_FILE)
1031 # ifndef _MPFR_H_HAVE_VA_LIST_FILE
1032 # define _MPFR_H_HAVE_VA_LIST_FILE 1
1034 #if defined (__cplusplus)
1038 #define mpfr_vfprintf __gmpfr_vfprintf
1039 __MPFR_DECLSPEC int mpfr_vfprintf _MPFR_PROTO ((FILE*, __gmp_const char*,
1042 #if defined (__cplusplus)
1046 # endif /* _MPFR_H_HAVE_VA_LIST_FILE */