Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/mpfr.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* mpfr.h -- Include file for mpfr.
0002 
0003 Copyright 1999-2023 Free Software Foundation, Inc.
0004 Contributed by the AriC and Caramba projects, INRIA.
0005 
0006 This file is part of the GNU MPFR Library.
0007 
0008 The GNU MPFR Library is free software; you can redistribute it and/or modify
0009 it under the terms of the GNU Lesser General Public License as published by
0010 the Free Software Foundation; either version 3 of the License, or (at your
0011 option) any later version.
0012 
0013 The GNU MPFR Library is distributed in the hope that it will be useful, but
0014 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
0015 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
0016 License for more details.
0017 
0018 You should have received a copy of the GNU Lesser General Public License
0019 along with the GNU MPFR Library; see the file COPYING.LESSER.  If not, see
0020 https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
0021 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
0022 
0023 #ifndef __MPFR_H
0024 #define __MPFR_H
0025 
0026 /* Define MPFR version number */
0027 #define MPFR_VERSION_MAJOR 4
0028 #define MPFR_VERSION_MINOR 2
0029 #define MPFR_VERSION_PATCHLEVEL 1
0030 #define MPFR_VERSION_STRING "4.2.1-p1"
0031 
0032 /* User macros:
0033    MPFR_USE_FILE:        Define it to make MPFR define functions dealing
0034                          with FILE* (auto-detect).
0035    MPFR_USE_INTMAX_T:    Define it to make MPFR define functions dealing
0036                          with intmax_t (auto-detect).
0037    MPFR_USE_VA_LIST:     Define it to make MPFR define functions dealing
0038                          with va_list (auto-detect).
0039    MPFR_USE_C99_FEATURE: Define it to 1 to make MPFR support C99-feature
0040                          (auto-detect), to 0 to bypass the detection.
0041    MPFR_USE_EXTENSION:   Define it to make MPFR use GCC extension to
0042                          reduce warnings.
0043    MPFR_USE_NO_MACRO:    Define it to make MPFR remove any overriding
0044                          function macro.
0045 */
0046 
0047 /* Macros dealing with MPFR VERSION */
0048 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
0049 #define MPFR_VERSION \
0050 MPFR_VERSION_NUM(MPFR_VERSION_MAJOR,MPFR_VERSION_MINOR,MPFR_VERSION_PATCHLEVEL)
0051 
0052 #ifndef MPFR_USE_MINI_GMP
0053 #include <gmp.h>
0054 #else
0055 #include <mini-gmp.h>
0056 #endif
0057 
0058 /* Avoid some problems with macro expansion if the user defines macros
0059    with the same name as keywords. By convention, identifiers and macro
0060    names starting with mpfr_ are reserved by MPFR. */
0061 typedef void            mpfr_void;
0062 typedef int             mpfr_int;
0063 typedef unsigned int    mpfr_uint;
0064 typedef long            mpfr_long;
0065 typedef unsigned long   mpfr_ulong;
0066 typedef size_t          mpfr_size_t;
0067 
0068 /* Global (possibly TLS) flags. Might also be used in an mpfr_t in the
0069    future (there would be room as mpfr_sign_t just needs 1 byte).
0070    TODO: The tests currently assume that the flags fits in an unsigned int;
0071    this should be cleaned up, e.g. by defining a function that outputs the
0072    flags as a string or by using the flags_out function (from tests/tests.c
0073    directly). */
0074 typedef unsigned int    mpfr_flags_t;
0075 
0076 /* Flags macros (in the public API) */
0077 #define MPFR_FLAGS_UNDERFLOW 1
0078 #define MPFR_FLAGS_OVERFLOW 2
0079 #define MPFR_FLAGS_NAN 4
0080 #define MPFR_FLAGS_INEXACT 8
0081 #define MPFR_FLAGS_ERANGE 16
0082 #define MPFR_FLAGS_DIVBY0 32
0083 #define MPFR_FLAGS_ALL (MPFR_FLAGS_UNDERFLOW | \
0084                         MPFR_FLAGS_OVERFLOW  | \
0085                         MPFR_FLAGS_NAN       | \
0086                         MPFR_FLAGS_INEXACT   | \
0087                         MPFR_FLAGS_ERANGE    | \
0088                         MPFR_FLAGS_DIVBY0)
0089 
0090 /* Definition of rounding modes (DON'T USE MPFR_RNDNA!).
0091    Warning! Changing the contents of this enum should be seen as an
0092    interface change since the old and the new types are not compatible
0093    (the integer type compatible with the enumerated type can even change,
0094    see ISO C99, 6.7.2.2#4), and in Makefile.am, AGE should be set to 0.
0095 
0096    MPFR_RNDU must appear just before MPFR_RNDD (see
0097    MPFR_IS_RNDUTEST_OR_RNDDNOTTEST in mpfr-impl.h).
0098 
0099    If you change the order of the rounding modes, please update the routines
0100    in texceptions.c which assume 0=RNDN, 1=RNDZ, 2=RNDU, 3=RNDD, 4=RNDA.
0101 */
0102 typedef enum {
0103   MPFR_RNDN=0,  /* round to nearest, with ties to even */
0104   MPFR_RNDZ,    /* round toward zero */
0105   MPFR_RNDU,    /* round toward +Inf */
0106   MPFR_RNDD,    /* round toward -Inf */
0107   MPFR_RNDA,    /* round away from zero */
0108   MPFR_RNDF,    /* faithful rounding */
0109   MPFR_RNDNA=-1 /* round to nearest, with ties away from zero (mpfr_round) */
0110 } mpfr_rnd_t;
0111 
0112 /* kept for compatibility with MPFR 2.4.x and before */
0113 #define GMP_RNDN MPFR_RNDN
0114 #define GMP_RNDZ MPFR_RNDZ
0115 #define GMP_RNDU MPFR_RNDU
0116 #define GMP_RNDD MPFR_RNDD
0117 
0118 /* The _MPFR_PREC_FORMAT and _MPFR_EXP_FORMAT values are automatically
0119    defined below. You MUST NOT force a value (this will break the ABI),
0120    possibly except for a very particular use, in which case you also need
0121    to rebuild the MPFR library with the chosen values; do not install this
0122    rebuilt library in a path that is searched by default, otherwise this
0123    will break applications that are dynamically linked with MPFR.
0124 
0125    Using non-default values is not guaranteed to work.
0126 
0127    Note: With the following default choices for _MPFR_PREC_FORMAT and
0128    _MPFR_EXP_FORMAT, mpfr_exp_t will be the same as [mp_exp_t] (at least
0129    up to GMP 6). */
0130 
0131 /* Define precision: 1 (short), 2 (int) or 3 (long).
0132    DON'T FORCE A VALUE (see above). */
0133 #ifndef _MPFR_PREC_FORMAT
0134 # if __GMP_MP_SIZE_T_INT
0135 #  define _MPFR_PREC_FORMAT 2
0136 # else
0137 #  define _MPFR_PREC_FORMAT 3
0138 # endif
0139 #endif
0140 
0141 /* Define exponent: 1 (short), 2 (int), 3 (long) or 4 (intmax_t).
0142    DON'T FORCE A VALUE (see above). */
0143 #ifndef _MPFR_EXP_FORMAT
0144 # define _MPFR_EXP_FORMAT _MPFR_PREC_FORMAT
0145 #endif
0146 
0147 #if _MPFR_PREC_FORMAT > _MPFR_EXP_FORMAT
0148 # error "mpfr_prec_t must not be larger than mpfr_exp_t"
0149 #endif
0150 
0151 /* Let's make mpfr_prec_t signed in order to avoid problems due to the
0152    usual arithmetic conversions when mixing mpfr_prec_t and mpfr_exp_t
0153    in an expression (for error analysis) if casts are forgotten.
0154    Note: mpfr_prec_t is currently limited to "long". This means that
0155    under MS Windows, the precisions are limited to about 2^31; however,
0156    these are already huge precisions, probably sufficient in practice
0157    on this platform. */
0158 #if   _MPFR_PREC_FORMAT == 1
0159 typedef short mpfr_prec_t;
0160 typedef unsigned short mpfr_uprec_t;
0161 #elif _MPFR_PREC_FORMAT == 2
0162 typedef int   mpfr_prec_t;
0163 typedef unsigned int   mpfr_uprec_t;
0164 #elif _MPFR_PREC_FORMAT == 3
0165 typedef long  mpfr_prec_t;
0166 typedef unsigned long  mpfr_uprec_t;
0167 #else
0168 # error "Invalid MPFR Prec format"
0169 #endif
0170 
0171 /* Definition of precision limits without needing <limits.h> */
0172 /* Note: The casts allows the expression to yield the wanted behavior
0173    for _MPFR_PREC_FORMAT == 1 (due to integer promotion rules). We
0174    also make sure that MPFR_PREC_MIN and MPFR_PREC_MAX have a signed
0175    integer type. The "- 256" allows more security, avoiding some
0176    integer overflows in extreme cases; ideally it should be useless. */
0177 #define MPFR_PREC_MIN 1
0178 #define MPFR_PREC_MAX ((mpfr_prec_t) ((((mpfr_uprec_t) -1) >> 1) - 256))
0179 
0180 /* Definition of sign */
0181 typedef int          mpfr_sign_t;
0182 
0183 /* Definition of the exponent. _MPFR_EXP_FORMAT must be large enough
0184    so that mpfr_exp_t has at least 32 bits. */
0185 #if   _MPFR_EXP_FORMAT == 1
0186 typedef short mpfr_exp_t;
0187 typedef unsigned short mpfr_uexp_t;
0188 #elif _MPFR_EXP_FORMAT == 2
0189 typedef int mpfr_exp_t;
0190 typedef unsigned int mpfr_uexp_t;
0191 #elif _MPFR_EXP_FORMAT == 3
0192 typedef long mpfr_exp_t;
0193 typedef unsigned long mpfr_uexp_t;
0194 #elif _MPFR_EXP_FORMAT == 4
0195 /* Note: in this case, intmax_t and uintmax_t must be defined before
0196    the inclusion of mpfr.h (we do not include <stdint.h> here due to
0197    potential issues with non-ISO implementations, on which there are
0198    alternative ways to define these types).
0199    In all known implementations, intmax_t has exactly 64 bits and is
0200    equivalent to long long when defined, but when long has 64 bits,
0201    it may be defined as long by <stdint.h> for better portability
0202    with old compilers, thus offers more flexibility than long long.
0203    This may change in the future.
0204    This _MPFR_EXP_FORMAT value is currently not supported since the
0205    MPFR code assumes that mpfr_exp_t fits in a long. Some examples
0206    of problematic code can be obtained with:
0207      grep -E 'mpfr_cmp_[su]i *\(.*__gmpfr_em' *.c
0208 */
0209 typedef intmax_t mpfr_exp_t;
0210 typedef uintmax_t mpfr_uexp_t;
0211 #else
0212 # error "Invalid MPFR Exp format"
0213 #endif
0214 
0215 /* Definition of the standard exponent limits */
0216 #define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((mpfr_ulong) 1 << 30) - 1))
0217 #define MPFR_EMIN_DEFAULT (-(MPFR_EMAX_DEFAULT))
0218 
0219 /* DON'T USE THIS! (For MPFR-public macros only, see below.)
0220    The mpfr_sgn macro uses the fact that __MPFR_EXP_NAN and __MPFR_EXP_ZERO
0221    are the smallest values. For a n-bit type, EXP_MAX is 2^(n-1)-1,
0222    EXP_ZERO is 1-2^(n-1), EXP_NAN is 2-2^(n-1), EXP_INF is 3-2^(n-1).
0223    This may change in the future. MPFR code should not be based on these
0224    representations (but if this is absolutely needed, protect the code
0225    with a static assertion). */
0226 #define __MPFR_EXP_MAX ((mpfr_exp_t) (((mpfr_uexp_t) -1) >> 1))
0227 #define __MPFR_EXP_NAN  (1 - __MPFR_EXP_MAX)
0228 #define __MPFR_EXP_ZERO (0 - __MPFR_EXP_MAX)
0229 #define __MPFR_EXP_INF  (2 - __MPFR_EXP_MAX)
0230 
0231 /* Definition of the main structure */
0232 typedef struct {
0233   mpfr_prec_t  _mpfr_prec;
0234   mpfr_sign_t  _mpfr_sign;
0235   mpfr_exp_t   _mpfr_exp;
0236   mp_limb_t   *_mpfr_d;
0237 } __mpfr_struct;
0238 
0239 /* Compatibility with previous types of MPFR */
0240 #ifndef mp_rnd_t
0241 # define mp_rnd_t  mpfr_rnd_t
0242 #endif
0243 #ifndef mp_prec_t
0244 # define mp_prec_t mpfr_prec_t
0245 #endif
0246 
0247 /*
0248    The represented number is
0249       _sign*(_d[k-1]/B+_d[k-2]/B^2+...+_d[0]/B^k)*2^_exp
0250    where k=ceil(_mp_prec/GMP_NUMB_BITS) and B=2^GMP_NUMB_BITS.
0251 
0252    For the msb (most significant bit) normalized representation, we must have
0253       _d[k-1]>=B/2, unless the number is singular.
0254 
0255    We must also have the last k*GMP_NUMB_BITS-_prec bits set to zero.
0256 */
0257 
0258 typedef __mpfr_struct mpfr_t[1];
0259 typedef __mpfr_struct *mpfr_ptr;
0260 typedef const __mpfr_struct *mpfr_srcptr;
0261 
0262 /* For those who need a direct and fast access to the sign field.
0263    However, it is not in the API, thus use it at your own risk: it
0264    might not be supported, or change name, in further versions!
0265    Unfortunately, it must be defined here (instead of MPFR's internal
0266    header file mpfr-impl.h) because it is used by some macros below.
0267 */
0268 #define MPFR_SIGN(x) ((x)->_mpfr_sign)
0269 
0270 /* Custom interface */
0271 typedef enum {
0272   MPFR_NAN_KIND     = 0,
0273   MPFR_INF_KIND     = 1,
0274   MPFR_ZERO_KIND    = 2,
0275   MPFR_REGULAR_KIND = 3
0276 } mpfr_kind_t;
0277 
0278 /* Free cache policy */
0279 typedef enum {
0280   MPFR_FREE_LOCAL_CACHE  = 1,  /* 1 << 0 */
0281   MPFR_FREE_GLOBAL_CACHE = 2   /* 1 << 1 */
0282 } mpfr_free_cache_t;
0283 
0284 /* GMP defines:
0285     + size_t:                Standard size_t
0286     + __GMP_NOTHROW          For C++: can't throw .
0287     + __GMP_EXTERN_INLINE    Attribute for inline function.
0288     + __GMP_DECLSPEC_EXPORT  compiling to go into a DLL
0289     + __GMP_DECLSPEC_IMPORT  compiling to go into a application
0290 */
0291 /* Extra MPFR defines */
0292 #define __MPFR_SENTINEL_ATTR
0293 #if defined (__GNUC__)
0294 # if __GNUC__ >= 4
0295 #  undef __MPFR_SENTINEL_ATTR
0296 #  define __MPFR_SENTINEL_ATTR __attribute__ ((__sentinel__))
0297 # endif
0298 #endif
0299 
0300 /* If the user hasn't requested his/her preference
0301    and if the intention of support by the compiler is C99
0302    and if the compiler is known to support the C99 feature
0303    then we can auto-detect the C99 support as OK.
0304    __GNUC__ is used to detect GNU-C, ICC & CLANG compilers.
0305    Currently we need only variadic macros, and they are present
0306    since GCC >= 3. We don't test library version since we don't
0307    use any feature present in the library too (except intmax_t,
0308    but they use another detection).*/
0309 #ifndef MPFR_USE_C99_FEATURE
0310 # if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
0311 #  if defined (__GNUC__)
0312 #   if __GNUC__ >= 3
0313 #    define MPFR_USE_C99_FEATURE 1
0314 #   endif
0315 #  endif
0316 # endif
0317 # ifndef MPFR_USE_C99_FEATURE
0318 #  define MPFR_USE_C99_FEATURE 0
0319 # endif
0320 #endif
0321 
0322 /* Support for WINDOWS Dll:
0323    Check if we are inside a MPFR build, and if so export the functions.
0324    Otherwise does the same thing as GMP */
0325 #if defined(__MPFR_WITHIN_MPFR) && __GMP_LIBGMP_DLL
0326 # define __MPFR_DECLSPEC __GMP_DECLSPEC_EXPORT
0327 #else
0328 # ifndef __GMP_DECLSPEC
0329 #  define __GMP_DECLSPEC
0330 # endif
0331 # define __MPFR_DECLSPEC __GMP_DECLSPEC
0332 #endif
0333 
0334 /* Use MPFR_DEPRECATED to mark MPFR functions, types or variables as
0335    deprecated. Code inspired by Apache Subversion's svn_types.h file.
0336    For compatibility with MSVC, MPFR_DEPRECATED must be put before
0337    __MPFR_DECLSPEC (not at the end of the function declaration as
0338    documented in the GCC manual); GCC does not seem to care.
0339    Moreover, in order to avoid a warning when testing such functions,
0340    do something like:
0341      +------------------------------------------
0342      |#ifndef _MPFR_NO_DEPRECATED_funcname
0343      |MPFR_DEPRECATED
0344      |#endif
0345      |__MPFR_DECLSPEC int mpfr_funcname (...);
0346      +------------------------------------------
0347    and in the corresponding test program:
0348      +------------------------------------------
0349      |#define _MPFR_NO_DEPRECATED_funcname
0350      |#include "mpfr-test.h"
0351      +------------------------------------------
0352 */
0353 #if defined(__GNUC__) && \
0354   (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
0355 # define MPFR_DEPRECATED __attribute__ ((__deprecated__))
0356 #elif defined(_MSC_VER) && _MSC_VER >= 1300
0357 # define MPFR_DEPRECATED __declspec(deprecated)
0358 #else
0359 # define MPFR_DEPRECATED
0360 #endif
0361 /* TODO: Also define MPFR_EXPERIMENTAL for experimental functions?
0362    See SVN_EXPERIMENTAL in Subversion 1.9+ as an example:
0363    __attribute__((__warning__("..."))) can be used with GCC 4.3.1+ but
0364    not __llvm__, and __declspec(deprecated("...")) can be used with
0365    MSC as above. */
0366 
0367 /* ICC up to 19.1.3.304 at least declares itself as interoperable with
0368    GCC 4.9, but does not support the returns_nonnull attribute, thus
0369    outputs warning #1292. This minor issue has been reported in 2019-04:
0370    https://community.intel.com/t5/Intel-C-Compiler/Missing-support-for-returns-nonnull-attribute/td-p/1183013 */
0371 #if defined(__GNUC__) && \
0372   (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9))
0373 # define MPFR_RETURNS_NONNULL __attribute__ ((__returns_nonnull__))
0374 #else
0375 # define MPFR_RETURNS_NONNULL
0376 #endif
0377 
0378 /* Note: In order to be declared, some functions need a specific
0379    system header to be included *before* "mpfr.h". If the user
0380    forgets to include the header, the MPFR function prototype in
0381    the user object file is not correct. To avoid wrong results,
0382    we raise a linker error in that case by changing their internal
0383    name in the library (prefixed by __gmpfr instead of mpfr). See
0384    the lines of the form "#define mpfr_xxx __gmpfr_xxx" below. */
0385 
0386 #if defined (__cplusplus)
0387 extern "C" {
0388 #endif
0389 
0390 __MPFR_DECLSPEC MPFR_RETURNS_NONNULL const char * mpfr_get_version (void);
0391 __MPFR_DECLSPEC MPFR_RETURNS_NONNULL const char * mpfr_get_patches (void);
0392 
0393 __MPFR_DECLSPEC int mpfr_buildopt_tls_p          (void);
0394 __MPFR_DECLSPEC int mpfr_buildopt_float128_p     (void);
0395 __MPFR_DECLSPEC int mpfr_buildopt_decimal_p      (void);
0396 __MPFR_DECLSPEC int mpfr_buildopt_gmpinternals_p (void);
0397 __MPFR_DECLSPEC int mpfr_buildopt_sharedcache_p  (void);
0398 __MPFR_DECLSPEC MPFR_RETURNS_NONNULL const char *
0399   mpfr_buildopt_tune_case (void);
0400 
0401 __MPFR_DECLSPEC mpfr_exp_t mpfr_get_emin     (void);
0402 __MPFR_DECLSPEC int        mpfr_set_emin     (mpfr_exp_t);
0403 __MPFR_DECLSPEC mpfr_exp_t mpfr_get_emin_min (void);
0404 __MPFR_DECLSPEC mpfr_exp_t mpfr_get_emin_max (void);
0405 __MPFR_DECLSPEC mpfr_exp_t mpfr_get_emax     (void);
0406 __MPFR_DECLSPEC int        mpfr_set_emax     (mpfr_exp_t);
0407 __MPFR_DECLSPEC mpfr_exp_t mpfr_get_emax_min (void);
0408 __MPFR_DECLSPEC mpfr_exp_t mpfr_get_emax_max (void);
0409 
0410 __MPFR_DECLSPEC void mpfr_set_default_rounding_mode (mpfr_rnd_t);
0411 __MPFR_DECLSPEC mpfr_rnd_t mpfr_get_default_rounding_mode (void);
0412 __MPFR_DECLSPEC const char * mpfr_print_rnd_mode (mpfr_rnd_t);
0413 
0414 __MPFR_DECLSPEC void mpfr_clear_flags (void);
0415 __MPFR_DECLSPEC void mpfr_clear_underflow (void);
0416 __MPFR_DECLSPEC void mpfr_clear_overflow (void);
0417 __MPFR_DECLSPEC void mpfr_clear_divby0 (void);
0418 __MPFR_DECLSPEC void mpfr_clear_nanflag (void);
0419 __MPFR_DECLSPEC void mpfr_clear_inexflag (void);
0420 __MPFR_DECLSPEC void mpfr_clear_erangeflag (void);
0421 
0422 __MPFR_DECLSPEC void mpfr_set_underflow (void);
0423 __MPFR_DECLSPEC void mpfr_set_overflow (void);
0424 __MPFR_DECLSPEC void mpfr_set_divby0 (void);
0425 __MPFR_DECLSPEC void mpfr_set_nanflag (void);
0426 __MPFR_DECLSPEC void mpfr_set_inexflag (void);
0427 __MPFR_DECLSPEC void mpfr_set_erangeflag (void);
0428 
0429 __MPFR_DECLSPEC int mpfr_underflow_p (void);
0430 __MPFR_DECLSPEC int mpfr_overflow_p (void);
0431 __MPFR_DECLSPEC int mpfr_divby0_p (void);
0432 __MPFR_DECLSPEC int mpfr_nanflag_p (void);
0433 __MPFR_DECLSPEC int mpfr_inexflag_p (void);
0434 __MPFR_DECLSPEC int mpfr_erangeflag_p (void);
0435 
0436 __MPFR_DECLSPEC void mpfr_flags_clear (mpfr_flags_t);
0437 __MPFR_DECLSPEC void mpfr_flags_set (mpfr_flags_t);
0438 __MPFR_DECLSPEC mpfr_flags_t mpfr_flags_test (mpfr_flags_t);
0439 __MPFR_DECLSPEC mpfr_flags_t mpfr_flags_save (void);
0440 __MPFR_DECLSPEC void mpfr_flags_restore (mpfr_flags_t,
0441                                          mpfr_flags_t);
0442 
0443 __MPFR_DECLSPEC int mpfr_check_range (mpfr_ptr, int, mpfr_rnd_t);
0444 
0445 __MPFR_DECLSPEC void mpfr_init2 (mpfr_ptr, mpfr_prec_t);
0446 __MPFR_DECLSPEC void mpfr_init (mpfr_ptr);
0447 __MPFR_DECLSPEC void mpfr_clear (mpfr_ptr);
0448 
0449 __MPFR_DECLSPEC void
0450   mpfr_inits2 (mpfr_prec_t, mpfr_ptr, ...) __MPFR_SENTINEL_ATTR;
0451 __MPFR_DECLSPEC void
0452   mpfr_inits (mpfr_ptr, ...) __MPFR_SENTINEL_ATTR;
0453 __MPFR_DECLSPEC void
0454   mpfr_clears (mpfr_ptr, ...) __MPFR_SENTINEL_ATTR;
0455 
0456 __MPFR_DECLSPEC int mpfr_prec_round (mpfr_ptr, mpfr_prec_t, mpfr_rnd_t);
0457 __MPFR_DECLSPEC int mpfr_can_round (mpfr_srcptr, mpfr_exp_t, mpfr_rnd_t,
0458                                     mpfr_rnd_t, mpfr_prec_t);
0459 __MPFR_DECLSPEC mpfr_prec_t mpfr_min_prec (mpfr_srcptr);
0460 
0461 __MPFR_DECLSPEC mpfr_exp_t mpfr_get_exp (mpfr_srcptr);
0462 __MPFR_DECLSPEC int mpfr_set_exp (mpfr_ptr, mpfr_exp_t);
0463 __MPFR_DECLSPEC mpfr_prec_t mpfr_get_prec (mpfr_srcptr);
0464 __MPFR_DECLSPEC void mpfr_set_prec (mpfr_ptr, mpfr_prec_t);
0465 __MPFR_DECLSPEC void mpfr_set_prec_raw (mpfr_ptr, mpfr_prec_t);
0466 __MPFR_DECLSPEC void mpfr_set_default_prec (mpfr_prec_t);
0467 __MPFR_DECLSPEC mpfr_prec_t mpfr_get_default_prec (void);
0468 
0469 __MPFR_DECLSPEC int mpfr_set_d (mpfr_ptr, double, mpfr_rnd_t);
0470 __MPFR_DECLSPEC int mpfr_set_flt (mpfr_ptr, float, mpfr_rnd_t);
0471 #ifdef MPFR_WANT_DECIMAL_FLOATS
0472 /* _Decimal64 is not defined in C++,
0473    cf https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51364 */
0474 __MPFR_DECLSPEC int mpfr_set_decimal64 (mpfr_ptr, _Decimal64, mpfr_rnd_t);
0475 __MPFR_DECLSPEC int mpfr_set_decimal128 (mpfr_ptr, _Decimal128, mpfr_rnd_t);
0476 #endif
0477 __MPFR_DECLSPEC int mpfr_set_ld (mpfr_ptr, long double, mpfr_rnd_t);
0478 #ifdef MPFR_WANT_FLOAT128
0479 /* The user is free to define mpfr_float128 as another equivalent type,
0480    such as __float128 if this one is supported by the current compiler
0481    but _Float128 isn't. */
0482 # ifndef mpfr_float128
0483 #  define mpfr_float128 _Float128
0484 # endif
0485 __MPFR_DECLSPEC int mpfr_set_float128 (mpfr_ptr, mpfr_float128, mpfr_rnd_t);
0486 __MPFR_DECLSPEC mpfr_float128 mpfr_get_float128 (mpfr_srcptr, mpfr_rnd_t);
0487 #endif
0488 __MPFR_DECLSPEC int mpfr_set_z (mpfr_ptr, mpz_srcptr, mpfr_rnd_t);
0489 __MPFR_DECLSPEC int mpfr_set_z_2exp (mpfr_ptr, mpz_srcptr, mpfr_exp_t,
0490                                      mpfr_rnd_t);
0491 __MPFR_DECLSPEC void mpfr_set_nan (mpfr_ptr);
0492 __MPFR_DECLSPEC void mpfr_set_inf (mpfr_ptr, int);
0493 __MPFR_DECLSPEC void mpfr_set_zero (mpfr_ptr, int);
0494 
0495 #ifndef MPFR_USE_MINI_GMP
0496   /* mini-gmp does not provide mpf_t, we disable the following functions */
0497 __MPFR_DECLSPEC int mpfr_set_f (mpfr_ptr, mpf_srcptr, mpfr_rnd_t);
0498 __MPFR_DECLSPEC int mpfr_cmp_f (mpfr_srcptr, mpf_srcptr);
0499 __MPFR_DECLSPEC int mpfr_get_f (mpf_ptr, mpfr_srcptr, mpfr_rnd_t);
0500 #endif
0501 __MPFR_DECLSPEC int mpfr_set_si (mpfr_ptr, long, mpfr_rnd_t);
0502 __MPFR_DECLSPEC int mpfr_set_ui (mpfr_ptr, unsigned long, mpfr_rnd_t);
0503 __MPFR_DECLSPEC int mpfr_set_si_2exp (mpfr_ptr, long, mpfr_exp_t, mpfr_rnd_t);
0504 __MPFR_DECLSPEC int mpfr_set_ui_2exp (mpfr_ptr, unsigned long, mpfr_exp_t,
0505                                       mpfr_rnd_t);
0506 #ifndef MPFR_USE_MINI_GMP
0507   /* mini-gmp does not provide mpq_t, we disable the following functions */
0508 __MPFR_DECLSPEC int mpfr_set_q (mpfr_ptr, mpq_srcptr, mpfr_rnd_t);
0509 __MPFR_DECLSPEC int mpfr_mul_q (mpfr_ptr, mpfr_srcptr, mpq_srcptr, mpfr_rnd_t);
0510 __MPFR_DECLSPEC int mpfr_div_q (mpfr_ptr, mpfr_srcptr, mpq_srcptr, mpfr_rnd_t);
0511 __MPFR_DECLSPEC int mpfr_add_q (mpfr_ptr, mpfr_srcptr, mpq_srcptr, mpfr_rnd_t);
0512 __MPFR_DECLSPEC int mpfr_sub_q (mpfr_ptr, mpfr_srcptr, mpq_srcptr, mpfr_rnd_t);
0513 __MPFR_DECLSPEC int mpfr_cmp_q (mpfr_srcptr, mpq_srcptr);
0514 __MPFR_DECLSPEC void mpfr_get_q (mpq_ptr q, mpfr_srcptr f);
0515 #endif
0516 __MPFR_DECLSPEC int mpfr_set_str (mpfr_ptr, const char *, int, mpfr_rnd_t);
0517 __MPFR_DECLSPEC int mpfr_init_set_str (mpfr_ptr, const char *, int,
0518                                        mpfr_rnd_t);
0519 __MPFR_DECLSPEC int mpfr_set4 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t, int);
0520 __MPFR_DECLSPEC int mpfr_abs (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0521 __MPFR_DECLSPEC int mpfr_set (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0522 __MPFR_DECLSPEC int mpfr_neg (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0523 __MPFR_DECLSPEC int mpfr_signbit (mpfr_srcptr);
0524 __MPFR_DECLSPEC int mpfr_setsign (mpfr_ptr, mpfr_srcptr, int, mpfr_rnd_t);
0525 __MPFR_DECLSPEC int mpfr_copysign (mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
0526                                    mpfr_rnd_t);
0527 
0528 __MPFR_DECLSPEC mpfr_exp_t mpfr_get_z_2exp (mpz_ptr, mpfr_srcptr);
0529 __MPFR_DECLSPEC float mpfr_get_flt (mpfr_srcptr, mpfr_rnd_t);
0530 __MPFR_DECLSPEC double mpfr_get_d (mpfr_srcptr, mpfr_rnd_t);
0531 #ifdef MPFR_WANT_DECIMAL_FLOATS
0532 __MPFR_DECLSPEC _Decimal64 mpfr_get_decimal64 (mpfr_srcptr, mpfr_rnd_t);
0533 __MPFR_DECLSPEC _Decimal128 mpfr_get_decimal128 (mpfr_srcptr, mpfr_rnd_t);
0534 #endif
0535 __MPFR_DECLSPEC long double mpfr_get_ld (mpfr_srcptr, mpfr_rnd_t);
0536 __MPFR_DECLSPEC double mpfr_get_d1 (mpfr_srcptr);
0537 __MPFR_DECLSPEC double mpfr_get_d_2exp (long*, mpfr_srcptr, mpfr_rnd_t);
0538 __MPFR_DECLSPEC long double mpfr_get_ld_2exp (long*, mpfr_srcptr, mpfr_rnd_t);
0539 __MPFR_DECLSPEC int mpfr_frexp (mpfr_exp_t*, mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0540 __MPFR_DECLSPEC long mpfr_get_si (mpfr_srcptr, mpfr_rnd_t);
0541 __MPFR_DECLSPEC unsigned long mpfr_get_ui (mpfr_srcptr, mpfr_rnd_t);
0542 __MPFR_DECLSPEC size_t mpfr_get_str_ndigits (int, mpfr_prec_t);
0543 __MPFR_DECLSPEC char * mpfr_get_str (char*, mpfr_exp_t*, int, size_t,
0544                                      mpfr_srcptr, mpfr_rnd_t);
0545 __MPFR_DECLSPEC int mpfr_get_z (mpz_ptr z, mpfr_srcptr f, mpfr_rnd_t);
0546 
0547 __MPFR_DECLSPEC void mpfr_free_str (char *);
0548 
0549 __MPFR_DECLSPEC int mpfr_urandom (mpfr_ptr, gmp_randstate_t, mpfr_rnd_t);
0550 #ifndef _MPFR_NO_DEPRECATED_GRANDOM /* for the test of this function */
0551 MPFR_DEPRECATED
0552 #endif
0553 __MPFR_DECLSPEC int mpfr_grandom (mpfr_ptr, mpfr_ptr, gmp_randstate_t,
0554                                   mpfr_rnd_t);
0555 __MPFR_DECLSPEC int mpfr_nrandom (mpfr_ptr, gmp_randstate_t, mpfr_rnd_t);
0556 __MPFR_DECLSPEC int mpfr_erandom (mpfr_ptr, gmp_randstate_t, mpfr_rnd_t);
0557 __MPFR_DECLSPEC int mpfr_urandomb (mpfr_ptr, gmp_randstate_t);
0558 
0559 __MPFR_DECLSPEC void mpfr_nextabove (mpfr_ptr);
0560 __MPFR_DECLSPEC void mpfr_nextbelow (mpfr_ptr);
0561 __MPFR_DECLSPEC void mpfr_nexttoward (mpfr_ptr, mpfr_srcptr);
0562 
0563 #ifndef MPFR_USE_MINI_GMP
0564 __MPFR_DECLSPEC int mpfr_printf (const char*, ...);
0565 __MPFR_DECLSPEC int mpfr_asprintf (char**, const char*, ...);
0566 __MPFR_DECLSPEC int mpfr_sprintf (char*, const char*, ...);
0567 __MPFR_DECLSPEC int mpfr_snprintf (char*, size_t, const char*, ...);
0568 #endif
0569 
0570 __MPFR_DECLSPEC int mpfr_pow (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t);
0571 __MPFR_DECLSPEC int mpfr_powr (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t);
0572 __MPFR_DECLSPEC int mpfr_pow_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t);
0573 __MPFR_DECLSPEC int mpfr_compound_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t);
0574 __MPFR_DECLSPEC int mpfr_pow_ui (mpfr_ptr, mpfr_srcptr, unsigned long,
0575                                  mpfr_rnd_t);
0576 __MPFR_DECLSPEC int mpfr_ui_pow_ui (mpfr_ptr, unsigned long, unsigned long,
0577                                     mpfr_rnd_t);
0578 __MPFR_DECLSPEC int mpfr_ui_pow (mpfr_ptr, unsigned long, mpfr_srcptr,
0579                                  mpfr_rnd_t);
0580 __MPFR_DECLSPEC int mpfr_pow_z (mpfr_ptr, mpfr_srcptr, mpz_srcptr, mpfr_rnd_t);
0581 
0582 __MPFR_DECLSPEC int mpfr_sqrt (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0583 __MPFR_DECLSPEC int mpfr_sqrt_ui (mpfr_ptr, unsigned long, mpfr_rnd_t);
0584 __MPFR_DECLSPEC int mpfr_rec_sqrt (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0585 
0586 __MPFR_DECLSPEC int mpfr_add (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t);
0587 __MPFR_DECLSPEC int mpfr_sub (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t);
0588 __MPFR_DECLSPEC int mpfr_mul (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t);
0589 __MPFR_DECLSPEC int mpfr_div (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t);
0590 
0591 __MPFR_DECLSPEC int mpfr_add_ui (mpfr_ptr, mpfr_srcptr, unsigned long,
0592                                  mpfr_rnd_t);
0593 __MPFR_DECLSPEC int mpfr_sub_ui (mpfr_ptr, mpfr_srcptr, unsigned long,
0594                                  mpfr_rnd_t);
0595 __MPFR_DECLSPEC int mpfr_ui_sub (mpfr_ptr, unsigned long, mpfr_srcptr,
0596                                  mpfr_rnd_t);
0597 __MPFR_DECLSPEC int mpfr_mul_ui (mpfr_ptr, mpfr_srcptr, unsigned long,
0598                                  mpfr_rnd_t);
0599 __MPFR_DECLSPEC int mpfr_div_ui (mpfr_ptr, mpfr_srcptr, unsigned long,
0600                                  mpfr_rnd_t);
0601 __MPFR_DECLSPEC int mpfr_ui_div (mpfr_ptr, unsigned long, mpfr_srcptr,
0602                                  mpfr_rnd_t);
0603 
0604 __MPFR_DECLSPEC int mpfr_add_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t);
0605 __MPFR_DECLSPEC int mpfr_sub_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t);
0606 __MPFR_DECLSPEC int mpfr_si_sub (mpfr_ptr, long, mpfr_srcptr, mpfr_rnd_t);
0607 __MPFR_DECLSPEC int mpfr_mul_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t);
0608 __MPFR_DECLSPEC int mpfr_div_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t);
0609 __MPFR_DECLSPEC int mpfr_si_div (mpfr_ptr, long, mpfr_srcptr, mpfr_rnd_t);
0610 
0611 __MPFR_DECLSPEC int mpfr_add_d (mpfr_ptr, mpfr_srcptr, double, mpfr_rnd_t);
0612 __MPFR_DECLSPEC int mpfr_sub_d (mpfr_ptr, mpfr_srcptr, double, mpfr_rnd_t);
0613 __MPFR_DECLSPEC int mpfr_d_sub (mpfr_ptr, double, mpfr_srcptr, mpfr_rnd_t);
0614 __MPFR_DECLSPEC int mpfr_mul_d (mpfr_ptr, mpfr_srcptr, double, mpfr_rnd_t);
0615 __MPFR_DECLSPEC int mpfr_div_d (mpfr_ptr, mpfr_srcptr, double, mpfr_rnd_t);
0616 __MPFR_DECLSPEC int mpfr_d_div (mpfr_ptr, double, mpfr_srcptr, mpfr_rnd_t);
0617 
0618 __MPFR_DECLSPEC int mpfr_sqr (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0619 
0620 __MPFR_DECLSPEC int mpfr_const_pi (mpfr_ptr, mpfr_rnd_t);
0621 __MPFR_DECLSPEC int mpfr_const_log2 (mpfr_ptr, mpfr_rnd_t);
0622 __MPFR_DECLSPEC int mpfr_const_euler (mpfr_ptr, mpfr_rnd_t);
0623 __MPFR_DECLSPEC int mpfr_const_catalan (mpfr_ptr, mpfr_rnd_t);
0624 
0625 __MPFR_DECLSPEC int mpfr_agm (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t);
0626 
0627 __MPFR_DECLSPEC int mpfr_log (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0628 __MPFR_DECLSPEC int mpfr_log2 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0629 __MPFR_DECLSPEC int mpfr_log10 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0630 __MPFR_DECLSPEC int mpfr_log1p (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0631 __MPFR_DECLSPEC int mpfr_log2p1 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0632 __MPFR_DECLSPEC int mpfr_log10p1 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0633 __MPFR_DECLSPEC int mpfr_log_ui (mpfr_ptr, unsigned long, mpfr_rnd_t);
0634 
0635 __MPFR_DECLSPEC int mpfr_exp (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0636 __MPFR_DECLSPEC int mpfr_exp2 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0637 __MPFR_DECLSPEC int mpfr_exp10 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0638 __MPFR_DECLSPEC int mpfr_expm1 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0639 __MPFR_DECLSPEC int mpfr_exp2m1 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0640 __MPFR_DECLSPEC int mpfr_exp10m1 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0641 __MPFR_DECLSPEC int mpfr_eint (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0642 __MPFR_DECLSPEC int mpfr_li2 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0643 
0644 __MPFR_DECLSPEC int mpfr_cmp  (mpfr_srcptr, mpfr_srcptr);
0645 __MPFR_DECLSPEC int mpfr_cmp3 (mpfr_srcptr, mpfr_srcptr, int);
0646 __MPFR_DECLSPEC int mpfr_cmp_d (mpfr_srcptr, double);
0647 __MPFR_DECLSPEC int mpfr_cmp_ld (mpfr_srcptr, long double);
0648 __MPFR_DECLSPEC int mpfr_cmp_ui (mpfr_srcptr, unsigned long);
0649 __MPFR_DECLSPEC int mpfr_cmp_si (mpfr_srcptr, long);
0650 __MPFR_DECLSPEC int mpfr_cmp_ui_2exp (mpfr_srcptr, unsigned long, mpfr_exp_t);
0651 __MPFR_DECLSPEC int mpfr_cmp_si_2exp (mpfr_srcptr, long, mpfr_exp_t);
0652 __MPFR_DECLSPEC int mpfr_cmpabs (mpfr_srcptr, mpfr_srcptr);
0653 __MPFR_DECLSPEC int mpfr_cmpabs_ui (mpfr_srcptr, unsigned long);
0654 __MPFR_DECLSPEC void mpfr_reldiff (mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
0655                                    mpfr_rnd_t);
0656 __MPFR_DECLSPEC int mpfr_eq (mpfr_srcptr, mpfr_srcptr, unsigned long);
0657 __MPFR_DECLSPEC int mpfr_sgn (mpfr_srcptr);
0658 
0659 __MPFR_DECLSPEC int mpfr_mul_2exp (mpfr_ptr, mpfr_srcptr, unsigned long,
0660                                    mpfr_rnd_t);
0661 __MPFR_DECLSPEC int mpfr_div_2exp (mpfr_ptr, mpfr_srcptr, unsigned long,
0662                                    mpfr_rnd_t);
0663 __MPFR_DECLSPEC int mpfr_mul_2ui (mpfr_ptr, mpfr_srcptr, unsigned long,
0664                                   mpfr_rnd_t);
0665 __MPFR_DECLSPEC int mpfr_div_2ui (mpfr_ptr, mpfr_srcptr, unsigned long,
0666                                   mpfr_rnd_t);
0667 __MPFR_DECLSPEC int mpfr_mul_2si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t);
0668 __MPFR_DECLSPEC int mpfr_div_2si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t);
0669 
0670 __MPFR_DECLSPEC int mpfr_rint (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0671 __MPFR_DECLSPEC int mpfr_roundeven (mpfr_ptr, mpfr_srcptr);
0672 __MPFR_DECLSPEC int mpfr_round (mpfr_ptr, mpfr_srcptr);
0673 __MPFR_DECLSPEC int mpfr_trunc (mpfr_ptr, mpfr_srcptr);
0674 __MPFR_DECLSPEC int mpfr_ceil (mpfr_ptr, mpfr_srcptr);
0675 __MPFR_DECLSPEC int mpfr_floor (mpfr_ptr, mpfr_srcptr);
0676 __MPFR_DECLSPEC int mpfr_rint_roundeven (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0677 __MPFR_DECLSPEC int mpfr_rint_round (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0678 __MPFR_DECLSPEC int mpfr_rint_trunc (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0679 __MPFR_DECLSPEC int mpfr_rint_ceil (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0680 __MPFR_DECLSPEC int mpfr_rint_floor (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0681 __MPFR_DECLSPEC int mpfr_frac (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0682 __MPFR_DECLSPEC int mpfr_modf (mpfr_ptr, mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0683 __MPFR_DECLSPEC int mpfr_remquo (mpfr_ptr, long*, mpfr_srcptr, mpfr_srcptr,
0684                                  mpfr_rnd_t);
0685 __MPFR_DECLSPEC int mpfr_remainder (mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
0686                                     mpfr_rnd_t);
0687 __MPFR_DECLSPEC int mpfr_fmod (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t);
0688 __MPFR_DECLSPEC int mpfr_fmod_ui (mpfr_ptr, mpfr_srcptr, unsigned long,
0689                                   mpfr_rnd_t);
0690 __MPFR_DECLSPEC int mpfr_fmodquo (mpfr_ptr, long*, mpfr_srcptr, mpfr_srcptr,
0691                                   mpfr_rnd_t);
0692 
0693 __MPFR_DECLSPEC int mpfr_fits_ulong_p (mpfr_srcptr, mpfr_rnd_t);
0694 __MPFR_DECLSPEC int mpfr_fits_slong_p (mpfr_srcptr, mpfr_rnd_t);
0695 __MPFR_DECLSPEC int mpfr_fits_uint_p (mpfr_srcptr, mpfr_rnd_t);
0696 __MPFR_DECLSPEC int mpfr_fits_sint_p (mpfr_srcptr, mpfr_rnd_t);
0697 __MPFR_DECLSPEC int mpfr_fits_ushort_p (mpfr_srcptr, mpfr_rnd_t);
0698 __MPFR_DECLSPEC int mpfr_fits_sshort_p (mpfr_srcptr, mpfr_rnd_t);
0699 __MPFR_DECLSPEC int mpfr_fits_uintmax_p (mpfr_srcptr, mpfr_rnd_t);
0700 __MPFR_DECLSPEC int mpfr_fits_intmax_p (mpfr_srcptr, mpfr_rnd_t);
0701 
0702 __MPFR_DECLSPEC void mpfr_extract (mpz_ptr, mpfr_srcptr, unsigned int);
0703 __MPFR_DECLSPEC void mpfr_swap (mpfr_ptr, mpfr_ptr);
0704 __MPFR_DECLSPEC void mpfr_dump (mpfr_srcptr);
0705 
0706 __MPFR_DECLSPEC int mpfr_nan_p (mpfr_srcptr);
0707 __MPFR_DECLSPEC int mpfr_inf_p (mpfr_srcptr);
0708 __MPFR_DECLSPEC int mpfr_number_p (mpfr_srcptr);
0709 __MPFR_DECLSPEC int mpfr_integer_p (mpfr_srcptr);
0710 __MPFR_DECLSPEC int mpfr_zero_p (mpfr_srcptr);
0711 __MPFR_DECLSPEC int mpfr_regular_p (mpfr_srcptr);
0712 
0713 __MPFR_DECLSPEC int mpfr_greater_p (mpfr_srcptr, mpfr_srcptr);
0714 __MPFR_DECLSPEC int mpfr_greaterequal_p (mpfr_srcptr, mpfr_srcptr);
0715 __MPFR_DECLSPEC int mpfr_less_p (mpfr_srcptr, mpfr_srcptr);
0716 __MPFR_DECLSPEC int mpfr_lessequal_p (mpfr_srcptr, mpfr_srcptr);
0717 __MPFR_DECLSPEC int mpfr_lessgreater_p (mpfr_srcptr, mpfr_srcptr);
0718 __MPFR_DECLSPEC int mpfr_equal_p (mpfr_srcptr, mpfr_srcptr);
0719 __MPFR_DECLSPEC int mpfr_unordered_p (mpfr_srcptr, mpfr_srcptr);
0720 
0721 __MPFR_DECLSPEC int mpfr_atanh (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0722 __MPFR_DECLSPEC int mpfr_acosh (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0723 __MPFR_DECLSPEC int mpfr_asinh (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0724 __MPFR_DECLSPEC int mpfr_cosh (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0725 __MPFR_DECLSPEC int mpfr_sinh (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0726 __MPFR_DECLSPEC int mpfr_tanh (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0727 __MPFR_DECLSPEC int mpfr_sinh_cosh (mpfr_ptr, mpfr_ptr, mpfr_srcptr,
0728                                     mpfr_rnd_t);
0729 
0730 __MPFR_DECLSPEC int mpfr_sech (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0731 __MPFR_DECLSPEC int mpfr_csch (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0732 __MPFR_DECLSPEC int mpfr_coth (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0733 
0734 __MPFR_DECLSPEC int mpfr_acos (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0735 __MPFR_DECLSPEC int mpfr_asin (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0736 __MPFR_DECLSPEC int mpfr_atan (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0737 __MPFR_DECLSPEC int mpfr_sin (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0738 __MPFR_DECLSPEC int mpfr_sin_cos (mpfr_ptr, mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0739 __MPFR_DECLSPEC int mpfr_cos (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0740 __MPFR_DECLSPEC int mpfr_tan (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0741 __MPFR_DECLSPEC int mpfr_atan2 (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t);
0742 __MPFR_DECLSPEC int mpfr_sec (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0743 __MPFR_DECLSPEC int mpfr_csc (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0744 __MPFR_DECLSPEC int mpfr_cot (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0745 
0746 __MPFR_DECLSPEC int mpfr_sinu (mpfr_ptr, mpfr_srcptr, unsigned long, mpfr_rnd_t);
0747 __MPFR_DECLSPEC int mpfr_cosu (mpfr_ptr, mpfr_srcptr, unsigned long, mpfr_rnd_t);
0748 __MPFR_DECLSPEC int mpfr_tanu (mpfr_ptr, mpfr_srcptr, unsigned long, mpfr_rnd_t);
0749 __MPFR_DECLSPEC int mpfr_acosu (mpfr_ptr, mpfr_srcptr, unsigned long, mpfr_rnd_t);
0750 __MPFR_DECLSPEC int mpfr_asinu (mpfr_ptr, mpfr_srcptr, unsigned long, mpfr_rnd_t);
0751 __MPFR_DECLSPEC int mpfr_atanu (mpfr_ptr, mpfr_srcptr, unsigned long, mpfr_rnd_t);
0752 __MPFR_DECLSPEC int mpfr_atan2u (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, unsigned long, mpfr_rnd_t);
0753 __MPFR_DECLSPEC int mpfr_acospi (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0754 __MPFR_DECLSPEC int mpfr_asinpi (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0755 __MPFR_DECLSPEC int mpfr_atanpi (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0756 __MPFR_DECLSPEC int mpfr_atan2pi (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t);
0757 
0758 __MPFR_DECLSPEC int mpfr_sinpi (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0759 __MPFR_DECLSPEC int mpfr_cospi (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0760 __MPFR_DECLSPEC int mpfr_tanpi (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0761 
0762 __MPFR_DECLSPEC int mpfr_hypot (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t);
0763 __MPFR_DECLSPEC int mpfr_erf (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0764 __MPFR_DECLSPEC int mpfr_erfc (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0765 __MPFR_DECLSPEC int mpfr_cbrt (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0766 #ifndef _MPFR_NO_DEPRECATED_ROOT /* for the test of this function */
0767 MPFR_DEPRECATED
0768 #endif
0769 __MPFR_DECLSPEC int mpfr_root (mpfr_ptr, mpfr_srcptr, unsigned long,
0770                                mpfr_rnd_t);
0771 __MPFR_DECLSPEC int mpfr_rootn_ui (mpfr_ptr, mpfr_srcptr, unsigned long,
0772                                    mpfr_rnd_t);
0773 __MPFR_DECLSPEC int mpfr_rootn_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t);
0774 __MPFR_DECLSPEC int mpfr_gamma (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0775 __MPFR_DECLSPEC int mpfr_gamma_inc (mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
0776                                     mpfr_rnd_t);
0777 __MPFR_DECLSPEC int mpfr_beta (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t);
0778 __MPFR_DECLSPEC int mpfr_lngamma (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0779 __MPFR_DECLSPEC int mpfr_lgamma (mpfr_ptr, int *, mpfr_srcptr, mpfr_rnd_t);
0780 __MPFR_DECLSPEC int mpfr_digamma (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0781 __MPFR_DECLSPEC int mpfr_zeta (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0782 __MPFR_DECLSPEC int mpfr_zeta_ui (mpfr_ptr, unsigned long, mpfr_rnd_t);
0783 __MPFR_DECLSPEC int mpfr_fac_ui (mpfr_ptr, unsigned long, mpfr_rnd_t);
0784 __MPFR_DECLSPEC int mpfr_j0 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0785 __MPFR_DECLSPEC int mpfr_j1 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0786 __MPFR_DECLSPEC int mpfr_jn (mpfr_ptr, long, mpfr_srcptr, mpfr_rnd_t);
0787 __MPFR_DECLSPEC int mpfr_y0 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0788 __MPFR_DECLSPEC int mpfr_y1 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0789 __MPFR_DECLSPEC int mpfr_yn (mpfr_ptr, long, mpfr_srcptr, mpfr_rnd_t);
0790 
0791 __MPFR_DECLSPEC int mpfr_ai (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
0792 
0793 __MPFR_DECLSPEC int mpfr_min (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t);
0794 __MPFR_DECLSPEC int mpfr_max (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t);
0795 __MPFR_DECLSPEC int mpfr_dim (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t);
0796 
0797 __MPFR_DECLSPEC int mpfr_mul_z (mpfr_ptr, mpfr_srcptr, mpz_srcptr, mpfr_rnd_t);
0798 __MPFR_DECLSPEC int mpfr_div_z (mpfr_ptr, mpfr_srcptr, mpz_srcptr, mpfr_rnd_t);
0799 __MPFR_DECLSPEC int mpfr_add_z (mpfr_ptr, mpfr_srcptr, mpz_srcptr, mpfr_rnd_t);
0800 __MPFR_DECLSPEC int mpfr_sub_z (mpfr_ptr, mpfr_srcptr, mpz_srcptr, mpfr_rnd_t);
0801 __MPFR_DECLSPEC int mpfr_z_sub (mpfr_ptr, mpz_srcptr, mpfr_srcptr, mpfr_rnd_t);
0802 __MPFR_DECLSPEC int mpfr_cmp_z (mpfr_srcptr, mpz_srcptr);
0803 
0804 __MPFR_DECLSPEC int mpfr_fma (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr,
0805                               mpfr_rnd_t);
0806 __MPFR_DECLSPEC int mpfr_fms (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr,
0807                               mpfr_rnd_t);
0808 __MPFR_DECLSPEC int mpfr_fmma (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr,
0809                                mpfr_srcptr, mpfr_rnd_t);
0810 __MPFR_DECLSPEC int mpfr_fmms (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr,
0811                                mpfr_srcptr, mpfr_rnd_t);
0812 __MPFR_DECLSPEC int mpfr_sum (mpfr_ptr, const mpfr_ptr *, unsigned long,
0813                               mpfr_rnd_t);
0814 __MPFR_DECLSPEC int mpfr_dot (mpfr_ptr, const mpfr_ptr *, const mpfr_ptr *,
0815                               unsigned long, mpfr_rnd_t);
0816 
0817 __MPFR_DECLSPEC void mpfr_free_cache (void);
0818 __MPFR_DECLSPEC void mpfr_free_cache2 (mpfr_free_cache_t);
0819 __MPFR_DECLSPEC void mpfr_free_pool (void);
0820 __MPFR_DECLSPEC int mpfr_mp_memory_cleanup (void);
0821 
0822 __MPFR_DECLSPEC int mpfr_subnormalize (mpfr_ptr, int, mpfr_rnd_t);
0823 
0824 __MPFR_DECLSPEC int mpfr_strtofr (mpfr_ptr, const char *, char **, int,
0825                                   mpfr_rnd_t);
0826 
0827 __MPFR_DECLSPEC void mpfr_round_nearest_away_begin (mpfr_ptr);
0828 __MPFR_DECLSPEC int mpfr_round_nearest_away_end (mpfr_ptr, int);
0829 
0830 __MPFR_DECLSPEC size_t mpfr_custom_get_size (mpfr_prec_t);
0831 __MPFR_DECLSPEC void mpfr_custom_init (void *, mpfr_prec_t);
0832 __MPFR_DECLSPEC MPFR_RETURNS_NONNULL void *
0833   mpfr_custom_get_significand (mpfr_srcptr);
0834 __MPFR_DECLSPEC mpfr_exp_t mpfr_custom_get_exp (mpfr_srcptr);
0835 __MPFR_DECLSPEC void mpfr_custom_move (mpfr_ptr, void *);
0836 __MPFR_DECLSPEC void mpfr_custom_init_set (mpfr_ptr, int, mpfr_exp_t,
0837                                            mpfr_prec_t, void *);
0838 __MPFR_DECLSPEC int mpfr_custom_get_kind (mpfr_srcptr);
0839 
0840 __MPFR_DECLSPEC int mpfr_total_order_p (mpfr_srcptr, mpfr_srcptr);
0841 
0842 #if defined (__cplusplus)
0843 }
0844 #endif
0845 
0846 /* Define MPFR_USE_EXTENSION to avoid "gcc -pedantic" warnings. */
0847 #ifndef MPFR_EXTENSION
0848 # if defined(MPFR_USE_EXTENSION)
0849 #  define MPFR_EXTENSION __extension__
0850 # else
0851 #  define MPFR_EXTENSION
0852 # endif
0853 #endif
0854 
0855 /* Warning! This macro doesn't work with K&R C (e.g., compare the "gcc -E"
0856    output with and without -traditional) and shouldn't be used internally.
0857    For public use only, but see the MPFR manual. */
0858 #define MPFR_DECL_INIT(_x, _p)                                        \
0859   MPFR_EXTENSION mp_limb_t __gmpfr_local_tab_##_x[((_p)-1)/GMP_NUMB_BITS+1]; \
0860   MPFR_EXTENSION mpfr_t _x = {{(_p),1,__MPFR_EXP_NAN,__gmpfr_local_tab_##_x}}
0861 
0862 #if MPFR_USE_C99_FEATURE
0863 /* C99 & C11 version: functions with multiple inputs supported */
0864 #define mpfr_round_nearest_away(func, rop, ...)                         \
0865   (mpfr_round_nearest_away_begin(rop),                                  \
0866    mpfr_round_nearest_away_end((rop), func((rop), __VA_ARGS__, MPFR_RNDN)))
0867 #else
0868 /* C90 version: function with one input supported */
0869 #define mpfr_round_nearest_away(func, rop, op)                          \
0870   (mpfr_round_nearest_away_begin(rop),                                  \
0871    mpfr_round_nearest_away_end((rop), func((rop), (op), MPFR_RNDN)))
0872 #endif
0873 
0874 /* Fast access macros to replace function interface.
0875    If the user doesn't want to use the macro interface, let him make happy
0876    even if it produces faster and smaller code. */
0877 #ifndef MPFR_USE_NO_MACRO
0878 
0879 /* In the implementation of these macros, we need to make sure that the
0880    arguments are evaluated one time exactly and that type conversion is
0881    done as it would be with a function. Tests should be added to ensure
0882    that. */
0883 
0884 /* Prevent x from being used as an lvalue.
0885    Thanks to Wojtek Lerch and Tim Rentsch for the idea. */
0886 #define MPFR_VALUE_OF(x)  (0 ? (x) : (x))
0887 
0888 /* The following macro converts the argument to mpfr_srcptr, as in type
0889    conversion for function parameters. But it will detect disallowed
0890    implicit conversions, e.g. when the argument has an integer type. */
0891 #define MPFR_SRCPTR(x) ((mpfr_srcptr) (0 ? (x) : (mpfr_srcptr) (x)))
0892 #define MPFR_GET_SIGN(_x) MPFR_VALUE_OF(MPFR_SIGN(MPFR_SRCPTR(_x)))
0893 
0894 #define mpfr_nan_p(_x)      (MPFR_SRCPTR(_x)->_mpfr_exp == __MPFR_EXP_NAN)
0895 #define mpfr_inf_p(_x)      (MPFR_SRCPTR(_x)->_mpfr_exp == __MPFR_EXP_INF)
0896 #define mpfr_zero_p(_x)     (MPFR_SRCPTR(_x)->_mpfr_exp == __MPFR_EXP_ZERO)
0897 #define mpfr_regular_p(_x)  (MPFR_SRCPTR(_x)->_mpfr_exp >  __MPFR_EXP_INF)
0898 
0899 /* mpfr_sgn is documented as a macro, thus the following code is fine.
0900    But it would be safer to regard it as a function in some future
0901    MPFR version. */
0902 #define mpfr_sgn(_x)                                               \
0903   ((_x)->_mpfr_exp < __MPFR_EXP_INF ?                              \
0904    (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (mpfr_void) 0), 0 : \
0905    MPFR_SIGN (_x))
0906 
0907 #define mpfr_get_prec(_x) MPFR_VALUE_OF(MPFR_SRCPTR(_x)->_mpfr_prec)
0908 #define mpfr_get_exp(_x)  MPFR_VALUE_OF(MPFR_SRCPTR(_x)->_mpfr_exp)
0909 /* Note: Defining mpfr_get_exp() as a macro has the effect to disable
0910    the check that the argument is a pure FP number (done in the function);
0911    this increases the risk of undetected error and makes debugging more
0912    complex. Is it really worth in practice? (Potential FIXME) */
0913 
0914 #define mpfr_round(a,b) mpfr_rint((a), (b), MPFR_RNDNA)
0915 #define mpfr_trunc(a,b) mpfr_rint((a), (b), MPFR_RNDZ)
0916 #define mpfr_ceil(a,b)  mpfr_rint((a), (b), MPFR_RNDU)
0917 #define mpfr_floor(a,b) mpfr_rint((a), (b), MPFR_RNDD)
0918 
0919 #define mpfr_cmp_ui(b,i) mpfr_cmp_ui_2exp((b),(i),0)
0920 #define mpfr_cmp_si(b,i) mpfr_cmp_si_2exp((b),(i),0)
0921 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
0922 #define mpfr_set(a,b,r)                         \
0923   __extension__ ({                              \
0924       mpfr_srcptr _p = (b);                     \
0925       mpfr_set4(a,_p,r,MPFR_SIGN(_p));          \
0926     })
0927 #endif
0928 #define mpfr_abs(a,b,r)  mpfr_set4(a,b,r,1)
0929 #define mpfr_copysign(a,b,c,r) mpfr_set4(a,b,r,MPFR_GET_SIGN(c))
0930 #define mpfr_setsign(a,b,s,r) mpfr_set4(a,b,r,(s) ? -1 : 1)
0931 #define mpfr_signbit(x)  (MPFR_GET_SIGN(x) < 0)
0932 #define mpfr_cmp(b, c)   mpfr_cmp3(b, c, 1)
0933 #define mpfr_mul_2exp(y,x,n,r) mpfr_mul_2ui((y),(x),(n),(r))
0934 #define mpfr_div_2exp(y,x,n,r) mpfr_div_2ui((y),(x),(n),(r))
0935 
0936 
0937 /* When using GCC or ICC, optimize certain common comparisons and affectations.
0938    Added casts to improve robustness in case of undefined behavior and
0939    compiler extensions based on UB (in particular -fwrapv). MPFR doesn't
0940    use such extensions, but these macros will be used by 3rd-party code,
0941    where such extensions may be required.
0942    Moreover casts to unsigned long have been added to avoid warnings in
0943    programs that use MPFR and are compiled with -Wconversion; such casts
0944    are OK since if X is a constant expression, then (unsigned long) X is
0945    also a constant expression, so that the optimizations still work. The
0946    warnings are probably related to the following two bugs:
0947      https://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210
0948      https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470 (possibly a variant)
0949    and the casts could be removed once these bugs are fixed.
0950    Casts shouldn't be used on the generic calls (to the ..._2exp functions),
0951    where implicit conversions are performed. Indeed, having at least one
0952    implicit conversion in the macro allows the compiler to emit diagnostics
0953    when normally expected, for instance in the following call:
0954      mpfr_set_ui (x, "foo", MPFR_RNDN);
0955    If this is not possible (for future macros), one of the tricks described on
0956    https://groups.google.com/g/comp.std.c/c/9Jl0giNILfg/m/e6-evyS9KukJ?pli=1
0957    could be used. */
0958 #if defined (__GNUC__) && !defined(__cplusplus)
0959 #if (__GNUC__ >= 2)
0960 
0961 #undef mpfr_cmp_ui
0962 /* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0.
0963    But warning! mpfr_sgn is specified as a macro in the API, thus the macro
0964    mustn't be used if side effects are possible, like here. */
0965 #define mpfr_cmp_ui(_f,_u)                                      \
0966   (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ?        \
0967    (mpfr_sgn) (_f) :                                            \
0968    mpfr_cmp_ui_2exp ((_f), (_u), 0))
0969 
0970 #undef mpfr_cmp_si
0971 #define mpfr_cmp_si(_f,_s)                                      \
0972   (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ?         \
0973    mpfr_cmp_ui ((_f), (mpfr_ulong) (mpfr_long) (_s)) :          \
0974    mpfr_cmp_si_2exp ((_f), (_s), 0))
0975 
0976 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
0977 #undef mpfr_set_ui
0978 #define mpfr_set_ui(_f,_u,_r)                                   \
0979   (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ?        \
0980    __extension__ ({                                             \
0981        mpfr_ptr _p = (_f);                                      \
0982        _p->_mpfr_sign = 1;                                      \
0983        _p->_mpfr_exp = __MPFR_EXP_ZERO;                         \
0984        (mpfr_void) (_r); 0; }) :                                \
0985    mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
0986 #endif
0987 
0988 #undef mpfr_set_si
0989 #define mpfr_set_si(_f,_s,_r)                                   \
0990   (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ?         \
0991    mpfr_set_ui ((_f), (mpfr_ulong) (mpfr_long) (_s), (_r)) :    \
0992    mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
0993 
0994 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
0995 /* If the source is a constant number that is a power of 2,
0996    optimize the call */
0997 #undef mpfr_mul_ui
0998 #define mpfr_mul_ui(_f, _g, _u,_r)                              \
0999   (__builtin_constant_p (_u) && (mpfr_ulong) (_u) >= 1 &&       \
1000    ((mpfr_ulong) (_u) & ((mpfr_ulong) (_u) - 1)) == 0 ?         \
1001    mpfr_mul_2si((_f), (_g), __builtin_ctzl (_u), (_r)) :        \
1002    mpfr_mul_ui ((_f), (_g), (_u), (_r)))
1003 #undef mpfr_div_ui
1004 #define mpfr_div_ui(_f, _g, _u,_r)                              \
1005   (__builtin_constant_p (_u) && (mpfr_ulong) (_u) >= 1 &&       \
1006    ((mpfr_ulong) (_u) & ((mpfr_ulong) (_u) - 1)) == 0 ?         \
1007    mpfr_mul_2si((_f), (_g), - __builtin_ctzl (_u), (_r)) :      \
1008    mpfr_div_ui ((_f), (_g), (_u), (_r)))
1009 #endif
1010 
1011 /* If the source is a constant number that is non-negative,
1012    optimize the call */
1013 #undef mpfr_mul_si
1014 #define mpfr_mul_si(_f, _g, _s,_r)                                      \
1015   (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ?                 \
1016    mpfr_mul_ui ((_f), (_g), (mpfr_ulong) (mpfr_long) (_s), (_r)) :      \
1017    mpfr_mul_si ((_f), (_g), (_s), (_r)))
1018 #undef mpfr_div_si
1019 #define mpfr_div_si(_f, _g, _s,_r)                                      \
1020   (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ?                 \
1021    mpfr_div_ui ((_f), (_g), (mpfr_ulong) (mpfr_long) (_s), (_r)) :      \
1022    mpfr_div_si ((_f), (_g), (_s), (_r)))
1023 
1024 #endif
1025 #endif
1026 
1027 /* Macro versions of the custom interface for fast access. */
1028 
1029 /* The internal cast to mpfr_size_t will silent a warning with
1030    GCC's -Wsign-conversion that could occur with user code, as
1031    sizeof is of type size_t, which is unsigned. */
1032 #define mpfr_custom_get_size(p)                                             \
1033   ((mpfr_size_t)                                                            \
1034    ((mpfr_size_t) (((mpfr_prec_t)(p) + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS)  \
1035     * sizeof (mp_limb_t)))
1036 
1037 #define mpfr_custom_init(m,p) ((void) (m), (void) (p))
1038 
1039 #define mpfr_custom_get_significand(x) \
1040   ((mpfr_void *) MPFR_VALUE_OF(MPFR_SRCPTR(x)->_mpfr_d))
1041 
1042 #define mpfr_custom_get_exp(x) MPFR_VALUE_OF(MPFR_SRCPTR(x)->_mpfr_exp)
1043 
1044 #define mpfr_custom_move(x,m) (((mpfr_ptr) (x))->_mpfr_d = (mp_limb_t *) (m))
1045 
1046 /* Note: the following macro is not usable in contexts where an expression
1047    is expected. */
1048 #define mpfr_custom_init_set(x,k,e,p,m) do {                   \
1049   mpfr_ptr _x = (x);                                           \
1050   mpfr_exp_t _e = (e);                                         \
1051   mpfr_kind_t _t;                                              \
1052   mpfr_int _s, _k;                                             \
1053   _k = (k);                                                    \
1054   if (_k >= 0)  {                                              \
1055     _t = (mpfr_kind_t) _k;                                     \
1056     _s = 1;                                                    \
1057   } else {                                                     \
1058     _t = (mpfr_kind_t) - _k;                                   \
1059     _s = -1;                                                   \
1060   }                                                            \
1061   _e = _t == MPFR_REGULAR_KIND ? _e :                          \
1062     _t == MPFR_NAN_KIND ? __MPFR_EXP_NAN :                     \
1063     _t == MPFR_INF_KIND ? __MPFR_EXP_INF : __MPFR_EXP_ZERO;    \
1064   _x->_mpfr_prec = (p);                                        \
1065   _x->_mpfr_sign = _s;                                         \
1066   _x->_mpfr_exp  = _e;                                         \
1067   _x->_mpfr_d    = (mp_limb_t*) (m);                           \
1068  } while (0)
1069 
1070 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
1071 #define mpfr_custom_get_kind(x)                                         \
1072   __extension__ ({                                                      \
1073     mpfr_srcptr _x = (x);                                               \
1074     _x->_mpfr_exp >  __MPFR_EXP_INF ?                                   \
1075       (mpfr_int) MPFR_REGULAR_KIND * MPFR_SIGN (_x)                     \
1076       : _x->_mpfr_exp == __MPFR_EXP_INF ?                               \
1077       (mpfr_int) MPFR_INF_KIND * MPFR_SIGN (_x)                         \
1078       : _x->_mpfr_exp == __MPFR_EXP_NAN ? (mpfr_int) MPFR_NAN_KIND      \
1079       : (mpfr_int) MPFR_ZERO_KIND * MPFR_SIGN (_x);                     \
1080   })
1081 #else
1082 #define mpfr_custom_get_kind(x) ((mpfr_custom_get_kind)(x))
1083 #endif
1084 
1085 /* End of the macro versions of the custom interface. */
1086 
1087 #endif /* MPFR_USE_NO_MACRO */
1088 
1089 /* These are defined to be macros */
1090 #define mpfr_init_set_si(x, i, rnd) \
1091  ( mpfr_init(x), mpfr_set_si((x), (i), (rnd)) )
1092 #define mpfr_init_set_ui(x, i, rnd) \
1093  ( mpfr_init(x), mpfr_set_ui((x), (i), (rnd)) )
1094 #define mpfr_init_set_d(x, d, rnd) \
1095  ( mpfr_init(x), mpfr_set_d((x), (d), (rnd)) )
1096 #define mpfr_init_set_ld(x, d, rnd) \
1097  ( mpfr_init(x), mpfr_set_ld((x), (d), (rnd)) )
1098 #define mpfr_init_set_z(x, i, rnd) \
1099  ( mpfr_init(x), mpfr_set_z((x), (i), (rnd)) )
1100 #ifndef MPFR_USE_MINI_GMP
1101 #define mpfr_init_set_q(x, i, rnd) \
1102  ( mpfr_init(x), mpfr_set_q((x), (i), (rnd)) )
1103 #define mpfr_init_set_f(x, y, rnd) \
1104  ( mpfr_init(x), mpfr_set_f((x), (y), (rnd)) )
1105 #endif
1106 #define mpfr_init_set(x, y, rnd) \
1107  ( mpfr_init(x), mpfr_set((x), (y), (rnd)) )
1108 
1109 /* Compatibility layer -- obsolete functions and macros */
1110 /* Note: it is not possible to output warnings, unless one defines
1111  * a deprecated variable and uses it, e.g.
1112  *   MPFR_DEPRECATED extern int mpfr_deprecated_feature;
1113  *   #define MPFR_EMIN_MIN ((void)mpfr_deprecated_feature,mpfr_get_emin_min())
1114  * (the cast to void avoids a warning because the left-hand operand
1115  * has no effect).
1116  */
1117 #define mpfr_cmp_abs mpfr_cmpabs
1118 #define mpfr_round_prec(x,r,p) mpfr_prec_round(x,p,r)
1119 #define __gmp_default_rounding_mode (mpfr_get_default_rounding_mode())
1120 #define __mpfr_emin (mpfr_get_emin())
1121 #define __mpfr_emax (mpfr_get_emax())
1122 #define __mpfr_default_fp_bit_precision (mpfr_get_default_fp_bit_precision())
1123 #define MPFR_EMIN_MIN mpfr_get_emin_min()
1124 #define MPFR_EMIN_MAX mpfr_get_emin_max()
1125 #define MPFR_EMAX_MIN mpfr_get_emax_min()
1126 #define MPFR_EMAX_MAX mpfr_get_emax_max()
1127 #define mpfr_version (mpfr_get_version())
1128 #ifndef mpz_set_fr
1129 # define mpz_set_fr mpfr_get_z
1130 #endif
1131 #define mpfr_get_z_exp mpfr_get_z_2exp
1132 #define mpfr_custom_get_mantissa mpfr_custom_get_significand
1133 
1134 #endif /* __MPFR_H */
1135 
1136 
1137 /* Check if <stdint.h> / <inttypes.h> is included or if the user
1138    explicitly wants intmax_t. Automatic detection is done by
1139    checking:
1140      - INTMAX_C and UINTMAX_C, but not if the compiler is a C++ one
1141        (as suggested by Patrick Pelissier) because the test does not
1142        work well in this case. See:
1143          https://sympa.inria.fr/sympa/arc/mpfr/2010-02/msg00025.html
1144        We do not check INTMAX_MAX and UINTMAX_MAX because under Solaris,
1145        these macros are always defined by <limits.h> (i.e. even when
1146        <stdint.h> and <inttypes.h> are not included).
1147      - _STDINT_H (defined by the glibc), _STDINT_H_ (defined under
1148        Mac OS X) and _STDINT (defined under MS Visual Studio), but
1149        this test may not work with all implementations.
1150        Portable software should not rely on these tests.
1151 */
1152 #if (defined (INTMAX_C) && defined (UINTMAX_C) && !defined(__cplusplus)) || \
1153   defined (MPFR_USE_INTMAX_T) || \
1154   defined (_STDINT_H) || defined (_STDINT_H_) || defined (_STDINT) || \
1155   defined (_SYS_STDINT_H_) /* needed for FreeBSD */
1156 # ifndef _MPFR_H_HAVE_INTMAX_T
1157 # define _MPFR_H_HAVE_INTMAX_T 1
1158 
1159 #if defined (__cplusplus)
1160 extern "C" {
1161 #endif
1162 
1163 #define mpfr_set_sj __gmpfr_set_sj
1164 #define mpfr_set_sj_2exp __gmpfr_set_sj_2exp
1165 #define mpfr_set_uj __gmpfr_set_uj
1166 #define mpfr_set_uj_2exp __gmpfr_set_uj_2exp
1167 #define mpfr_get_sj __gmpfr_mpfr_get_sj
1168 #define mpfr_get_uj __gmpfr_mpfr_get_uj
1169 #define mpfr_pow_uj __gmpfr_mpfr_pow_uj
1170 #define mpfr_pow_sj __gmpfr_mpfr_pow_sj
1171 __MPFR_DECLSPEC int mpfr_set_sj (mpfr_ptr, intmax_t, mpfr_rnd_t);
1172 __MPFR_DECLSPEC int mpfr_set_sj_2exp (mpfr_ptr, intmax_t, intmax_t,
1173                                       mpfr_rnd_t);
1174 __MPFR_DECLSPEC int mpfr_set_uj (mpfr_ptr, uintmax_t, mpfr_rnd_t);
1175 __MPFR_DECLSPEC int mpfr_set_uj_2exp (mpfr_ptr, uintmax_t, intmax_t,
1176                                       mpfr_rnd_t);
1177 __MPFR_DECLSPEC intmax_t mpfr_get_sj (mpfr_srcptr, mpfr_rnd_t);
1178 __MPFR_DECLSPEC uintmax_t mpfr_get_uj (mpfr_srcptr, mpfr_rnd_t);
1179 __MPFR_DECLSPEC int mpfr_pow_uj (mpfr_ptr, mpfr_srcptr, uintmax_t, mpfr_rnd_t);
1180 __MPFR_DECLSPEC int mpfr_pow_sj (mpfr_ptr, mpfr_srcptr, intmax_t, mpfr_rnd_t);
1181 /* define mpfr_pown (defined in IEEE 754-2019) as an alias for mpfr_pow_sj.
1182    It is currently implemented as a macro, but this may change in the future
1183    (it could be implemented as an inline function); in case of change, update
1184    the manual. */
1185 #define mpfr_pown mpfr_pow_sj
1186 
1187 #if defined (__cplusplus)
1188 }
1189 #endif
1190 
1191 # endif /* _MPFR_H_HAVE_INTMAX_T */
1192 #endif
1193 
1194 
1195 /* Check if <stdio.h> has been included or if the user wants FILE */
1196 #if defined (_GMP_H_HAVE_FILE) || defined (MPFR_USE_FILE)
1197 # ifndef _MPFR_H_HAVE_FILE
1198 # define _MPFR_H_HAVE_FILE 1
1199 
1200 #if defined (__cplusplus)
1201 extern "C" {
1202 #endif
1203 
1204 #define mpfr_inp_str __gmpfr_inp_str
1205 #define mpfr_out_str __gmpfr_out_str
1206 __MPFR_DECLSPEC size_t mpfr_inp_str (mpfr_ptr, FILE*, int, mpfr_rnd_t);
1207 __MPFR_DECLSPEC size_t mpfr_out_str (FILE*, int, size_t, mpfr_srcptr,
1208                                      mpfr_rnd_t);
1209 #ifndef MPFR_USE_MINI_GMP
1210 #define mpfr_fprintf __gmpfr_fprintf
1211 __MPFR_DECLSPEC int mpfr_fprintf (FILE*, const char*, ...);
1212 #endif
1213 #define mpfr_fpif_export __gmpfr_fpif_export
1214 #define mpfr_fpif_import __gmpfr_fpif_import
1215 __MPFR_DECLSPEC int mpfr_fpif_export (FILE*, mpfr_ptr);
1216 __MPFR_DECLSPEC int mpfr_fpif_import (mpfr_ptr, FILE*);
1217 
1218 #if defined (__cplusplus)
1219 }
1220 #endif
1221 
1222 # endif /* _MPFR_H_HAVE_FILE */
1223 #endif
1224 
1225 
1226 /* check if <stdarg.h> has been included or if the user wants va_list */
1227 #if defined (_GMP_H_HAVE_VA_LIST) || defined (MPFR_USE_VA_LIST)
1228 # ifndef _MPFR_H_HAVE_VA_LIST
1229 # define _MPFR_H_HAVE_VA_LIST 1
1230 
1231 #if defined (__cplusplus)
1232 extern "C" {
1233 #endif
1234 
1235 #define mpfr_vprintf __gmpfr_vprintf
1236 #define mpfr_vasprintf __gmpfr_vasprintf
1237 #define mpfr_vsprintf __gmpfr_vsprintf
1238 #define mpfr_vsnprintf __gmpfr_vsnprintf
1239 __MPFR_DECLSPEC int mpfr_vprintf (const char*, va_list);
1240 __MPFR_DECLSPEC int mpfr_vasprintf (char**, const char*, va_list);
1241 __MPFR_DECLSPEC int mpfr_vsprintf (char*, const char*, va_list);
1242 __MPFR_DECLSPEC int mpfr_vsnprintf (char*, size_t, const char*, va_list);
1243 
1244 #if defined (__cplusplus)
1245 }
1246 #endif
1247 
1248 # endif /* _MPFR_H_HAVE_VA_LIST */
1249 #endif
1250 
1251 
1252 /* check if <stdarg.h> has been included and if FILE is available
1253    (see above) */
1254 #if defined (_MPFR_H_HAVE_VA_LIST) && defined (_MPFR_H_HAVE_FILE)
1255 # ifndef _MPFR_H_HAVE_VA_LIST_FILE
1256 # define _MPFR_H_HAVE_VA_LIST_FILE 1
1257 
1258 #if defined (__cplusplus)
1259 extern "C" {
1260 #endif
1261 
1262 #define mpfr_vfprintf __gmpfr_vfprintf
1263 __MPFR_DECLSPEC int mpfr_vfprintf (FILE*, const char*, va_list);
1264 
1265 #if defined (__cplusplus)
1266 }
1267 #endif
1268 
1269 # endif /* _MPFR_H_HAVE_VA_LIST_FILE */
1270 #endif