Home | History | Annotate | Download | only in include
      1 /* mpfr.h -- Include file for mpfr.
      2 
      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.
      5 
      6 This file is part of the GNU MPFR Library.
      7 
      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.
     12 
     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.
     17 
     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. */
     22 
     23 #ifndef __MPFR_H
     24 #define __MPFR_H
     25 
     26 /* Define MPFR version number */
     27 #define MPFR_VERSION_MAJOR 2
     28 #define MPFR_VERSION_MINOR 4
     29 #define MPFR_VERSION_PATCHLEVEL 1
     30 #define MPFR_VERSION_STRING "2.4.1"
     31 
     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)
     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 /* 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
     45 #endif
     46 
     47 #if defined (_GMP_H_HAVE_VA_LIST)
     48 # define _MPFR_H_HAVE_VA_LIST 1
     49 #endif
     50 
     51 /* Check if stdint.h/inttypes.h is included or if the user wants intmax_t */
     52 #if (defined (INTMAX_C) && defined (UINTMAX_C)) || defined (MPFR_USE_INTMAX_T)
     53 # define _MPFR_H_HAVE_INTMAX_T 1
     54 #endif
     55 
     56 /* Definition of rounding modes (DON'T USE GMP_RNDNA!)
     57    Warning! Changing the contents of this enum should be seen as an
     58    interface change since the old and the new types are not compatible
     59    (the integer type compatible with the enumerated type can even change,
     60    see ISO C99, 6.7.2.2#4), and in Makefile.am, AGE should be set to 0. */
     61 typedef enum {
     62   GMP_RNDN=0, GMP_RNDZ, GMP_RNDU, GMP_RNDD, GMP_RND_MAX,
     63   GMP_RNDNA=-1
     64 } mpfr_rnd_t;
     65 
     66 /* Define precision : 1 (short), 2 (int) or 3 (long) (DON'T USE IT!)*/
     67 #ifndef _MPFR_PREC_FORMAT
     68 # if __GMP_MP_SIZE_T_INT == 1
     69 #  define _MPFR_PREC_FORMAT 2
     70 # else
     71 #  define _MPFR_PREC_FORMAT 3
     72 # endif
     73 #endif
     74 
     75 #if   _MPFR_PREC_FORMAT == 1
     76 typedef unsigned short mpfr_prec_t;
     77 #elif _MPFR_PREC_FORMAT == 2
     78 typedef unsigned int   mpfr_prec_t;
     79 #elif _MPFR_PREC_FORMAT == 3
     80 typedef unsigned long  mpfr_prec_t;
     81 #else
     82 # error "Invalid MPFR Prec format"
     83 #endif
     84 
     85 /* Definition of precision limits */
     86 #define MPFR_PREC_MIN 2
     87 #define MPFR_PREC_MAX ((mpfr_prec_t)((mpfr_prec_t)(~(mpfr_prec_t)0)>>1))
     88 
     89 /* Definition of sign */
     90 typedef int          mpfr_sign_t;
     91 
     92 /* Definition of the standard exponent limits */
     93 #define MPFR_EMAX_DEFAULT ((mp_exp_t) (((unsigned long) 1 << 30) - 1))
     94 #define MPFR_EMIN_DEFAULT (-(MPFR_EMAX_DEFAULT))
     95 
     96 /* Definition of the main structure */
     97 typedef struct {
     98   mpfr_prec_t  _mpfr_prec;
     99   mpfr_sign_t  _mpfr_sign;
    100   mp_exp_t     _mpfr_exp;
    101   mp_limb_t   *_mpfr_d;
    102 } __mpfr_struct;
    103 
    104 /* Compatibility with previous types of MPFR */
    105 #ifndef mp_rnd_t
    106 # define mp_rnd_t  mpfr_rnd_t
    107 #endif
    108 #ifndef mp_prec_t
    109 # define mp_prec_t mpfr_prec_t
    110 #endif
    111 
    112 /*
    113    The represented number is
    114       _sign*(_d[k-1]/B+_d[k-2]/B^2+...+_d[0]/B^k)*2^_exp
    115    where k=ceil(_mp_prec/BITS_PER_MP_LIMB) and B=2^BITS_PER_MP_LIMB.
    116 
    117    For the msb (most significant bit) normalized representation, we must have
    118       _d[k-1]>=B/2, unless the number is singular.
    119 
    120    We must also have the last k*BITS_PER_MP_LIMB-_prec bits set to zero.
    121 */
    122 
    123 typedef __mpfr_struct mpfr_t[1];
    124 typedef __mpfr_struct *mpfr_ptr;
    125 typedef __gmp_const __mpfr_struct *mpfr_srcptr;
    126 
    127 /* For those who need a direct and fast access to the sign field.
    128    However it is not in the API, thus use it at your own risk: it might
    129    not be supported, or change name, in further versions!
    130    Unfortunately, it must be defined here (instead of MPFR's internal
    131    header file mpfr-impl.h) because it is used by some macros below.
    132 */
    133 #define MPFR_SIGN(x) ((x)->_mpfr_sign)
    134 
    135 /* Stack interface */
    136 typedef enum {
    137   MPFR_NAN_KIND = 0,
    138   MPFR_INF_KIND = 1, MPFR_ZERO_KIND = 2, MPFR_REGULAR_KIND = 3
    139 } mpfr_kind_t;
    140 
    141 /* GMP defines:
    142     + size_t:                Standard size_t
    143     + __GMP_ATTRIBUTE_PURE   Attribute for math functions.
    144     + __GMP_NOTHROW          For C++: can't throw .
    145     + __GMP_EXTERN_INLINE    Attribute for inline function.
    146     * __gmp_const            const (Supports for K&R compiler only for mpfr.h).
    147     + __GMP_DECLSPEC_EXPORT  compiling to go into a DLL
    148     + __GMP_DECLSPEC_IMPORT  compiling to go into a application
    149 */
    150 /* Extra MPFR defines */
    151 #define __MPFR_SENTINEL_ATTR
    152 #if defined (__GNUC__)
    153 # if __GNUC__ >= 4
    154 #  undef __MPFR_SENTINEL_ATTR
    155 #  define __MPFR_SENTINEL_ATTR __attribute__ ((sentinel))
    156 # endif
    157 #endif
    158 
    159 /* Prototypes: Support of K&R compiler */
    160 #if defined (__GMP_PROTO)
    161 # define _MPFR_PROTO __GMP_PROTO
    162 #elif defined (__STDC__) || defined (__cplusplus)
    163 # define _MPFR_PROTO(x) x
    164 #else
    165 # define _MPFR_PROTO(x) ()
    166 #endif
    167 /* Support for WINDOWS Dll:
    168    Check if we are inside a MPFR build, and if so export the functions.
    169    Otherwise does the same thing as GMP */
    170 #if defined(__MPFR_WITHIN_MPFR) && __GMP_LIBGMP_DLL
    171 # define __MPFR_DECLSPEC __GMP_DECLSPEC_EXPORT
    172 #else
    173 # define __MPFR_DECLSPEC __GMP_DECLSPEC
    174 #endif
    175 
    176 /* Note: some functions need that a specific system header is included before
    177    mpfr.h to be defined. If the user forgets to include the header, the mpfr
    178    function prototype in the user object file is not correct. In order to
    179    raise a linker error in that case, we change their internal name in the
    180    GNU mpfr library (prefixed by __gmpfr instead of mpfr)*/
    181 #if defined (__cplusplus)
    182 extern "C" {
    183 #endif
    184 
    185 __MPFR_DECLSPEC __gmp_const char * mpfr_get_version _MPFR_PROTO ((void));
    186 __MPFR_DECLSPEC __gmp_const char * mpfr_get_patches _MPFR_PROTO ((void));
    187 
    188 __MPFR_DECLSPEC mp_exp_t mpfr_get_emin     _MPFR_PROTO ((void));
    189 __MPFR_DECLSPEC int      mpfr_set_emin     _MPFR_PROTO ((mp_exp_t));
    190 __MPFR_DECLSPEC mp_exp_t mpfr_get_emin_min _MPFR_PROTO ((void));
    191 __MPFR_DECLSPEC mp_exp_t mpfr_get_emin_max _MPFR_PROTO ((void));
    192 __MPFR_DECLSPEC mp_exp_t mpfr_get_emax     _MPFR_PROTO ((void));
    193 __MPFR_DECLSPEC int      mpfr_set_emax     _MPFR_PROTO ((mp_exp_t));
    194 __MPFR_DECLSPEC mp_exp_t mpfr_get_emax_min _MPFR_PROTO ((void));
    195 __MPFR_DECLSPEC mp_exp_t mpfr_get_emax_max _MPFR_PROTO ((void));
    196 
    197 __MPFR_DECLSPEC void mpfr_set_default_rounding_mode _MPFR_PROTO((mpfr_rnd_t));
    198 __MPFR_DECLSPEC mp_rnd_t mpfr_get_default_rounding_mode _MPFR_PROTO((void));
    199 __MPFR_DECLSPEC __gmp_const char *
    200    mpfr_print_rnd_mode _MPFR_PROTO((mpfr_rnd_t));
    201 
    202 __MPFR_DECLSPEC void mpfr_clear_flags _MPFR_PROTO ((void));
    203 __MPFR_DECLSPEC void mpfr_clear_underflow _MPFR_PROTO ((void));
    204 __MPFR_DECLSPEC void mpfr_clear_overflow _MPFR_PROTO ((void));
    205 __MPFR_DECLSPEC void mpfr_clear_nanflag _MPFR_PROTO ((void));
    206 __MPFR_DECLSPEC void mpfr_clear_inexflag _MPFR_PROTO ((void));
    207 __MPFR_DECLSPEC void mpfr_clear_erangeflag _MPFR_PROTO ((void));
    208 
    209 __MPFR_DECLSPEC void mpfr_set_underflow _MPFR_PROTO ((void));
    210 __MPFR_DECLSPEC void mpfr_set_overflow _MPFR_PROTO ((void));
    211 __MPFR_DECLSPEC void mpfr_set_nanflag _MPFR_PROTO ((void));
    212 __MPFR_DECLSPEC void mpfr_set_inexflag _MPFR_PROTO ((void));
    213 __MPFR_DECLSPEC void mpfr_set_erangeflag _MPFR_PROTO ((void));
    214 
    215 __MPFR_DECLSPEC int mpfr_underflow_p _MPFR_PROTO ((void));
    216 __MPFR_DECLSPEC int mpfr_overflow_p _MPFR_PROTO ((void));
    217 __MPFR_DECLSPEC int mpfr_nanflag_p _MPFR_PROTO ((void));
    218 __MPFR_DECLSPEC int mpfr_inexflag_p _MPFR_PROTO ((void));
    219 __MPFR_DECLSPEC int mpfr_erangeflag_p _MPFR_PROTO ((void));
    220 
    221 __MPFR_DECLSPEC int
    222   mpfr_check_range _MPFR_PROTO ((mpfr_ptr, int, mpfr_rnd_t));
    223 
    224 __MPFR_DECLSPEC void mpfr_init2 _MPFR_PROTO ((mpfr_ptr, mpfr_prec_t));
    225 __MPFR_DECLSPEC void mpfr_init _MPFR_PROTO ((mpfr_ptr));
    226 __MPFR_DECLSPEC void mpfr_clear _MPFR_PROTO ((mpfr_ptr));
    227 
    228 __MPFR_DECLSPEC void
    229   mpfr_inits2 _MPFR_PROTO ((mp_prec_t, mpfr_ptr, ...)) __MPFR_SENTINEL_ATTR;
    230 __MPFR_DECLSPEC void
    231   mpfr_inits _MPFR_PROTO ((mpfr_ptr, ...)) __MPFR_SENTINEL_ATTR;
    232 __MPFR_DECLSPEC void
    233   mpfr_clears _MPFR_PROTO ((mpfr_ptr, ...)) __MPFR_SENTINEL_ATTR;
    234 
    235 __MPFR_DECLSPEC int
    236   mpfr_prec_round _MPFR_PROTO ((mpfr_ptr, mpfr_prec_t, mpfr_rnd_t));
    237 __MPFR_DECLSPEC int
    238   mpfr_can_round _MPFR_PROTO ((mpfr_srcptr, mp_exp_t, mpfr_rnd_t, mpfr_rnd_t,
    239                                mpfr_prec_t));
    240 
    241 __MPFR_DECLSPEC mp_exp_t mpfr_get_exp _MPFR_PROTO ((mpfr_srcptr));
    242 __MPFR_DECLSPEC int mpfr_set_exp _MPFR_PROTO ((mpfr_ptr, mp_exp_t));
    243 __MPFR_DECLSPEC mp_prec_t mpfr_get_prec _MPFR_PROTO((mpfr_srcptr));
    244 __MPFR_DECLSPEC void mpfr_set_prec _MPFR_PROTO((mpfr_ptr, mpfr_prec_t));
    245 __MPFR_DECLSPEC void mpfr_set_prec_raw _MPFR_PROTO((mpfr_ptr, mpfr_prec_t));
    246 __MPFR_DECLSPEC void mpfr_set_default_prec _MPFR_PROTO((mpfr_prec_t));
    247 __MPFR_DECLSPEC mp_prec_t mpfr_get_default_prec _MPFR_PROTO((void));
    248 
    249 __MPFR_DECLSPEC int mpfr_set_d _MPFR_PROTO ((mpfr_ptr, double, mpfr_rnd_t));
    250 #ifdef MPFR_WANT_DECIMAL_FLOATS
    251 __MPFR_DECLSPEC int mpfr_set_decimal64 _MPFR_PROTO ((mpfr_ptr, _Decimal64,
    252                                                      mp_rnd_t));
    253 #endif
    254 __MPFR_DECLSPEC int
    255   mpfr_set_ld _MPFR_PROTO ((mpfr_ptr, long double, mpfr_rnd_t));
    256 __MPFR_DECLSPEC int
    257   mpfr_set_z _MPFR_PROTO ((mpfr_ptr, mpz_srcptr, mpfr_rnd_t));
    258 __MPFR_DECLSPEC void mpfr_set_nan _MPFR_PROTO ((mpfr_ptr));
    259 __MPFR_DECLSPEC void mpfr_set_inf _MPFR_PROTO ((mpfr_ptr, int));
    260 __MPFR_DECLSPEC int
    261   mpfr_set_f _MPFR_PROTO ((mpfr_ptr, mpf_srcptr, mpfr_rnd_t));
    262 __MPFR_DECLSPEC int
    263   mpfr_get_f _MPFR_PROTO ((mpf_ptr, mpfr_srcptr, mpfr_rnd_t));
    264 __MPFR_DECLSPEC int mpfr_set_si _MPFR_PROTO ((mpfr_ptr, long, mpfr_rnd_t));
    265 __MPFR_DECLSPEC int
    266   mpfr_set_ui _MPFR_PROTO ((mpfr_ptr, unsigned long, mpfr_rnd_t));
    267 __MPFR_DECLSPEC int
    268   mpfr_set_si_2exp _MPFR_PROTO ((mpfr_ptr, long, mp_exp_t, mpfr_rnd_t));
    269 __MPFR_DECLSPEC int
    270   mpfr_set_ui_2exp _MPFR_PROTO ((mpfr_ptr,unsigned long,mp_exp_t,mpfr_rnd_t));
    271 __MPFR_DECLSPEC int
    272   mpfr_set_q _MPFR_PROTO ((mpfr_ptr, mpq_srcptr, mpfr_rnd_t));
    273 __MPFR_DECLSPEC int
    274   mpfr_set_str _MPFR_PROTO ((mpfr_ptr, __gmp_const char *, int, mpfr_rnd_t));
    275 __MPFR_DECLSPEC int
    276   mpfr_init_set_str _MPFR_PROTO ((mpfr_ptr, __gmp_const char *, int,
    277                                   mpfr_rnd_t));
    278 __MPFR_DECLSPEC int
    279   mpfr_set4 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t, int));
    280 __MPFR_DECLSPEC int
    281   mpfr_abs _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
    282 __MPFR_DECLSPEC int
    283   mpfr_set _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
    284 __MPFR_DECLSPEC int mpfr_neg _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
    285 __MPFR_DECLSPEC int mpfr_signbit _MPFR_PROTO ((mpfr_srcptr));
    286 __MPFR_DECLSPEC int
    287   mpfr_setsign _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, int, mpfr_rnd_t));
    288 __MPFR_DECLSPEC int
    289   mpfr_copysign _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t));
    290 
    291 #ifdef _MPFR_H_HAVE_INTMAX_T
    292 #define mpfr_set_sj __gmpfr_set_sj
    293 #define mpfr_set_sj_2exp __gmpfr_set_sj_2exp
    294 #define mpfr_set_uj __gmpfr_set_uj
    295 #define mpfr_set_uj_2exp __gmpfr_set_uj_2exp
    296 #define mpfr_get_sj __gmpfr_mpfr_get_sj
    297 #define mpfr_get_uj __gmpfr_mpfr_get_uj
    298 __MPFR_DECLSPEC int mpfr_set_sj _MPFR_PROTO ((mpfr_t, intmax_t, mpfr_rnd_t));
    299 __MPFR_DECLSPEC int
    300   mpfr_set_sj_2exp _MPFR_PROTO ((mpfr_t, intmax_t, intmax_t, mpfr_rnd_t));
    301 __MPFR_DECLSPEC int mpfr_set_uj _MPFR_PROTO ((mpfr_t, uintmax_t, mpfr_rnd_t));
    302 __MPFR_DECLSPEC int
    303   mpfr_set_uj_2exp _MPFR_PROTO ((mpfr_t, uintmax_t, intmax_t, mpfr_rnd_t));
    304 __MPFR_DECLSPEC intmax_t mpfr_get_sj _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
    305 __MPFR_DECLSPEC uintmax_t mpfr_get_uj _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
    306 #endif
    307 
    308 __MPFR_DECLSPEC mp_exp_t mpfr_get_z_exp _MPFR_PROTO ((mpz_ptr, mpfr_srcptr));
    309 __MPFR_DECLSPEC double mpfr_get_d _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
    310 #ifdef MPFR_WANT_DECIMAL_FLOATS
    311 __MPFR_DECLSPEC _Decimal64 mpfr_get_decimal64 _MPFR_PROTO ((mpfr_srcptr,
    312                                                            mp_rnd_t));
    313 #endif
    314 __MPFR_DECLSPEC long double mpfr_get_ld _MPFR_PROTO ((mpfr_srcptr,
    315                                                       mpfr_rnd_t));
    316 __MPFR_DECLSPEC double mpfr_get_d1 _MPFR_PROTO ((mpfr_srcptr));
    317 __MPFR_DECLSPEC double mpfr_get_d_2exp _MPFR_PROTO ((long*, mpfr_srcptr,
    318                                                      mpfr_rnd_t));
    319 __MPFR_DECLSPEC long double mpfr_get_ld_2exp _MPFR_PROTO ((long*, mpfr_srcptr,
    320                                                            mpfr_rnd_t));
    321 __MPFR_DECLSPEC long mpfr_get_si _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
    322 __MPFR_DECLSPEC unsigned long mpfr_get_ui _MPFR_PROTO ((mpfr_srcptr,
    323                                                         mpfr_rnd_t));
    324 __MPFR_DECLSPEC char*mpfr_get_str _MPFR_PROTO ((char*, mp_exp_t*, int, size_t,
    325                                                 mpfr_srcptr, mpfr_rnd_t));
    326 __MPFR_DECLSPEC void mpfr_get_z _MPFR_PROTO ((mpz_ptr z, mpfr_srcptr f,
    327                                               mpfr_rnd_t));
    328 
    329 __MPFR_DECLSPEC void mpfr_free_str _MPFR_PROTO ((char *));
    330 
    331 
    332 __MPFR_DECLSPEC void mpfr_random _MPFR_PROTO ((mpfr_ptr));
    333 __MPFR_DECLSPEC void mpfr_random2 _MPFR_PROTO ((mpfr_ptr,mp_size_t,mp_exp_t));
    334 __MPFR_DECLSPEC int mpfr_urandomb _MPFR_PROTO ((mpfr_ptr, gmp_randstate_t));
    335 
    336 __MPFR_DECLSPEC void mpfr_nextabove _MPFR_PROTO ((mpfr_ptr));
    337 __MPFR_DECLSPEC void mpfr_nextbelow _MPFR_PROTO ((mpfr_ptr));
    338 __MPFR_DECLSPEC void mpfr_nexttoward _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr));
    339 
    340 #ifdef _MPFR_H_HAVE_FILE
    341 #define mpfr_inp_str __gmpfr_inp_str
    342 #define mpfr_out_str __gmpfr_out_str
    343 __MPFR_DECLSPEC size_t mpfr_inp_str _MPFR_PROTO ((mpfr_ptr, FILE*, int,
    344                                                   mpfr_rnd_t));
    345 __MPFR_DECLSPEC size_t mpfr_out_str _MPFR_PROTO ((FILE*, int, size_t,
    346                                                   mpfr_srcptr, mpfr_rnd_t));
    347 #define mpfr_fprintf __gmpfr_fprintf
    348 __MPFR_DECLSPEC int mpfr_fprintf _MPFR_PROTO ((FILE*, __gmp_const char*,
    349                                                ...));
    350 #endif
    351 __MPFR_DECLSPEC int mpfr_printf _MPFR_PROTO ((__gmp_const char*, ...));
    352 __MPFR_DECLSPEC int mpfr_asprintf _MPFR_PROTO ((char**, __gmp_const char*,
    353                                                 ...));
    354 __MPFR_DECLSPEC int mpfr_sprintf _MPFR_PROTO ((char*, __gmp_const char*,
    355                                                ...));
    356 __MPFR_DECLSPEC int mpfr_snprintf _MPFR_PROTO ((char*, size_t,
    357                                                 __gmp_const char*, ...));
    358 
    359 #ifdef _MPFR_H_HAVE_VA_LIST
    360 #ifdef _MPFR_H_HAVE_FILE
    361 #define mpfr_vfprintf __gmpfr_vfprintf
    362 __MPFR_DECLSPEC int mpfr_vfprintf _MPFR_PROTO ((FILE*, __gmp_const char*,
    363                                                 va_list));
    364 #endif /* _MPFR_H_HAVE_FILE */
    365 #define mpfr_vprintf __gmpfr_vprintf
    366 #define mpfr_vasprintf __gmpfr_vasprintf
    367 #define mpfr_vsprintf __gmpfr_vsprintf
    368 #define mpfr_vsnprintf __gmpfr_vsnprintf
    369 __MPFR_DECLSPEC int mpfr_vprintf _MPFR_PROTO ((__gmp_const char*, va_list));
    370 __MPFR_DECLSPEC int mpfr_vasprintf _MPFR_PROTO ((char**, __gmp_const char*,
    371                                                  va_list));
    372 __MPFR_DECLSPEC int mpfr_vsprintf _MPFR_PROTO ((char*, __gmp_const char*,
    373                                                va_list));
    374 __MPFR_DECLSPEC int mpfr_vsnprintf _MPFR_PROTO ((char*, size_t,
    375                                                 __gmp_const char*, va_list));
    376 #endif /* _MPFR_H_HAVE_VA_LIST */
    377 
    378 __MPFR_DECLSPEC int mpfr_pow _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    379                                            mpfr_srcptr, mpfr_rnd_t));
    380 __MPFR_DECLSPEC int mpfr_pow_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    381                                               long int, mpfr_rnd_t));
    382 __MPFR_DECLSPEC int mpfr_pow_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    383                                               unsigned long int, mpfr_rnd_t));
    384 __MPFR_DECLSPEC int mpfr_ui_pow_ui _MPFR_PROTO ((mpfr_ptr, unsigned long int,
    385                                              unsigned long int, mpfr_rnd_t));
    386 __MPFR_DECLSPEC int mpfr_ui_pow _MPFR_PROTO ((mpfr_ptr, unsigned long int,
    387                                               mpfr_srcptr, mpfr_rnd_t));
    388 __MPFR_DECLSPEC int mpfr_pow_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    389                                              mpz_srcptr, mpfr_rnd_t));
    390 
    391 __MPFR_DECLSPEC int mpfr_sqrt _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    392                                             mpfr_rnd_t));
    393 __MPFR_DECLSPEC int mpfr_sqrt_ui _MPFR_PROTO ((mpfr_ptr, unsigned long,
    394                                                mpfr_rnd_t));
    395 __MPFR_DECLSPEC int mpfr_rec_sqrt _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    396                                                 mpfr_rnd_t));
    397 
    398 __MPFR_DECLSPEC int mpfr_add _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    399                                            mpfr_srcptr, mpfr_rnd_t));
    400 __MPFR_DECLSPEC int mpfr_sub _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    401                                            mpfr_srcptr, mpfr_rnd_t));
    402 __MPFR_DECLSPEC int mpfr_mul _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    403                                            mpfr_srcptr, mpfr_rnd_t));
    404 __MPFR_DECLSPEC int mpfr_div _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    405                                            mpfr_srcptr, mpfr_rnd_t));
    406 
    407 __MPFR_DECLSPEC int mpfr_add_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    408                                               unsigned long, mpfr_rnd_t));
    409 __MPFR_DECLSPEC int mpfr_sub_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    410                                               unsigned long, mpfr_rnd_t));
    411 __MPFR_DECLSPEC int mpfr_ui_sub _MPFR_PROTO ((mpfr_ptr, unsigned long,
    412                                               mpfr_srcptr, mpfr_rnd_t));
    413 __MPFR_DECLSPEC int mpfr_mul_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    414                                               unsigned long, mpfr_rnd_t));
    415 __MPFR_DECLSPEC int mpfr_div_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    416                                               unsigned long, mpfr_rnd_t));
    417 __MPFR_DECLSPEC int mpfr_ui_div _MPFR_PROTO ((mpfr_ptr, unsigned long,
    418                                               mpfr_srcptr, mpfr_rnd_t));
    419 
    420 __MPFR_DECLSPEC int mpfr_add_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    421                                               long int, mpfr_rnd_t));
    422 __MPFR_DECLSPEC int mpfr_sub_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    423                                               long int, mpfr_rnd_t));
    424 __MPFR_DECLSPEC int mpfr_si_sub _MPFR_PROTO ((mpfr_ptr, long int,
    425                                               mpfr_srcptr, mpfr_rnd_t));
    426 __MPFR_DECLSPEC int mpfr_mul_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    427                                               long int, mpfr_rnd_t));
    428 __MPFR_DECLSPEC int mpfr_div_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    429                                               long int, mpfr_rnd_t));
    430 __MPFR_DECLSPEC int mpfr_si_div _MPFR_PROTO ((mpfr_ptr, long int,
    431                                               mpfr_srcptr, mpfr_rnd_t));
    432 
    433 __MPFR_DECLSPEC int mpfr_add_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    434                                               double, mpfr_rnd_t));
    435 __MPFR_DECLSPEC int mpfr_sub_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    436                                               double, mpfr_rnd_t));
    437 __MPFR_DECLSPEC int mpfr_d_sub _MPFR_PROTO ((mpfr_ptr, double,
    438                                               mpfr_srcptr, mpfr_rnd_t));
    439 __MPFR_DECLSPEC int mpfr_mul_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    440                                               double, mpfr_rnd_t));
    441 __MPFR_DECLSPEC int mpfr_div_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    442                                               double, mpfr_rnd_t));
    443 __MPFR_DECLSPEC int mpfr_d_div _MPFR_PROTO ((mpfr_ptr, double,
    444                                               mpfr_srcptr, mpfr_rnd_t));
    445 
    446 __MPFR_DECLSPEC int mpfr_sqr _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
    447 
    448 __MPFR_DECLSPEC int mpfr_const_pi _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
    449 __MPFR_DECLSPEC int mpfr_const_log2 _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
    450 __MPFR_DECLSPEC int mpfr_const_euler _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
    451 __MPFR_DECLSPEC int mpfr_const_catalan _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
    452 
    453 __MPFR_DECLSPEC int mpfr_agm _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
    454                                            mpfr_rnd_t));
    455 
    456 __MPFR_DECLSPEC int mpfr_log _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
    457 __MPFR_DECLSPEC int mpfr_log2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
    458 __MPFR_DECLSPEC int mpfr_log10 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    459                                              mpfr_rnd_t));
    460 __MPFR_DECLSPEC int mpfr_log1p _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    461                                              mpfr_rnd_t));
    462 
    463 __MPFR_DECLSPEC int mpfr_exp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
    464 __MPFR_DECLSPEC int mpfr_exp2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
    465 __MPFR_DECLSPEC int mpfr_exp10 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    466                                              mpfr_rnd_t));
    467 __MPFR_DECLSPEC int mpfr_expm1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    468                                              mpfr_rnd_t));
    469 __MPFR_DECLSPEC int mpfr_eint _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
    470 __MPFR_DECLSPEC int mpfr_li2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
    471 
    472 __MPFR_DECLSPEC int mpfr_cmp  _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
    473 __MPFR_DECLSPEC int mpfr_cmp3 _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr, int));
    474 __MPFR_DECLSPEC int mpfr_cmp_d _MPFR_PROTO ((mpfr_srcptr, double));
    475 __MPFR_DECLSPEC int mpfr_cmp_ld _MPFR_PROTO ((mpfr_srcptr, long double));
    476 __MPFR_DECLSPEC int mpfr_cmpabs _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
    477 __MPFR_DECLSPEC int mpfr_cmp_ui _MPFR_PROTO ((mpfr_srcptr, unsigned long));
    478 __MPFR_DECLSPEC int mpfr_cmp_si _MPFR_PROTO ((mpfr_srcptr, long));
    479 __MPFR_DECLSPEC int mpfr_cmp_ui_2exp _MPFR_PROTO ((mpfr_srcptr, unsigned long,
    480                                                    mp_exp_t));
    481 __MPFR_DECLSPEC int mpfr_cmp_si_2exp _MPFR_PROTO ((mpfr_srcptr, long,
    482                                                    mp_exp_t));
    483 __MPFR_DECLSPEC void mpfr_reldiff _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    484                                                 mpfr_srcptr, mpfr_rnd_t));
    485 __MPFR_DECLSPEC int mpfr_eq _MPFR_PROTO((mpfr_srcptr, mpfr_srcptr,
    486                                          unsigned long));
    487 __MPFR_DECLSPEC int mpfr_sgn _MPFR_PROTO ((mpfr_srcptr));
    488 
    489 __MPFR_DECLSPEC int mpfr_mul_2exp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    490                                                 unsigned long, mpfr_rnd_t));
    491 __MPFR_DECLSPEC int mpfr_div_2exp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    492                                                 unsigned long, mpfr_rnd_t));
    493 __MPFR_DECLSPEC int mpfr_mul_2ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    494                                                unsigned long, mpfr_rnd_t));
    495 __MPFR_DECLSPEC int mpfr_div_2ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    496                                                unsigned long, mpfr_rnd_t));
    497 __MPFR_DECLSPEC int mpfr_mul_2si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    498                                                long, mpfr_rnd_t));
    499 __MPFR_DECLSPEC int mpfr_div_2si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    500                                                long, mpfr_rnd_t));
    501 
    502 __MPFR_DECLSPEC int mpfr_rint _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
    503 __MPFR_DECLSPEC int mpfr_round _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
    504 __MPFR_DECLSPEC int mpfr_trunc _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
    505 __MPFR_DECLSPEC int mpfr_ceil _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
    506 __MPFR_DECLSPEC int mpfr_floor _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
    507 __MPFR_DECLSPEC int mpfr_rint_round _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    508                                                   mpfr_rnd_t));
    509 __MPFR_DECLSPEC int mpfr_rint_trunc _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    510                                                   mpfr_rnd_t));
    511 __MPFR_DECLSPEC int mpfr_rint_ceil _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    512                                                  mpfr_rnd_t));
    513 __MPFR_DECLSPEC int mpfr_rint_floor _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    514                                                   mpfr_rnd_t));
    515 __MPFR_DECLSPEC int mpfr_frac _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
    516 __MPFR_DECLSPEC int mpfr_modf _MPFR_PROTO ((mpfr_ptr, mpfr_ptr, mpfr_srcptr,
    517                                                   mpfr_rnd_t));
    518 __MPFR_DECLSPEC int mpfr_remquo _MPFR_PROTO ((mpfr_ptr, long*, mpfr_srcptr,
    519                                               mpfr_srcptr, mp_rnd_t));
    520 __MPFR_DECLSPEC int mpfr_remainder _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    521                                                  mpfr_srcptr, mp_rnd_t));
    522 __MPFR_DECLSPEC int mpfr_fmod _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    523                                                  mpfr_srcptr, mp_rnd_t));
    524 
    525 __MPFR_DECLSPEC int mpfr_fits_ulong_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
    526 __MPFR_DECLSPEC int mpfr_fits_slong_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
    527 __MPFR_DECLSPEC int mpfr_fits_uint_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
    528 __MPFR_DECLSPEC int mpfr_fits_sint_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
    529 __MPFR_DECLSPEC int mpfr_fits_ushort_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
    530 __MPFR_DECLSPEC int mpfr_fits_sshort_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
    531 __MPFR_DECLSPEC int mpfr_fits_uintmax_p _MPFR_PROTO((mpfr_srcptr,mpfr_rnd_t));
    532 __MPFR_DECLSPEC int mpfr_fits_intmax_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
    533 
    534 __MPFR_DECLSPEC void mpfr_extract _MPFR_PROTO ((mpz_ptr, mpfr_srcptr,
    535                                                 unsigned int));
    536 __MPFR_DECLSPEC void mpfr_swap _MPFR_PROTO ((mpfr_ptr, mpfr_ptr));
    537 __MPFR_DECLSPEC void mpfr_dump _MPFR_PROTO ((mpfr_srcptr));
    538 
    539 __MPFR_DECLSPEC int mpfr_nan_p _MPFR_PROTO((mpfr_srcptr));
    540 __MPFR_DECLSPEC int mpfr_inf_p _MPFR_PROTO((mpfr_srcptr));
    541 __MPFR_DECLSPEC int mpfr_number_p _MPFR_PROTO((mpfr_srcptr));
    542 __MPFR_DECLSPEC int mpfr_integer_p _MPFR_PROTO ((mpfr_srcptr));
    543 __MPFR_DECLSPEC int mpfr_zero_p _MPFR_PROTO ((mpfr_srcptr));
    544 
    545 __MPFR_DECLSPEC int mpfr_greater_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
    546 __MPFR_DECLSPEC int mpfr_greaterequal_p _MPFR_PROTO ((mpfr_srcptr,
    547                                                       mpfr_srcptr));
    548 __MPFR_DECLSPEC int mpfr_less_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
    549 __MPFR_DECLSPEC int mpfr_lessequal_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
    550 __MPFR_DECLSPEC int mpfr_lessgreater_p _MPFR_PROTO((mpfr_srcptr,mpfr_srcptr));
    551 __MPFR_DECLSPEC int mpfr_equal_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
    552 __MPFR_DECLSPEC int mpfr_unordered_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
    553 
    554 __MPFR_DECLSPEC int mpfr_atanh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
    555 __MPFR_DECLSPEC int mpfr_acosh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
    556 __MPFR_DECLSPEC int mpfr_asinh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
    557 __MPFR_DECLSPEC int mpfr_cosh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
    558 __MPFR_DECLSPEC int mpfr_sinh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
    559 __MPFR_DECLSPEC int mpfr_tanh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
    560 __MPFR_DECLSPEC int mpfr_sinh_cosh _MPFR_PROTO ((mpfr_ptr, mpfr_ptr,
    561                                                mpfr_srcptr, mpfr_rnd_t));
    562 
    563 __MPFR_DECLSPEC int mpfr_sech _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
    564 __MPFR_DECLSPEC int mpfr_csch _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
    565 __MPFR_DECLSPEC int mpfr_coth _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
    566 
    567 __MPFR_DECLSPEC int mpfr_acos _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
    568 __MPFR_DECLSPEC int mpfr_asin _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
    569 __MPFR_DECLSPEC int mpfr_atan _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
    570 __MPFR_DECLSPEC int mpfr_sin _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
    571 __MPFR_DECLSPEC int mpfr_sin_cos _MPFR_PROTO ((mpfr_ptr, mpfr_ptr,
    572                                                mpfr_srcptr, mpfr_rnd_t));
    573 __MPFR_DECLSPEC int mpfr_cos _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
    574 __MPFR_DECLSPEC int mpfr_tan _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
    575 __MPFR_DECLSPEC int mpfr_atan2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_srcptr,
    576                                              mpfr_rnd_t));
    577 __MPFR_DECLSPEC int mpfr_sec _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
    578 __MPFR_DECLSPEC int mpfr_csc _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
    579 __MPFR_DECLSPEC int mpfr_cot _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
    580 
    581 __MPFR_DECLSPEC int mpfr_hypot _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    582                                              mpfr_srcptr, mpfr_rnd_t));
    583 __MPFR_DECLSPEC int mpfr_erf _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
    584 __MPFR_DECLSPEC int mpfr_erfc _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
    585 __MPFR_DECLSPEC int mpfr_cbrt _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
    586 __MPFR_DECLSPEC int mpfr_root _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,unsigned long,mpfr_rnd_t));
    587 __MPFR_DECLSPEC int mpfr_gamma _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
    588 __MPFR_DECLSPEC int mpfr_lngamma _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
    589 __MPFR_DECLSPEC int mpfr_lgamma _MPFR_PROTO((mpfr_ptr,int*,mpfr_srcptr,mpfr_rnd_t));
    590 __MPFR_DECLSPEC int mpfr_zeta _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
    591 __MPFR_DECLSPEC int mpfr_zeta_ui _MPFR_PROTO ((mpfr_ptr,unsigned long,mpfr_rnd_t));
    592 __MPFR_DECLSPEC int mpfr_fac_ui _MPFR_PROTO ((mpfr_ptr, unsigned long int,
    593                                               mpfr_rnd_t));
    594 __MPFR_DECLSPEC int mpfr_j0 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
    595 __MPFR_DECLSPEC int mpfr_j1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
    596 __MPFR_DECLSPEC int mpfr_jn _MPFR_PROTO ((mpfr_ptr, long, mpfr_srcptr,
    597                                           mpfr_rnd_t));
    598 __MPFR_DECLSPEC int mpfr_y0 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
    599 __MPFR_DECLSPEC int mpfr_y1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
    600 __MPFR_DECLSPEC int mpfr_yn _MPFR_PROTO ((mpfr_ptr, long, mpfr_srcptr,
    601                                           mpfr_rnd_t));
    602 
    603 __MPFR_DECLSPEC int mpfr_min _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
    604                                            mpfr_rnd_t));
    605 __MPFR_DECLSPEC int mpfr_max _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
    606                                            mpfr_rnd_t));
    607 __MPFR_DECLSPEC int mpfr_dim _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
    608                                            mpfr_rnd_t));
    609 
    610 __MPFR_DECLSPEC int mpfr_mul_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    611                                              mpz_srcptr, mpfr_rnd_t));
    612 __MPFR_DECLSPEC int mpfr_div_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    613                                              mpz_srcptr, mpfr_rnd_t));
    614 __MPFR_DECLSPEC int mpfr_add_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    615                                              mpz_srcptr, mpfr_rnd_t));
    616 __MPFR_DECLSPEC int mpfr_sub_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    617                                              mpz_srcptr, mpfr_rnd_t));
    618 __MPFR_DECLSPEC int mpfr_cmp_z _MPFR_PROTO ((mpfr_srcptr, mpz_srcptr));
    619 
    620 __MPFR_DECLSPEC int mpfr_mul_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    621                                              mpq_srcptr, mpfr_rnd_t));
    622 __MPFR_DECLSPEC int mpfr_div_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    623                                              mpq_srcptr, mpfr_rnd_t));
    624 __MPFR_DECLSPEC int mpfr_add_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    625                                              mpq_srcptr, mpfr_rnd_t));
    626 __MPFR_DECLSPEC int mpfr_sub_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
    627                                              mpq_srcptr, mpfr_rnd_t));
    628 __MPFR_DECLSPEC int mpfr_cmp_q _MPFR_PROTO ((mpfr_srcptr, mpq_srcptr));
    629 
    630 __MPFR_DECLSPEC int mpfr_cmp_f _MPFR_PROTO ((mpfr_srcptr, mpf_srcptr));
    631 
    632 __MPFR_DECLSPEC int mpfr_fma _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
    633                                            mpfr_srcptr, mpfr_rnd_t));
    634 __MPFR_DECLSPEC int mpfr_fms _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
    635                                            mpfr_srcptr, mpfr_rnd_t));
    636 __MPFR_DECLSPEC int mpfr_sum _MPFR_PROTO ((mpfr_ptr, mpfr_ptr *__gmp_const,
    637                                            unsigned long, mpfr_rnd_t));
    638 
    639 __MPFR_DECLSPEC void mpfr_free_cache _MPFR_PROTO ((void));
    640 
    641 __MPFR_DECLSPEC int  mpfr_subnormalize _MPFR_PROTO ((mpfr_ptr, int,
    642                                                      mp_rnd_t));
    643 
    644 __MPFR_DECLSPEC int  mpfr_strtofr _MPFR_PROTO ((mpfr_ptr, __gmp_const char *,
    645                                                 char **, int, mpfr_rnd_t));
    646 
    647 __MPFR_DECLSPEC size_t mpfr_custom_get_size   _MPFR_PROTO ((mp_prec_t));
    648 __MPFR_DECLSPEC void   mpfr_custom_init       _MPFR_PROTO ((void *, mp_prec_t));
    649 __MPFR_DECLSPEC void * mpfr_custom_get_mantissa _MPFR_PROTO ((mpfr_srcptr));
    650 __MPFR_DECLSPEC mp_exp_t mpfr_custom_get_exp  _MPFR_PROTO ((mpfr_srcptr));
    651 __MPFR_DECLSPEC void   mpfr_custom_move       _MPFR_PROTO ((mpfr_ptr, void *));
    652 __MPFR_DECLSPEC void   mpfr_custom_init_set   _MPFR_PROTO ((mpfr_ptr, int,
    653                                                mp_exp_t, mp_prec_t, void *));
    654 __MPFR_DECLSPEC int    mpfr_custom_get_kind   _MPFR_PROTO ((mpfr_srcptr));
    655 
    656 #if defined (__cplusplus)
    657 }
    658 #endif
    659 
    660 /* DON'T USE THIS! (For MPFR-public macros only, see below.)
    661    The mpfr_sgn macro uses the fact that __MPFR_EXP_NAN and __MPFR_EXP_ZERO
    662    are the smallest values. */
    663 #if __GMP_MP_SIZE_T_INT
    664 #define __MPFR_EXP_NAN  ((mp_exp_t)((~((~(unsigned int)0)>>1))+2))
    665 #define __MPFR_EXP_ZERO ((mp_exp_t)((~((~(unsigned int)0)>>1))+1))
    666 #define __MPFR_EXP_INF  ((mp_exp_t)((~((~(unsigned int)0)>>1))+3))
    667 #else
    668 #define __MPFR_EXP_NAN  ((mp_exp_t)((~((~(unsigned long)0)>>1))+2))
    669 #define __MPFR_EXP_ZERO ((mp_exp_t)((~((~(unsigned long)0)>>1))+1))
    670 #define __MPFR_EXP_INF  ((mp_exp_t)((~((~(unsigned long)0)>>1))+3))
    671 #endif
    672 
    673 /* Define MPFR_USE_EXTENSION to avoid "gcc -pedantic" warnings. */
    674 #ifndef MPFR_EXTENSION
    675 # if defined(MPFR_USE_EXTENSION)
    676 #  define MPFR_EXTENSION __extension__
    677 # else
    678 #  define MPFR_EXTENSION
    679 # endif
    680 #endif
    681 
    682 /* Warning! This macro doesn't work with K&R C and shouldn't be used
    683    internally. For public use only, but see the MPFR manual. */
    684 #define MPFR_DECL_INIT(_x, _p)                                        \
    685   MPFR_EXTENSION mp_limb_t __gmpfr_local_tab_##_x[((_p)-1)/GMP_NUMB_BITS+1]; \
    686   MPFR_EXTENSION mpfr_t _x = {{(_p),1,__MPFR_EXP_NAN,__gmpfr_local_tab_##_x}}
    687 
    688 /* Fast access macros to replace function interface.
    689    If the USER don't want to use the macro interface, let him make happy
    690    even if it produces faster and smaller code. */
    691 #ifndef MPFR_USE_NO_MACRO
    692 
    693 /* Inlining theses functions is both faster and smaller */
    694 #define mpfr_nan_p(_x)    ((_x)->_mpfr_exp == __MPFR_EXP_NAN)
    695 #define mpfr_inf_p(_x)    ((_x)->_mpfr_exp == __MPFR_EXP_INF)
    696 #define mpfr_zero_p(_x)   ((_x)->_mpfr_exp == __MPFR_EXP_ZERO)
    697 #define mpfr_sgn(_x)                                          \
    698   ((_x)->_mpfr_exp < __MPFR_EXP_INF ?                         \
    699    (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (void) 0), 0 : \
    700    MPFR_SIGN (_x))
    701 
    702 /* Prevent them from using as lvalues */
    703 #define mpfr_get_prec(_x) ((_x)->_mpfr_prec + 0)
    704 #define mpfr_get_exp(_x)  ((_x)->_mpfr_exp + 0)
    705 
    706 #define mpfr_round(a,b) mpfr_rint((a), (b), GMP_RNDNA)
    707 #define mpfr_trunc(a,b) mpfr_rint((a), (b), GMP_RNDZ)
    708 #define mpfr_ceil(a,b)  mpfr_rint((a), (b), GMP_RNDU)
    709 #define mpfr_floor(a,b) mpfr_rint((a), (b), GMP_RNDD)
    710 
    711 #define mpfr_cmp_ui(b,i) mpfr_cmp_ui_2exp((b),(i),0)
    712 #define mpfr_cmp_si(b,i) mpfr_cmp_si_2exp((b),(i),0)
    713 #define mpfr_set(a,b,r)  mpfr_set4(a,b,r,MPFR_SIGN(b))
    714 #define mpfr_abs(a,b,r)  mpfr_set4(a,b,r,1)
    715 #define mpfr_copysign(a,b,c,r) mpfr_set4(a,b,r,MPFR_SIGN(c))
    716 #define mpfr_setsign(a,b,s,r) mpfr_set4(a,b,r,(s) ? -1 : 1)
    717 #define mpfr_signbit(x)  (MPFR_SIGN(x) < 0)
    718 #define mpfr_cmp(b, c)   mpfr_cmp3(b, c, 1)
    719 #define mpfr_mul_2exp(y,x,n,r) mpfr_mul_2ui((y),(x),(n),(r))
    720 #define mpfr_div_2exp(y,x,n,r) mpfr_div_2ui((y),(x),(n),(r))
    721 
    722 
    723 /* When using GCC, optimize certain common comparisons and affectations.
    724    + Remove ICC since it defines __GNUC__ but produces a
    725      huge number of warnings if you use this code.
    726      VL: I couldn't reproduce a single warning when enabling these macros
    727      with icc 10.1 20080212 on Itanium. But with this version, __ICC isn't
    728      defined (__INTEL_COMPILER is, though), so that these macros are enabled
    729      anyway. Checking with other ICC versions is needed. Possibly detect
    730      whether warnings are produced or not with a configure test.
    731    + Remove C++ too, since it complains too much. */
    732 #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus)
    733 #if (__GNUC__ >= 2)
    734 #undef mpfr_cmp_ui
    735 /* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0. */
    736 #define mpfr_cmp_ui(_f,_u)                 \
    737  (__builtin_constant_p (_u) && (_u) == 0 ? \
    738    mpfr_sgn (_f) :                         \
    739    mpfr_cmp_ui_2exp ((_f),(_u),0))
    740 #undef mpfr_cmp_si
    741 #define mpfr_cmp_si(_f,_s)                 \
    742  (__builtin_constant_p (_s) && (_s) >= 0 ? \
    743    mpfr_cmp_ui ((_f), (_s)) :              \
    744    mpfr_cmp_si_2exp ((_f), (_s), 0))
    745 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
    746 #undef mpfr_set_ui
    747 #define mpfr_set_ui(_f,_u,_r)              \
    748  (__builtin_constant_p (_u) && (_u) == 0 ? \
    749    __extension__ ({                        \
    750      mpfr_ptr _p = (_f);                   \
    751      _p->_mpfr_sign = 1;                   \
    752      _p->_mpfr_exp = __MPFR_EXP_ZERO;      \
    753      (void) (_r); 0; }) :                  \
    754    mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
    755 #endif
    756 #undef mpfr_set_si
    757 #define mpfr_set_si(_f,_s,_r)              \
    758  (__builtin_constant_p (_s) && (_s) >= 0 ? \
    759    mpfr_set_ui ((_f), (_s), (_r)) :        \
    760    mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
    761 #endif
    762 #endif
    763 
    764 /* Macro version of mpfr_stack interface for fast access */
    765 #define mpfr_custom_get_size(p) ((size_t)                            \
    766        (((p)+GMP_NUMB_BITS-1)/GMP_NUMB_BITS*sizeof (mp_limb_t)))
    767 #define mpfr_custom_init(m,p) do {} while (0)
    768 #define mpfr_custom_get_mantissa(x) ((void*)((x)->_mpfr_d))
    769 #define mpfr_custom_get_exp(x) ((x)->_mpfr_exp)
    770 #define mpfr_custom_move(x,m) do { ((x)->_mpfr_d = (mp_limb_t*)(m)); } while (0)
    771 #define mpfr_custom_init_set(x,k,e,p,m) do {                    \
    772   mpfr_ptr _x = (x);                                           \
    773   mp_exp_t _e;                                                 \
    774   mpfr_kind_t _t;                                              \
    775   int _s, _k;                                                  \
    776   _k = (k);                                                    \
    777   if (_k >= 0)  {                                              \
    778     _t = (mpfr_kind_t) _k;                                     \
    779     _s = 1;                                                    \
    780   } else {                                                     \
    781     _t = (mpfr_kind_t) -k;                                     \
    782     _s = -1;                                                   \
    783   }                                                            \
    784   _e = _t == MPFR_REGULAR_KIND ? (e) :                         \
    785     _t == MPFR_NAN_KIND ? __MPFR_EXP_NAN :                     \
    786     _t == MPFR_INF_KIND ? __MPFR_EXP_INF : __MPFR_EXP_ZERO;    \
    787   _x->_mpfr_prec = (p);                                        \
    788   _x->_mpfr_sign = _s;                                         \
    789   _x->_mpfr_exp  = _e;                                         \
    790   _x->_mpfr_d    = (mp_limb_t*) (m);                           \
    791  } while (0)
    792 #define mpfr_custom_get_kind(x)                                              \
    793   ( (x)->_mpfr_exp >  __MPFR_EXP_INF ? (int)MPFR_REGULAR_KIND*MPFR_SIGN (x) \
    794   : (x)->_mpfr_exp == __MPFR_EXP_INF ? (int)MPFR_INF_KIND*MPFR_SIGN (x)     \
    795   : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (int)MPFR_NAN_KIND                   \
    796   : (int) MPFR_ZERO_KIND * MPFR_SIGN (x) )
    797 
    798 
    799 #endif /* MPFR_USE_NO_MACRO */
    800 
    801 /* Theses are defined to be macros */
    802 #define mpfr_init_set_si(x, i, rnd) \
    803  ( mpfr_init(x), mpfr_set_si((x), (i), (rnd)) )
    804 #define mpfr_init_set_ui(x, i, rnd) \
    805  ( mpfr_init(x), mpfr_set_ui((x), (i), (rnd)) )
    806 #define mpfr_init_set_d(x, d, rnd) \
    807  ( mpfr_init(x), mpfr_set_d((x), (d), (rnd)) )
    808 #define mpfr_init_set_ld(x, d, rnd) \
    809  ( mpfr_init(x), mpfr_set_ld((x), (d), (rnd)) )
    810 #define mpfr_init_set_z(x, i, rnd) \
    811  ( mpfr_init(x), mpfr_set_z((x), (i), (rnd)) )
    812 #define mpfr_init_set_q(x, i, rnd) \
    813  ( mpfr_init(x), mpfr_set_q((x), (i), (rnd)) )
    814 #define mpfr_init_set(x, y, rnd) \
    815  ( mpfr_init(x), mpfr_set((x), (y), (rnd)) )
    816 #define mpfr_init_set_f(x, y, rnd) \
    817  ( mpfr_init(x), mpfr_set_f((x), (y), (rnd)) )
    818 
    819 /* Compatibility layer -- obsolete functions and macros */
    820 #define mpfr_cmp_abs mpfr_cmpabs
    821 #define mpfr_round_prec(x,r,p) mpfr_prec_round(x,p,r)
    822 #define __gmp_default_rounding_mode (mpfr_get_default_rounding_mode())
    823 #define __mpfr_emin (mpfr_get_emin())
    824 #define __mpfr_emax (mpfr_get_emax())
    825 #define __mpfr_default_fp_bit_precision (mpfr_get_default_fp_bit_precision())
    826 #define MPFR_EMIN_MIN mpfr_get_emin_min()
    827 #define MPFR_EMIN_MAX mpfr_get_emin_max()
    828 #define MPFR_EMAX_MIN mpfr_get_emax_min()
    829 #define MPFR_EMAX_MAX mpfr_get_emax_max()
    830 #define mpfr_version (mpfr_get_version())
    831 #ifndef mpz_set_fr
    832 # define mpz_set_fr mpfr_get_z
    833 #endif
    834 #define mpfr_add_one_ulp(x,r) \
    835  (mpfr_sgn (x) > 0 ? mpfr_nextabove (x) : mpfr_nextbelow (x))
    836 #define mpfr_sub_one_ulp(x,r) \
    837  (mpfr_sgn (x) > 0 ? mpfr_nextbelow (x) : mpfr_nextabove (x))
    838 
    839 #endif /* __MPFR_H*/
    840