1 /* mpfr.h -- Include file for mpfr.
3 Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
4 Contributed by the Arenaire and Cacao 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 2.1 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.LIB. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
21 MA 02110-1301, USA. */
26 /* Define MPFR version number */
27 #define MPFR_VERSION_MAJOR 2
28 #define MPFR_VERSION_MINOR 4
29 #define MPFR_VERSION_PATCHLEVEL 2
30 #define MPFR_VERSION_STRING "2.4.2-p3"
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 /* Check if stdio.h is included or if the user wants FILE */
43 #if defined (_GMP_H_HAVE_FILE) || defined (MPFR_USE_FILE)
44 # define _MPFR_H_HAVE_FILE 1
47 #if defined (_GMP_H_HAVE_VA_LIST)
48 # define _MPFR_H_HAVE_VA_LIST 1
51 /* Check if <stdint.h> / <inttypes.h> is included or if the user
52 explicitly wants intmax_t, by checking INTMAX_C and UINTMAX_C.
53 We do not check INTMAX_MAX and UINTMAX_MAX because under Solaris,
54 these macros are always defined by <limits.h> (i.e. even when
55 <stdint.h> and <inttypes.h> are not included).
56 Note: with C++ implementations, the test of the C99 macros will
57 work only if the user has defined __STDC_CONSTANT_MACROS before
58 <stdint.h> has been included (see ISO C99 standard); that's why
59 _STDINT_H (defined by the glibc) and _STDINT_H_ (defined under
60 Mac OS X) are tested too, but under other OS, MPFR_USE_INTMAX_T
61 may need to be defined. */
62 #if (defined (INTMAX_C) && defined (UINTMAX_C)) || \
63 defined (MPFR_USE_INTMAX_T) || defined (_STDINT_H) || defined (_STDINT_H_)
64 # define _MPFR_H_HAVE_INTMAX_T 1
67 /* Definition of rounding modes (DON'T USE GMP_RNDNA!).
68 Warning! Changing the contents of this enum should be seen as an
69 interface change since the old and the new types are not compatible
70 (the integer type compatible with the enumerated type can even change,
71 see ISO C99, 6.7.2.2#4), and in Makefile.am, AGE should be set to 0. */
73 GMP_RNDN=0, /* round to nearest, with ties to even */
74 GMP_RNDZ, /* round toward zero */
75 GMP_RNDU, /* round toward +Inf */
76 GMP_RNDD, /* round toward -Inf */
77 GMP_RND_MAX, /* gives number of supported rounding modes, those after are
78 only supported by some functions */
79 GMP_RNDNA=-1 /* round to nearest, with ties away from zero (mpfr_round) */
82 /* Define precision : 1 (short), 2 (int) or 3 (long) (DON'T USE IT!)*/
83 #ifndef _MPFR_PREC_FORMAT
84 # if __GMP_MP_SIZE_T_INT == 1
85 # define _MPFR_PREC_FORMAT 2
87 # define _MPFR_PREC_FORMAT 3
91 #if _MPFR_PREC_FORMAT == 1
92 typedef unsigned short mpfr_prec_t;
93 #elif _MPFR_PREC_FORMAT == 2
94 typedef unsigned int mpfr_prec_t;
95 #elif _MPFR_PREC_FORMAT == 3
96 typedef unsigned long mpfr_prec_t;
98 # error "Invalid MPFR Prec format"
101 /* Definition of precision limits */
102 #define MPFR_PREC_MIN 2
103 #define MPFR_PREC_MAX ((mpfr_prec_t)((mpfr_prec_t)(~(mpfr_prec_t)0)>>1))
105 /* Definition of sign */
106 typedef int mpfr_sign_t;
108 /* Definition of the standard exponent limits */
109 #define MPFR_EMAX_DEFAULT ((mp_exp_t) (((unsigned long) 1 << 30) - 1))
110 #define MPFR_EMIN_DEFAULT (-(MPFR_EMAX_DEFAULT))
112 /* Definition of the main structure */
114 mpfr_prec_t _mpfr_prec;
115 mpfr_sign_t _mpfr_sign;
120 /* Compatibility with previous types of MPFR */
122 # define mp_rnd_t mpfr_rnd_t
125 # define mp_prec_t mpfr_prec_t
129 The represented number is
130 _sign*(_d[k-1]/B+_d[k-2]/B^2+...+_d[0]/B^k)*2^_exp
131 where k=ceil(_mp_prec/BITS_PER_MP_LIMB) and B=2^BITS_PER_MP_LIMB.
133 For the msb (most significant bit) normalized representation, we must have
134 _d[k-1]>=B/2, unless the number is singular.
136 We must also have the last k*BITS_PER_MP_LIMB-_prec bits set to zero.
139 typedef __mpfr_struct mpfr_t[1];
140 typedef __mpfr_struct *mpfr_ptr;
141 typedef __gmp_const __mpfr_struct *mpfr_srcptr;
143 /* For those who need a direct and fast access to the sign field.
144 However it is not in the API, thus use it at your own risk: it might
145 not be supported, or change name, in further versions!
146 Unfortunately, it must be defined here (instead of MPFR's internal
147 header file mpfr-impl.h) because it is used by some macros below.
149 #define MPFR_SIGN(x) ((x)->_mpfr_sign)
151 /* Stack interface */
154 MPFR_INF_KIND = 1, MPFR_ZERO_KIND = 2, MPFR_REGULAR_KIND = 3
158 + size_t: Standard size_t
159 + __GMP_ATTRIBUTE_PURE Attribute for math functions.
160 + __GMP_NOTHROW For C++: can't throw .
161 + __GMP_EXTERN_INLINE Attribute for inline function.
162 * __gmp_const const (Supports for K&R compiler only for mpfr.h).
163 + __GMP_DECLSPEC_EXPORT compiling to go into a DLL
164 + __GMP_DECLSPEC_IMPORT compiling to go into a application
166 /* Extra MPFR defines */
167 #define __MPFR_SENTINEL_ATTR
168 #if defined (__GNUC__)
170 # undef __MPFR_SENTINEL_ATTR
171 # define __MPFR_SENTINEL_ATTR __attribute__ ((sentinel))
175 /* Prototypes: Support of K&R compiler */
176 #if defined (__GMP_PROTO)
177 # define _MPFR_PROTO __GMP_PROTO
178 #elif defined (__STDC__) || defined (__cplusplus)
179 # define _MPFR_PROTO(x) x
181 # define _MPFR_PROTO(x) ()
183 /* Support for WINDOWS Dll:
184 Check if we are inside a MPFR build, and if so export the functions.
185 Otherwise does the same thing as GMP */
186 #if defined(__MPFR_WITHIN_MPFR) && __GMP_LIBGMP_DLL
187 # define __MPFR_DECLSPEC __GMP_DECLSPEC_EXPORT
189 # define __MPFR_DECLSPEC __GMP_DECLSPEC
192 /* Note: In order to be declared, some functions need a specific
193 system header to be included *before* "mpfr.h". If the user
194 forgets to include the header, the MPFR function prototype in
195 the user object file is not correct. To avoid wrong results,
196 we raise a linker error in that case by changing their internal
197 name in the library (prefixed by __gmpfr instead of mpfr). See
198 the lines of the form "#define mpfr_xxx __gmpfr_xxx" below. */
200 #if defined (__cplusplus)
204 __MPFR_DECLSPEC __gmp_const char * mpfr_get_version _MPFR_PROTO ((void));
205 __MPFR_DECLSPEC __gmp_const char * mpfr_get_patches _MPFR_PROTO ((void));
207 __MPFR_DECLSPEC mp_exp_t mpfr_get_emin _MPFR_PROTO ((void));
208 __MPFR_DECLSPEC int mpfr_set_emin _MPFR_PROTO ((mp_exp_t));
209 __MPFR_DECLSPEC mp_exp_t mpfr_get_emin_min _MPFR_PROTO ((void));
210 __MPFR_DECLSPEC mp_exp_t mpfr_get_emin_max _MPFR_PROTO ((void));
211 __MPFR_DECLSPEC mp_exp_t mpfr_get_emax _MPFR_PROTO ((void));
212 __MPFR_DECLSPEC int mpfr_set_emax _MPFR_PROTO ((mp_exp_t));
213 __MPFR_DECLSPEC mp_exp_t mpfr_get_emax_min _MPFR_PROTO ((void));
214 __MPFR_DECLSPEC mp_exp_t mpfr_get_emax_max _MPFR_PROTO ((void));
216 __MPFR_DECLSPEC void mpfr_set_default_rounding_mode _MPFR_PROTO((mpfr_rnd_t));
217 __MPFR_DECLSPEC mp_rnd_t mpfr_get_default_rounding_mode _MPFR_PROTO((void));
218 __MPFR_DECLSPEC __gmp_const char *
219 mpfr_print_rnd_mode _MPFR_PROTO((mpfr_rnd_t));
221 __MPFR_DECLSPEC void mpfr_clear_flags _MPFR_PROTO ((void));
222 __MPFR_DECLSPEC void mpfr_clear_underflow _MPFR_PROTO ((void));
223 __MPFR_DECLSPEC void mpfr_clear_overflow _MPFR_PROTO ((void));
224 __MPFR_DECLSPEC void mpfr_clear_nanflag _MPFR_PROTO ((void));
225 __MPFR_DECLSPEC void mpfr_clear_inexflag _MPFR_PROTO ((void));
226 __MPFR_DECLSPEC void mpfr_clear_erangeflag _MPFR_PROTO ((void));
228 __MPFR_DECLSPEC void mpfr_set_underflow _MPFR_PROTO ((void));
229 __MPFR_DECLSPEC void mpfr_set_overflow _MPFR_PROTO ((void));
230 __MPFR_DECLSPEC void mpfr_set_nanflag _MPFR_PROTO ((void));
231 __MPFR_DECLSPEC void mpfr_set_inexflag _MPFR_PROTO ((void));
232 __MPFR_DECLSPEC void mpfr_set_erangeflag _MPFR_PROTO ((void));
234 __MPFR_DECLSPEC int mpfr_underflow_p _MPFR_PROTO ((void));
235 __MPFR_DECLSPEC int mpfr_overflow_p _MPFR_PROTO ((void));
236 __MPFR_DECLSPEC int mpfr_nanflag_p _MPFR_PROTO ((void));
237 __MPFR_DECLSPEC int mpfr_inexflag_p _MPFR_PROTO ((void));
238 __MPFR_DECLSPEC int mpfr_erangeflag_p _MPFR_PROTO ((void));
241 mpfr_check_range _MPFR_PROTO ((mpfr_ptr, int, mpfr_rnd_t));
243 __MPFR_DECLSPEC void mpfr_init2 _MPFR_PROTO ((mpfr_ptr, mpfr_prec_t));
244 __MPFR_DECLSPEC void mpfr_init _MPFR_PROTO ((mpfr_ptr));
245 __MPFR_DECLSPEC void mpfr_clear _MPFR_PROTO ((mpfr_ptr));
248 mpfr_inits2 _MPFR_PROTO ((mp_prec_t, mpfr_ptr, ...)) __MPFR_SENTINEL_ATTR;
250 mpfr_inits _MPFR_PROTO ((mpfr_ptr, ...)) __MPFR_SENTINEL_ATTR;
252 mpfr_clears _MPFR_PROTO ((mpfr_ptr, ...)) __MPFR_SENTINEL_ATTR;
255 mpfr_prec_round _MPFR_PROTO ((mpfr_ptr, mpfr_prec_t, mpfr_rnd_t));
257 mpfr_can_round _MPFR_PROTO ((mpfr_srcptr, mp_exp_t, mpfr_rnd_t, mpfr_rnd_t,
260 __MPFR_DECLSPEC mp_exp_t mpfr_get_exp _MPFR_PROTO ((mpfr_srcptr));
261 __MPFR_DECLSPEC int mpfr_set_exp _MPFR_PROTO ((mpfr_ptr, mp_exp_t));
262 __MPFR_DECLSPEC mp_prec_t mpfr_get_prec _MPFR_PROTO((mpfr_srcptr));
263 __MPFR_DECLSPEC void mpfr_set_prec _MPFR_PROTO((mpfr_ptr, mpfr_prec_t));
264 __MPFR_DECLSPEC void mpfr_set_prec_raw _MPFR_PROTO((mpfr_ptr, mpfr_prec_t));
265 __MPFR_DECLSPEC void mpfr_set_default_prec _MPFR_PROTO((mpfr_prec_t));
266 __MPFR_DECLSPEC mp_prec_t mpfr_get_default_prec _MPFR_PROTO((void));
268 __MPFR_DECLSPEC int mpfr_set_d _MPFR_PROTO ((mpfr_ptr, double, mpfr_rnd_t));
269 #ifdef MPFR_WANT_DECIMAL_FLOATS
270 __MPFR_DECLSPEC int mpfr_set_decimal64 _MPFR_PROTO ((mpfr_ptr, _Decimal64,
274 mpfr_set_ld _MPFR_PROTO ((mpfr_ptr, long double, mpfr_rnd_t));
276 mpfr_set_z _MPFR_PROTO ((mpfr_ptr, mpz_srcptr, mpfr_rnd_t));
277 __MPFR_DECLSPEC void mpfr_set_nan _MPFR_PROTO ((mpfr_ptr));
278 __MPFR_DECLSPEC void mpfr_set_inf _MPFR_PROTO ((mpfr_ptr, int));
280 mpfr_set_f _MPFR_PROTO ((mpfr_ptr, mpf_srcptr, mpfr_rnd_t));
282 mpfr_get_f _MPFR_PROTO ((mpf_ptr, mpfr_srcptr, mpfr_rnd_t));
283 __MPFR_DECLSPEC int mpfr_set_si _MPFR_PROTO ((mpfr_ptr, long, mpfr_rnd_t));
285 mpfr_set_ui _MPFR_PROTO ((mpfr_ptr, unsigned long, mpfr_rnd_t));
287 mpfr_set_si_2exp _MPFR_PROTO ((mpfr_ptr, long, mp_exp_t, mpfr_rnd_t));
289 mpfr_set_ui_2exp _MPFR_PROTO ((mpfr_ptr,unsigned long,mp_exp_t,mpfr_rnd_t));
291 mpfr_set_q _MPFR_PROTO ((mpfr_ptr, mpq_srcptr, mpfr_rnd_t));
293 mpfr_set_str _MPFR_PROTO ((mpfr_ptr, __gmp_const char *, int, mpfr_rnd_t));
295 mpfr_init_set_str _MPFR_PROTO ((mpfr_ptr, __gmp_const char *, int,
298 mpfr_set4 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t, int));
300 mpfr_abs _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
302 mpfr_set _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
303 __MPFR_DECLSPEC int mpfr_neg _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
304 __MPFR_DECLSPEC int mpfr_signbit _MPFR_PROTO ((mpfr_srcptr));
306 mpfr_setsign _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, int, mpfr_rnd_t));
308 mpfr_copysign _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t));
310 #ifdef _MPFR_H_HAVE_INTMAX_T
311 #define mpfr_set_sj __gmpfr_set_sj
312 #define mpfr_set_sj_2exp __gmpfr_set_sj_2exp
313 #define mpfr_set_uj __gmpfr_set_uj
314 #define mpfr_set_uj_2exp __gmpfr_set_uj_2exp
315 #define mpfr_get_sj __gmpfr_mpfr_get_sj
316 #define mpfr_get_uj __gmpfr_mpfr_get_uj
317 __MPFR_DECLSPEC int mpfr_set_sj _MPFR_PROTO ((mpfr_t, intmax_t, mpfr_rnd_t));
319 mpfr_set_sj_2exp _MPFR_PROTO ((mpfr_t, intmax_t, intmax_t, mpfr_rnd_t));
320 __MPFR_DECLSPEC int mpfr_set_uj _MPFR_PROTO ((mpfr_t, uintmax_t, mpfr_rnd_t));
322 mpfr_set_uj_2exp _MPFR_PROTO ((mpfr_t, uintmax_t, intmax_t, mpfr_rnd_t));
323 __MPFR_DECLSPEC intmax_t mpfr_get_sj _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
324 __MPFR_DECLSPEC uintmax_t mpfr_get_uj _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
327 __MPFR_DECLSPEC mp_exp_t mpfr_get_z_exp _MPFR_PROTO ((mpz_ptr, mpfr_srcptr));
328 __MPFR_DECLSPEC double mpfr_get_d _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
329 #ifdef MPFR_WANT_DECIMAL_FLOATS
330 __MPFR_DECLSPEC _Decimal64 mpfr_get_decimal64 _MPFR_PROTO ((mpfr_srcptr,
333 __MPFR_DECLSPEC long double mpfr_get_ld _MPFR_PROTO ((mpfr_srcptr,
335 __MPFR_DECLSPEC double mpfr_get_d1 _MPFR_PROTO ((mpfr_srcptr));
336 __MPFR_DECLSPEC double mpfr_get_d_2exp _MPFR_PROTO ((long*, mpfr_srcptr,
338 __MPFR_DECLSPEC long double mpfr_get_ld_2exp _MPFR_PROTO ((long*, mpfr_srcptr,
340 __MPFR_DECLSPEC long mpfr_get_si _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
341 __MPFR_DECLSPEC unsigned long mpfr_get_ui _MPFR_PROTO ((mpfr_srcptr,
343 __MPFR_DECLSPEC char*mpfr_get_str _MPFR_PROTO ((char*, mp_exp_t*, int, size_t,
344 mpfr_srcptr, mpfr_rnd_t));
345 __MPFR_DECLSPEC void mpfr_get_z _MPFR_PROTO ((mpz_ptr z, mpfr_srcptr f,
348 __MPFR_DECLSPEC void mpfr_free_str _MPFR_PROTO ((char *));
351 __MPFR_DECLSPEC void mpfr_random _MPFR_PROTO ((mpfr_ptr));
352 __MPFR_DECLSPEC void mpfr_random2 _MPFR_PROTO ((mpfr_ptr,mp_size_t,mp_exp_t));
353 __MPFR_DECLSPEC int mpfr_urandomb _MPFR_PROTO ((mpfr_ptr, gmp_randstate_t));
355 __MPFR_DECLSPEC void mpfr_nextabove _MPFR_PROTO ((mpfr_ptr));
356 __MPFR_DECLSPEC void mpfr_nextbelow _MPFR_PROTO ((mpfr_ptr));
357 __MPFR_DECLSPEC void mpfr_nexttoward _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr));
359 #ifdef _MPFR_H_HAVE_FILE
360 #define mpfr_inp_str __gmpfr_inp_str
361 #define mpfr_out_str __gmpfr_out_str
362 __MPFR_DECLSPEC size_t mpfr_inp_str _MPFR_PROTO ((mpfr_ptr, FILE*, int,
364 __MPFR_DECLSPEC size_t mpfr_out_str _MPFR_PROTO ((FILE*, int, size_t,
365 mpfr_srcptr, mpfr_rnd_t));
366 #define mpfr_fprintf __gmpfr_fprintf
367 __MPFR_DECLSPEC int mpfr_fprintf _MPFR_PROTO ((FILE*, __gmp_const char*,
370 __MPFR_DECLSPEC int mpfr_printf _MPFR_PROTO ((__gmp_const char*, ...));
371 __MPFR_DECLSPEC int mpfr_asprintf _MPFR_PROTO ((char**, __gmp_const char*,
373 __MPFR_DECLSPEC int mpfr_sprintf _MPFR_PROTO ((char*, __gmp_const char*,
375 __MPFR_DECLSPEC int mpfr_snprintf _MPFR_PROTO ((char*, size_t,
376 __gmp_const char*, ...));
378 #ifdef _MPFR_H_HAVE_VA_LIST
379 #ifdef _MPFR_H_HAVE_FILE
380 #define mpfr_vfprintf __gmpfr_vfprintf
381 __MPFR_DECLSPEC int mpfr_vfprintf _MPFR_PROTO ((FILE*, __gmp_const char*,
383 #endif /* _MPFR_H_HAVE_FILE */
384 #define mpfr_vprintf __gmpfr_vprintf
385 #define mpfr_vasprintf __gmpfr_vasprintf
386 #define mpfr_vsprintf __gmpfr_vsprintf
387 #define mpfr_vsnprintf __gmpfr_vsnprintf
388 __MPFR_DECLSPEC int mpfr_vprintf _MPFR_PROTO ((__gmp_const char*, va_list));
389 __MPFR_DECLSPEC int mpfr_vasprintf _MPFR_PROTO ((char**, __gmp_const char*,
391 __MPFR_DECLSPEC int mpfr_vsprintf _MPFR_PROTO ((char*, __gmp_const char*,
393 __MPFR_DECLSPEC int mpfr_vsnprintf _MPFR_PROTO ((char*, size_t,
394 __gmp_const char*, va_list));
395 #endif /* _MPFR_H_HAVE_VA_LIST */
397 __MPFR_DECLSPEC int mpfr_pow _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
398 mpfr_srcptr, mpfr_rnd_t));
399 __MPFR_DECLSPEC int mpfr_pow_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
400 long int, mpfr_rnd_t));
401 __MPFR_DECLSPEC int mpfr_pow_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
402 unsigned long int, mpfr_rnd_t));
403 __MPFR_DECLSPEC int mpfr_ui_pow_ui _MPFR_PROTO ((mpfr_ptr, unsigned long int,
404 unsigned long int, mpfr_rnd_t));
405 __MPFR_DECLSPEC int mpfr_ui_pow _MPFR_PROTO ((mpfr_ptr, unsigned long int,
406 mpfr_srcptr, mpfr_rnd_t));
407 __MPFR_DECLSPEC int mpfr_pow_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
408 mpz_srcptr, mpfr_rnd_t));
410 __MPFR_DECLSPEC int mpfr_sqrt _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
412 __MPFR_DECLSPEC int mpfr_sqrt_ui _MPFR_PROTO ((mpfr_ptr, unsigned long,
414 __MPFR_DECLSPEC int mpfr_rec_sqrt _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
417 __MPFR_DECLSPEC int mpfr_add _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
418 mpfr_srcptr, mpfr_rnd_t));
419 __MPFR_DECLSPEC int mpfr_sub _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
420 mpfr_srcptr, mpfr_rnd_t));
421 __MPFR_DECLSPEC int mpfr_mul _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
422 mpfr_srcptr, mpfr_rnd_t));
423 __MPFR_DECLSPEC int mpfr_div _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
424 mpfr_srcptr, mpfr_rnd_t));
426 __MPFR_DECLSPEC int mpfr_add_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
427 unsigned long, mpfr_rnd_t));
428 __MPFR_DECLSPEC int mpfr_sub_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
429 unsigned long, mpfr_rnd_t));
430 __MPFR_DECLSPEC int mpfr_ui_sub _MPFR_PROTO ((mpfr_ptr, unsigned long,
431 mpfr_srcptr, mpfr_rnd_t));
432 __MPFR_DECLSPEC int mpfr_mul_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
433 unsigned long, mpfr_rnd_t));
434 __MPFR_DECLSPEC int mpfr_div_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
435 unsigned long, mpfr_rnd_t));
436 __MPFR_DECLSPEC int mpfr_ui_div _MPFR_PROTO ((mpfr_ptr, unsigned long,
437 mpfr_srcptr, mpfr_rnd_t));
439 __MPFR_DECLSPEC int mpfr_add_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
440 long int, mpfr_rnd_t));
441 __MPFR_DECLSPEC int mpfr_sub_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
442 long int, mpfr_rnd_t));
443 __MPFR_DECLSPEC int mpfr_si_sub _MPFR_PROTO ((mpfr_ptr, long int,
444 mpfr_srcptr, mpfr_rnd_t));
445 __MPFR_DECLSPEC int mpfr_mul_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
446 long int, mpfr_rnd_t));
447 __MPFR_DECLSPEC int mpfr_div_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
448 long int, mpfr_rnd_t));
449 __MPFR_DECLSPEC int mpfr_si_div _MPFR_PROTO ((mpfr_ptr, long int,
450 mpfr_srcptr, mpfr_rnd_t));
452 __MPFR_DECLSPEC int mpfr_add_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
453 double, mpfr_rnd_t));
454 __MPFR_DECLSPEC int mpfr_sub_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
455 double, mpfr_rnd_t));
456 __MPFR_DECLSPEC int mpfr_d_sub _MPFR_PROTO ((mpfr_ptr, double,
457 mpfr_srcptr, mpfr_rnd_t));
458 __MPFR_DECLSPEC int mpfr_mul_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
459 double, mpfr_rnd_t));
460 __MPFR_DECLSPEC int mpfr_div_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
461 double, mpfr_rnd_t));
462 __MPFR_DECLSPEC int mpfr_d_div _MPFR_PROTO ((mpfr_ptr, double,
463 mpfr_srcptr, mpfr_rnd_t));
465 __MPFR_DECLSPEC int mpfr_sqr _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
467 __MPFR_DECLSPEC int mpfr_const_pi _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
468 __MPFR_DECLSPEC int mpfr_const_log2 _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
469 __MPFR_DECLSPEC int mpfr_const_euler _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
470 __MPFR_DECLSPEC int mpfr_const_catalan _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
472 __MPFR_DECLSPEC int mpfr_agm _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
475 __MPFR_DECLSPEC int mpfr_log _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
476 __MPFR_DECLSPEC int mpfr_log2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
477 __MPFR_DECLSPEC int mpfr_log10 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
479 __MPFR_DECLSPEC int mpfr_log1p _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
482 __MPFR_DECLSPEC int mpfr_exp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
483 __MPFR_DECLSPEC int mpfr_exp2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
484 __MPFR_DECLSPEC int mpfr_exp10 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
486 __MPFR_DECLSPEC int mpfr_expm1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
488 __MPFR_DECLSPEC int mpfr_eint _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
489 __MPFR_DECLSPEC int mpfr_li2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
491 __MPFR_DECLSPEC int mpfr_cmp _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
492 __MPFR_DECLSPEC int mpfr_cmp3 _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr, int));
493 __MPFR_DECLSPEC int mpfr_cmp_d _MPFR_PROTO ((mpfr_srcptr, double));
494 __MPFR_DECLSPEC int mpfr_cmp_ld _MPFR_PROTO ((mpfr_srcptr, long double));
495 __MPFR_DECLSPEC int mpfr_cmpabs _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
496 __MPFR_DECLSPEC int mpfr_cmp_ui _MPFR_PROTO ((mpfr_srcptr, unsigned long));
497 __MPFR_DECLSPEC int mpfr_cmp_si _MPFR_PROTO ((mpfr_srcptr, long));
498 __MPFR_DECLSPEC int mpfr_cmp_ui_2exp _MPFR_PROTO ((mpfr_srcptr, unsigned long,
500 __MPFR_DECLSPEC int mpfr_cmp_si_2exp _MPFR_PROTO ((mpfr_srcptr, long,
502 __MPFR_DECLSPEC void mpfr_reldiff _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
503 mpfr_srcptr, mpfr_rnd_t));
504 __MPFR_DECLSPEC int mpfr_eq _MPFR_PROTO((mpfr_srcptr, mpfr_srcptr,
506 __MPFR_DECLSPEC int mpfr_sgn _MPFR_PROTO ((mpfr_srcptr));
508 __MPFR_DECLSPEC int mpfr_mul_2exp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
509 unsigned long, mpfr_rnd_t));
510 __MPFR_DECLSPEC int mpfr_div_2exp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
511 unsigned long, mpfr_rnd_t));
512 __MPFR_DECLSPEC int mpfr_mul_2ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
513 unsigned long, mpfr_rnd_t));
514 __MPFR_DECLSPEC int mpfr_div_2ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
515 unsigned long, mpfr_rnd_t));
516 __MPFR_DECLSPEC int mpfr_mul_2si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
518 __MPFR_DECLSPEC int mpfr_div_2si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
521 __MPFR_DECLSPEC int mpfr_rint _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
522 __MPFR_DECLSPEC int mpfr_round _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
523 __MPFR_DECLSPEC int mpfr_trunc _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
524 __MPFR_DECLSPEC int mpfr_ceil _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
525 __MPFR_DECLSPEC int mpfr_floor _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
526 __MPFR_DECLSPEC int mpfr_rint_round _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
528 __MPFR_DECLSPEC int mpfr_rint_trunc _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
530 __MPFR_DECLSPEC int mpfr_rint_ceil _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
532 __MPFR_DECLSPEC int mpfr_rint_floor _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
534 __MPFR_DECLSPEC int mpfr_frac _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
535 __MPFR_DECLSPEC int mpfr_modf _MPFR_PROTO ((mpfr_ptr, mpfr_ptr, mpfr_srcptr,
537 __MPFR_DECLSPEC int mpfr_remquo _MPFR_PROTO ((mpfr_ptr, long*, mpfr_srcptr,
538 mpfr_srcptr, mp_rnd_t));
539 __MPFR_DECLSPEC int mpfr_remainder _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
540 mpfr_srcptr, mp_rnd_t));
541 __MPFR_DECLSPEC int mpfr_fmod _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
542 mpfr_srcptr, mp_rnd_t));
544 __MPFR_DECLSPEC int mpfr_fits_ulong_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
545 __MPFR_DECLSPEC int mpfr_fits_slong_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
546 __MPFR_DECLSPEC int mpfr_fits_uint_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
547 __MPFR_DECLSPEC int mpfr_fits_sint_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
548 __MPFR_DECLSPEC int mpfr_fits_ushort_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
549 __MPFR_DECLSPEC int mpfr_fits_sshort_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
550 __MPFR_DECLSPEC int mpfr_fits_uintmax_p _MPFR_PROTO((mpfr_srcptr,mpfr_rnd_t));
551 __MPFR_DECLSPEC int mpfr_fits_intmax_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
553 __MPFR_DECLSPEC void mpfr_extract _MPFR_PROTO ((mpz_ptr, mpfr_srcptr,
555 __MPFR_DECLSPEC void mpfr_swap _MPFR_PROTO ((mpfr_ptr, mpfr_ptr));
556 __MPFR_DECLSPEC void mpfr_dump _MPFR_PROTO ((mpfr_srcptr));
558 __MPFR_DECLSPEC int mpfr_nan_p _MPFR_PROTO((mpfr_srcptr));
559 __MPFR_DECLSPEC int mpfr_inf_p _MPFR_PROTO((mpfr_srcptr));
560 __MPFR_DECLSPEC int mpfr_number_p _MPFR_PROTO((mpfr_srcptr));
561 __MPFR_DECLSPEC int mpfr_integer_p _MPFR_PROTO ((mpfr_srcptr));
562 __MPFR_DECLSPEC int mpfr_zero_p _MPFR_PROTO ((mpfr_srcptr));
564 __MPFR_DECLSPEC int mpfr_greater_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
565 __MPFR_DECLSPEC int mpfr_greaterequal_p _MPFR_PROTO ((mpfr_srcptr,
567 __MPFR_DECLSPEC int mpfr_less_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
568 __MPFR_DECLSPEC int mpfr_lessequal_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
569 __MPFR_DECLSPEC int mpfr_lessgreater_p _MPFR_PROTO((mpfr_srcptr,mpfr_srcptr));
570 __MPFR_DECLSPEC int mpfr_equal_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
571 __MPFR_DECLSPEC int mpfr_unordered_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
573 __MPFR_DECLSPEC int mpfr_atanh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
574 __MPFR_DECLSPEC int mpfr_acosh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
575 __MPFR_DECLSPEC int mpfr_asinh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
576 __MPFR_DECLSPEC int mpfr_cosh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
577 __MPFR_DECLSPEC int mpfr_sinh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
578 __MPFR_DECLSPEC int mpfr_tanh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
579 __MPFR_DECLSPEC int mpfr_sinh_cosh _MPFR_PROTO ((mpfr_ptr, mpfr_ptr,
580 mpfr_srcptr, mpfr_rnd_t));
582 __MPFR_DECLSPEC int mpfr_sech _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
583 __MPFR_DECLSPEC int mpfr_csch _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
584 __MPFR_DECLSPEC int mpfr_coth _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
586 __MPFR_DECLSPEC int mpfr_acos _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
587 __MPFR_DECLSPEC int mpfr_asin _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
588 __MPFR_DECLSPEC int mpfr_atan _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
589 __MPFR_DECLSPEC int mpfr_sin _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
590 __MPFR_DECLSPEC int mpfr_sin_cos _MPFR_PROTO ((mpfr_ptr, mpfr_ptr,
591 mpfr_srcptr, mpfr_rnd_t));
592 __MPFR_DECLSPEC int mpfr_cos _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
593 __MPFR_DECLSPEC int mpfr_tan _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
594 __MPFR_DECLSPEC int mpfr_atan2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_srcptr,
596 __MPFR_DECLSPEC int mpfr_sec _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
597 __MPFR_DECLSPEC int mpfr_csc _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
598 __MPFR_DECLSPEC int mpfr_cot _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
600 __MPFR_DECLSPEC int mpfr_hypot _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
601 mpfr_srcptr, mpfr_rnd_t));
602 __MPFR_DECLSPEC int mpfr_erf _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
603 __MPFR_DECLSPEC int mpfr_erfc _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
604 __MPFR_DECLSPEC int mpfr_cbrt _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
605 __MPFR_DECLSPEC int mpfr_root _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,unsigned long,mpfr_rnd_t));
606 __MPFR_DECLSPEC int mpfr_gamma _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
607 __MPFR_DECLSPEC int mpfr_lngamma _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
608 __MPFR_DECLSPEC int mpfr_lgamma _MPFR_PROTO((mpfr_ptr,int*,mpfr_srcptr,mpfr_rnd_t));
609 __MPFR_DECLSPEC int mpfr_zeta _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
610 __MPFR_DECLSPEC int mpfr_zeta_ui _MPFR_PROTO ((mpfr_ptr,unsigned long,mpfr_rnd_t));
611 __MPFR_DECLSPEC int mpfr_fac_ui _MPFR_PROTO ((mpfr_ptr, unsigned long int,
613 __MPFR_DECLSPEC int mpfr_j0 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
614 __MPFR_DECLSPEC int mpfr_j1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
615 __MPFR_DECLSPEC int mpfr_jn _MPFR_PROTO ((mpfr_ptr, long, mpfr_srcptr,
617 __MPFR_DECLSPEC int mpfr_y0 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
618 __MPFR_DECLSPEC int mpfr_y1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
619 __MPFR_DECLSPEC int mpfr_yn _MPFR_PROTO ((mpfr_ptr, long, mpfr_srcptr,
622 __MPFR_DECLSPEC int mpfr_min _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
624 __MPFR_DECLSPEC int mpfr_max _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
626 __MPFR_DECLSPEC int mpfr_dim _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
629 __MPFR_DECLSPEC int mpfr_mul_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
630 mpz_srcptr, mpfr_rnd_t));
631 __MPFR_DECLSPEC int mpfr_div_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
632 mpz_srcptr, mpfr_rnd_t));
633 __MPFR_DECLSPEC int mpfr_add_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
634 mpz_srcptr, mpfr_rnd_t));
635 __MPFR_DECLSPEC int mpfr_sub_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
636 mpz_srcptr, mpfr_rnd_t));
637 __MPFR_DECLSPEC int mpfr_cmp_z _MPFR_PROTO ((mpfr_srcptr, mpz_srcptr));
639 __MPFR_DECLSPEC int mpfr_mul_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
640 mpq_srcptr, mpfr_rnd_t));
641 __MPFR_DECLSPEC int mpfr_div_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
642 mpq_srcptr, mpfr_rnd_t));
643 __MPFR_DECLSPEC int mpfr_add_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
644 mpq_srcptr, mpfr_rnd_t));
645 __MPFR_DECLSPEC int mpfr_sub_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
646 mpq_srcptr, mpfr_rnd_t));
647 __MPFR_DECLSPEC int mpfr_cmp_q _MPFR_PROTO ((mpfr_srcptr, mpq_srcptr));
649 __MPFR_DECLSPEC int mpfr_cmp_f _MPFR_PROTO ((mpfr_srcptr, mpf_srcptr));
651 __MPFR_DECLSPEC int mpfr_fma _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
652 mpfr_srcptr, mpfr_rnd_t));
653 __MPFR_DECLSPEC int mpfr_fms _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
654 mpfr_srcptr, mpfr_rnd_t));
655 __MPFR_DECLSPEC int mpfr_sum _MPFR_PROTO ((mpfr_ptr, mpfr_ptr *__gmp_const,
656 unsigned long, mpfr_rnd_t));
658 __MPFR_DECLSPEC void mpfr_free_cache _MPFR_PROTO ((void));
660 __MPFR_DECLSPEC int mpfr_subnormalize _MPFR_PROTO ((mpfr_ptr, int,
663 __MPFR_DECLSPEC int mpfr_strtofr _MPFR_PROTO ((mpfr_ptr, __gmp_const char *,
664 char **, int, mpfr_rnd_t));
666 __MPFR_DECLSPEC size_t mpfr_custom_get_size _MPFR_PROTO ((mp_prec_t));
667 __MPFR_DECLSPEC void mpfr_custom_init _MPFR_PROTO ((void *, mp_prec_t));
668 __MPFR_DECLSPEC void * mpfr_custom_get_mantissa _MPFR_PROTO ((mpfr_srcptr));
669 __MPFR_DECLSPEC mp_exp_t mpfr_custom_get_exp _MPFR_PROTO ((mpfr_srcptr));
670 __MPFR_DECLSPEC void mpfr_custom_move _MPFR_PROTO ((mpfr_ptr, void *));
671 __MPFR_DECLSPEC void mpfr_custom_init_set _MPFR_PROTO ((mpfr_ptr, int,
672 mp_exp_t, mp_prec_t, void *));
673 __MPFR_DECLSPEC int mpfr_custom_get_kind _MPFR_PROTO ((mpfr_srcptr));
675 #if defined (__cplusplus)
679 /* DON'T USE THIS! (For MPFR-public macros only, see below.)
680 The mpfr_sgn macro uses the fact that __MPFR_EXP_NAN and __MPFR_EXP_ZERO
681 are the smallest values. */
682 #if __GMP_MP_SIZE_T_INT
683 #define __MPFR_EXP_NAN ((mp_exp_t)((~((~(unsigned int)0)>>1))+2))
684 #define __MPFR_EXP_ZERO ((mp_exp_t)((~((~(unsigned int)0)>>1))+1))
685 #define __MPFR_EXP_INF ((mp_exp_t)((~((~(unsigned int)0)>>1))+3))
687 #define __MPFR_EXP_NAN ((mp_exp_t)((~((~(unsigned long)0)>>1))+2))
688 #define __MPFR_EXP_ZERO ((mp_exp_t)((~((~(unsigned long)0)>>1))+1))
689 #define __MPFR_EXP_INF ((mp_exp_t)((~((~(unsigned long)0)>>1))+3))
692 /* Define MPFR_USE_EXTENSION to avoid "gcc -pedantic" warnings. */
693 #ifndef MPFR_EXTENSION
694 # if defined(MPFR_USE_EXTENSION)
695 # define MPFR_EXTENSION __extension__
697 # define MPFR_EXTENSION
701 /* Warning! This macro doesn't work with K&R C and shouldn't be used
702 internally. For public use only, but see the MPFR manual. */
703 #define MPFR_DECL_INIT(_x, _p) \
704 MPFR_EXTENSION mp_limb_t __gmpfr_local_tab_##_x[((_p)-1)/GMP_NUMB_BITS+1]; \
705 MPFR_EXTENSION mpfr_t _x = {{(_p),1,__MPFR_EXP_NAN,__gmpfr_local_tab_##_x}}
707 /* Fast access macros to replace function interface.
708 If the USER don't want to use the macro interface, let him make happy
709 even if it produces faster and smaller code. */
710 #ifndef MPFR_USE_NO_MACRO
712 /* Inlining theses functions is both faster and smaller */
713 #define mpfr_nan_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_NAN)
714 #define mpfr_inf_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_INF)
715 #define mpfr_zero_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_ZERO)
716 #define mpfr_sgn(_x) \
717 ((_x)->_mpfr_exp < __MPFR_EXP_INF ? \
718 (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (void) 0), 0 : \
721 /* Prevent them from using as lvalues */
722 #define mpfr_get_prec(_x) ((_x)->_mpfr_prec + 0)
723 #define mpfr_get_exp(_x) ((_x)->_mpfr_exp + 0)
725 #define mpfr_round(a,b) mpfr_rint((a), (b), GMP_RNDNA)
726 #define mpfr_trunc(a,b) mpfr_rint((a), (b), GMP_RNDZ)
727 #define mpfr_ceil(a,b) mpfr_rint((a), (b), GMP_RNDU)
728 #define mpfr_floor(a,b) mpfr_rint((a), (b), GMP_RNDD)
730 #define mpfr_cmp_ui(b,i) mpfr_cmp_ui_2exp((b),(i),0)
731 #define mpfr_cmp_si(b,i) mpfr_cmp_si_2exp((b),(i),0)
732 #define mpfr_set(a,b,r) mpfr_set4(a,b,r,MPFR_SIGN(b))
733 #define mpfr_abs(a,b,r) mpfr_set4(a,b,r,1)
734 #define mpfr_copysign(a,b,c,r) mpfr_set4(a,b,r,MPFR_SIGN(c))
735 #define mpfr_setsign(a,b,s,r) mpfr_set4(a,b,r,(s) ? -1 : 1)
736 #define mpfr_signbit(x) (MPFR_SIGN(x) < 0)
737 #define mpfr_cmp(b, c) mpfr_cmp3(b, c, 1)
738 #define mpfr_mul_2exp(y,x,n,r) mpfr_mul_2ui((y),(x),(n),(r))
739 #define mpfr_div_2exp(y,x,n,r) mpfr_div_2ui((y),(x),(n),(r))
742 /* When using GCC, optimize certain common comparisons and affectations.
743 + Remove ICC since it defines __GNUC__ but produces a
744 huge number of warnings if you use this code.
745 VL: I couldn't reproduce a single warning when enabling these macros
746 with icc 10.1 20080212 on Itanium. But with this version, __ICC isn't
747 defined (__INTEL_COMPILER is, though), so that these macros are enabled
748 anyway. Checking with other ICC versions is needed. Possibly detect
749 whether warnings are produced or not with a configure test.
750 + Remove C++ too, since it complains too much. */
751 #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus)
754 /* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0. */
755 #define mpfr_cmp_ui(_f,_u) \
756 (__builtin_constant_p (_u) && (_u) == 0 ? \
758 mpfr_cmp_ui_2exp ((_f),(_u),0))
760 #define mpfr_cmp_si(_f,_s) \
761 (__builtin_constant_p (_s) && (_s) >= 0 ? \
762 mpfr_cmp_ui ((_f), (_s)) : \
763 mpfr_cmp_si_2exp ((_f), (_s), 0))
764 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
766 #define mpfr_set_ui(_f,_u,_r) \
767 (__builtin_constant_p (_u) && (_u) == 0 ? \
769 mpfr_ptr _p = (_f); \
770 _p->_mpfr_sign = 1; \
771 _p->_mpfr_exp = __MPFR_EXP_ZERO; \
772 (void) (_r); 0; }) : \
773 mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
776 #define mpfr_set_si(_f,_s,_r) \
777 (__builtin_constant_p (_s) && (_s) >= 0 ? \
778 mpfr_set_ui ((_f), (_s), (_r)) : \
779 mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
783 /* Macro version of mpfr_stack interface for fast access */
784 #define mpfr_custom_get_size(p) ((size_t) \
785 (((p)+GMP_NUMB_BITS-1)/GMP_NUMB_BITS*sizeof (mp_limb_t)))
786 #define mpfr_custom_init(m,p) do {} while (0)
787 #define mpfr_custom_get_mantissa(x) ((void*)((x)->_mpfr_d))
788 #define mpfr_custom_get_exp(x) ((x)->_mpfr_exp)
789 #define mpfr_custom_move(x,m) do { ((x)->_mpfr_d = (mp_limb_t*)(m)); } while (0)
790 #define mpfr_custom_init_set(x,k,e,p,m) do { \
797 _t = (mpfr_kind_t) _k; \
800 _t = (mpfr_kind_t) -k; \
803 _e = _t == MPFR_REGULAR_KIND ? (e) : \
804 _t == MPFR_NAN_KIND ? __MPFR_EXP_NAN : \
805 _t == MPFR_INF_KIND ? __MPFR_EXP_INF : __MPFR_EXP_ZERO; \
806 _x->_mpfr_prec = (p); \
807 _x->_mpfr_sign = _s; \
808 _x->_mpfr_exp = _e; \
809 _x->_mpfr_d = (mp_limb_t*) (m); \
811 #define mpfr_custom_get_kind(x) \
812 ( (x)->_mpfr_exp > __MPFR_EXP_INF ? (int)MPFR_REGULAR_KIND*MPFR_SIGN (x) \
813 : (x)->_mpfr_exp == __MPFR_EXP_INF ? (int)MPFR_INF_KIND*MPFR_SIGN (x) \
814 : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (int)MPFR_NAN_KIND \
815 : (int) MPFR_ZERO_KIND * MPFR_SIGN (x) )
818 #endif /* MPFR_USE_NO_MACRO */
820 /* Theses are defined to be macros */
821 #define mpfr_init_set_si(x, i, rnd) \
822 ( mpfr_init(x), mpfr_set_si((x), (i), (rnd)) )
823 #define mpfr_init_set_ui(x, i, rnd) \
824 ( mpfr_init(x), mpfr_set_ui((x), (i), (rnd)) )
825 #define mpfr_init_set_d(x, d, rnd) \
826 ( mpfr_init(x), mpfr_set_d((x), (d), (rnd)) )
827 #define mpfr_init_set_ld(x, d, rnd) \
828 ( mpfr_init(x), mpfr_set_ld((x), (d), (rnd)) )
829 #define mpfr_init_set_z(x, i, rnd) \
830 ( mpfr_init(x), mpfr_set_z((x), (i), (rnd)) )
831 #define mpfr_init_set_q(x, i, rnd) \
832 ( mpfr_init(x), mpfr_set_q((x), (i), (rnd)) )
833 #define mpfr_init_set(x, y, rnd) \
834 ( mpfr_init(x), mpfr_set((x), (y), (rnd)) )
835 #define mpfr_init_set_f(x, y, rnd) \
836 ( mpfr_init(x), mpfr_set_f((x), (y), (rnd)) )
838 /* Compatibility layer -- obsolete functions and macros */
839 #define mpfr_cmp_abs mpfr_cmpabs
840 #define mpfr_round_prec(x,r,p) mpfr_prec_round(x,p,r)
841 #define __gmp_default_rounding_mode (mpfr_get_default_rounding_mode())
842 #define __mpfr_emin (mpfr_get_emin())
843 #define __mpfr_emax (mpfr_get_emax())
844 #define __mpfr_default_fp_bit_precision (mpfr_get_default_fp_bit_precision())
845 #define MPFR_EMIN_MIN mpfr_get_emin_min()
846 #define MPFR_EMIN_MAX mpfr_get_emin_max()
847 #define MPFR_EMAX_MIN mpfr_get_emax_min()
848 #define MPFR_EMAX_MAX mpfr_get_emax_max()
849 #define mpfr_version (mpfr_get_version())
851 # define mpz_set_fr mpfr_get_z
853 #define mpfr_add_one_ulp(x,r) \
854 (mpfr_sgn (x) > 0 ? mpfr_nextabove (x) : mpfr_nextbelow (x))
855 #define mpfr_sub_one_ulp(x,r) \
856 (mpfr_sgn (x) > 0 ? mpfr_nextbelow (x) : mpfr_nextabove (x))