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