Next: , Previous: (dir), Up: (dir)

GNU MPFR

This manual documents how to install and use the Multiple Precision Floating-Point Reliable Library, version 3.1.0.

Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in GNU Free Documentation License.



Next: , Previous: Top, Up: Top

MPFR Copying Conditions

The GNU MPFR library (or MPFR for short) is free; this means that everyone is free to use it and free to redistribute it on a free basis. The library is not in the public domain; it is copyrighted and there are restrictions on its distribution, but these restrictions are designed to permit everything that a good cooperating citizen would want to do. What is not allowed is to try to prevent others from further sharing any version of this library that they might get from you.

Specifically, we want to make sure that you have the right to give away copies of the library, that you receive source code or else can get it if you want it, that you can change this library or use pieces of it in new free programs, and that you know you can do these things.

To make sure that everyone has such rights, we have to forbid you to deprive anyone else of these rights. For example, if you distribute copies of the GNU MPFR library, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights.

Also, for our own protection, we must make certain that everyone finds out that there is no warranty for the GNU MPFR library. If it is modified by someone else and passed on, we want their recipients to know that what they have is not what we distributed, so that any problems introduced by others will not reflect on our reputation.

The precise conditions of the license for the GNU MPFR library are found in the Lesser General Public License that accompanies the source code. See the file COPYING.LESSER.


Next: , Previous: Copying, Up: Top

1 Introduction to MPFR

MPFR is a portable library written in C for arbitrary precision arithmetic on floating-point numbers. It is based on the GNU MP library. It aims to provide a class of floating-point numbers with precise semantics. The main characteristics of MPFR, which make it differ from most arbitrary precision floating-point software tools, are:

In particular, with a precision of 53 bits, MPFR is able to exactly reproduce all computations with double-precision machine floating-point numbers (e.g., double type in C, with a C implementation that rigorously follows Annex F of the ISO C99 standard and FP_CONTRACT pragma set to OFF) on the four arithmetic operations and the square root, except the default exponent range is much wider and subnormal numbers are not implemented (but can be emulated).

This version of MPFR is released under the GNU Lesser General Public License, version 3 or any later version. It is permitted to link MPFR to most non-free programs, as long as when distributing them the MPFR source code and a means to re-link with a modified MPFR library is provided.

1.1 How to Use This Manual

Everyone should read MPFR Basics. If you need to install the library yourself, you need to read Installing MPFR, too. To use the library you will need to refer to MPFR Interface.

The rest of the manual can be used for later reference, although it is probably a good idea to glance through it.


Next: , Previous: Introduction to MPFR, Up: Top

2 Installing MPFR

The MPFR library is already installed on some GNU/Linux distributions, but the development files necessary to the compilation such as mpfr.h are not always present. To check that MPFR is fully installed on your computer, you can check the presence of the file mpfr.h in /usr/include, or try to compile a small program having #include <mpfr.h> (since mpfr.h may be installed somewhere else). For instance, you can try to compile:

     #include <stdio.h>
     #include <mpfr.h>
     int main (void)
     {
       printf ("MPFR library: %-12s\nMPFR header:  %s (based on %d.%d.%d)\n",
               mpfr_get_version (), MPFR_VERSION_STRING, MPFR_VERSION_MAJOR,
               MPFR_VERSION_MINOR, MPFR_VERSION_PATCHLEVEL);
       return 0;
     }

with

     cc -o version version.c -lmpfr -lgmp

and if you get errors whose first line looks like

     version.c:2:19: error: mpfr.h: No such file or directory

then MPFR is probably not installed. Running this program will give you the MPFR version.

If MPFR is not installed on your computer, or if you want to install a different version, please follow the steps below.

2.1 How to Install

Here are the steps needed to install the library on Unix systems (more details are provided in the INSTALL file):

  1. To build MPFR, you first have to install GNU MP (version 4.1 or higher) on your computer. You need a C compiler, preferably GCC, but any reasonable compiler should work. And you need the standard Unix ‘make’ command, plus some other standard Unix utility commands.

    Then, in the MPFR build directory, type the following commands.

  2. ./configure

    This will prepare the build and setup the options according to your system. You can give options to specify the install directories (instead of the default /usr/local), threading support, and so on. See the INSTALL file and/or the output of ‘./configure --help’ for more information, in particular if you get error messages.

  3. make

    This will compile MPFR, and create a library archive file libmpfr.a. On most platforms, a dynamic library will be produced too.

  4. make check

    This will make sure MPFR was built correctly. If you get error messages, please report this to the MPFR mailing-list ‘mpfr@loria.fr’. (See Reporting Bugs, for information on what to include in useful bug reports.)

  5. make install

    This will copy the files mpfr.h and mpf2mpfr.h to the directory /usr/local/include, the library files (libmpfr.a and possibly others) to the directory /usr/local/lib, the file mpfr.info to the directory /usr/local/share/info, and some other documentation files to the directory /usr/local/share/doc/mpfr (or if you passed the ‘--prefix’ option to configure, using the prefix directory given as argument to ‘--prefix’ instead of /usr/local).

2.2 Other `make' Targets

There are some other useful make targets:

2.3 Build Problems

In case of problem, please read the INSTALL file carefully before reporting a bug, in particular section “In case of problem”. Some problems are due to bad configuration on the user side (not specific to MPFR). Problems are also mentioned in the FAQ http://www.mpfr.org/faq.html.

Please report problems to the MPFR mailing-list ‘mpfr@loria.fr’. See Reporting Bugs. Some bug fixes are available on the MPFR 3.1.0 web page http://www.mpfr.org/mpfr-3.1.0/.

2.4 Getting the Latest Version of MPFR

The latest version of MPFR is available from ftp://ftp.gnu.org/gnu/mpfr/ or http://www.mpfr.org/.


Next: , Previous: Installing MPFR, Up: Top

3 Reporting Bugs

If you think you have found a bug in the MPFR library, first have a look on the MPFR 3.1.0 web page http://www.mpfr.org/mpfr-3.1.0/ and the FAQ http://www.mpfr.org/faq.html: perhaps this bug is already known, in which case you may find there a workaround for it. You might also look in the archives of the MPFR mailing-list: https://sympa.inria.fr/sympa/arc/mpfr. Otherwise, please investigate and report it. We have made this library available to you, and it is not to ask too much from you, to ask you to report the bugs that you find.

There are a few things you should think about when you put your bug report together.

You have to send us a test case that makes it possible for us to reproduce the bug, i.e., a small self-content program, using no other library than MPFR. Include instructions on how to run the test case.

You also have to explain what is wrong; if you get a crash, or if the results you get are incorrect and in that case, in what way.

Please include compiler version information in your bug report. This can be extracted using ‘cc -V’ on some machines, or, if you're using GCC, ‘gcc -v’. Also, include the output from ‘uname -a’ and the MPFR version (the GMP version may be useful too). If you get a failure while running ‘make’ or ‘make check’, please include the ‘config.log’ file in your bug report.

If your bug report is good, we will do our best to help you to get a corrected version of the library; if the bug report is poor, we will not do anything about it (aside of chiding you to send better bug reports).

Send your bug report to the MPFR mailing-list ‘mpfr@loria.fr’.

If you think something in this manual is unclear, or downright incorrect, or if the language needs to be improved, please send a note to the same address.


Next: , Previous: Reporting Bugs, Up: Top

4 MPFR Basics


Next: , Previous: MPFR Basics, Up: MPFR Basics

4.1 Headers and Libraries

All declarations needed to use MPFR are collected in the include file mpfr.h. It is designed to work with both C and C++ compilers. You should include that file in any program using the MPFR library:

     #include <mpfr.h>

Note however that prototypes for MPFR functions with FILE * parameters are provided only if <stdio.h> is included too (before mpfr.h):

     #include <stdio.h>
     #include <mpfr.h>

Likewise <stdarg.h> (or <varargs.h>) is required for prototypes with va_list parameters, such as mpfr_vprintf.

And for any functions using intmax_t, you must include <stdint.h> or <inttypes.h> before mpfr.h, to allow mpfr.h to define prototypes for these functions. Moreover, users of C++ compilers under some platforms may need to define MPFR_USE_INTMAX_T (and should do it for portability) before mpfr.h has been included; of course, it is possible to do that on the command line, e.g., with -DMPFR_USE_INTMAX_T.

Note: If mpfr.h and/or gmp.h (used by mpfr.h) are included several times (possibly from another header file), <stdio.h> and/or <stdarg.h> (or <varargs.h>) should be included before the first inclusion of mpfr.h or gmp.h. Alternatively, you can define MPFR_USE_FILE (for MPFR I/O functions) and/or MPFR_USE_VA_LIST (for MPFR functions with va_list parameters) anywhere before the last inclusion of mpfr.h. As a consequence, if your file is a public header that includes mpfr.h, you need to use the latter method.

When calling a MPFR macro, it is not allowed to have previously defined a macro with the same name as some keywords (currently do, while and sizeof).

You can avoid the use of MPFR macros encapsulating functions by defining the ‘MPFR_USE_NO_MACRO’ macro before mpfr.h is included. In general this should not be necessary, but this can be useful when debugging user code: with some macros, the compiler may emit spurious warnings with some warning options, and macros can prevent some prototype checking.

All programs using MPFR must link against both libmpfr and libgmp libraries. On a typical Unix-like system this can be done with ‘-lmpfr -lgmp’ (in that order), for example:

     gcc myprogram.c -lmpfr -lgmp

MPFR is built using Libtool and an application can use that to link if desired, see GNU Libtool.

If MPFR has been installed to a non-standard location, then it may be necessary to set up environment variables such as ‘C_INCLUDE_PATH’ and ‘LIBRARY_PATH’, or use ‘-I’ and ‘-L’ compiler options, in order to point to the right directories. For a shared library, it may also be necessary to set up some sort of run-time library path (e.g., ‘LD_LIBRARY_PATH’) on some systems. Please read the INSTALL file for additional information.


Next: , Previous: Headers and Libraries, Up: MPFR Basics

4.2 Nomenclature and Types

A floating-point number, or float for short, is an arbitrary precision significand (also called mantissa) with a limited precision exponent. The C data type for such objects is mpfr_t (internally defined as a one-element array of a structure, and mpfr_ptr is the C data type representing a pointer to this structure). A floating-point number can have three special values: Not-a-Number (NaN) or plus or minus Infinity. NaN represents an uninitialized object, the result of an invalid operation (like 0 divided by 0), or a value that cannot be determined (like +Infinity minus +Infinity). Moreover, like in the IEEE 754 standard, zero is signed, i.e., there are both +0 and −0; the behavior is the same as in the IEEE 754 standard and it is generalized to the other functions supported by MPFR. Unless documented otherwise, the sign bit of a NaN is unspecified.

The precision is the number of bits used to represent the significand of a floating-point number; the corresponding C data type is mpfr_prec_t. The precision can be any integer between MPFR_PREC_MIN and MPFR_PREC_MAX. In the current implementation, MPFR_PREC_MIN is equal to 2.

Warning! MPFR needs to increase the precision internally, in order to provide accurate results (and in particular, correct rounding). Do not attempt to set the precision to any value near MPFR_PREC_MAX, otherwise MPFR will abort due to an assertion failure. Moreover, you may reach some memory limit on your platform, in which case the program may abort, crash or have undefined behavior (depending on your C implementation).

The rounding mode specifies the way to round the result of a floating-point operation, in case the exact result can not be represented exactly in the destination significand; the corresponding C data type is mpfr_rnd_t.


Next: , Previous: Nomenclature and Types, Up: MPFR Basics

4.3 MPFR Variable Conventions

Before you can assign to an MPFR variable, you need to initialize it by calling one of the special initialization functions. When you're done with a variable, you need to clear it out, using one of the functions for that purpose. A variable should only be initialized once, or at least cleared out between each initialization. After a variable has been initialized, it may be assigned to any number of times. For efficiency reasons, avoid to initialize and clear out a variable in loops. Instead, initialize it before entering the loop, and clear it out after the loop has exited. You do not need to be concerned about allocating additional space for MPFR variables, since any variable has a significand of fixed size. Hence unless you change its precision, or clear and reinitialize it, a floating-point variable will have the same allocated space during all its life.

As a general rule, all MPFR functions expect output arguments before input arguments. This notation is based on an analogy with the assignment operator. MPFR allows you to use the same variable for both input and output in the same expression. For example, the main function for floating-point multiplication, mpfr_mul, can be used like this: mpfr_mul (x, x, x, rnd). This computes the square of x with rounding mode rnd and puts the result back in x.


Next: , Previous: MPFR Variable Conventions, Up: MPFR Basics

4.4 Rounding Modes

The following five rounding modes are supported:

The ‘round to nearest’ mode works as in the IEEE 754 standard: in case the number to be rounded lies exactly in the middle of two representable numbers, it is rounded to the one with the least significant bit set to zero. For example, the number 2.5, which is represented by (10.1) in binary, is rounded to (10.0)=2 with a precision of two bits, and not to (11.0)=3. This rule avoids the drift phenomenon mentioned by Knuth in volume 2 of The Art of Computer Programming (Section 4.2.2).

Most MPFR functions take as first argument the destination variable, as second and following arguments the input variables, as last argument a rounding mode, and have a return value of type int, called the ternary value. The value stored in the destination variable is correctly rounded, i.e., MPFR behaves as if it computed the result with an infinite precision, then rounded it to the precision of this variable. The input variables are regarded as exact (in particular, their precision does not affect the result).

As a consequence, in case of a non-zero real rounded result, the error on the result is less or equal to 1/2 ulp (unit in the last place) of that result in the rounding to nearest mode, and less than 1 ulp of that result in the directed rounding modes (a ulp is the weight of the least significant represented bit of the result after rounding).

Unless documented otherwise, functions returning an int return a ternary value. If the ternary value is zero, it means that the value stored in the destination variable is the exact result of the corresponding mathematical function. If the ternary value is positive (resp. negative), it means the value stored in the destination variable is greater (resp. lower) than the exact result. For example with the MPFR_RNDU rounding mode, the ternary value is usually positive, except when the result is exact, in which case it is zero. In the case of an infinite result, it is considered as inexact when it was obtained by overflow, and exact otherwise. A NaN result (Not-a-Number) always corresponds to an exact return value. The opposite of a returned ternary value is guaranteed to be representable in an int.

Unless documented otherwise, functions returning as result the value 1 (or any other value specified in this manual) for special cases (like acos(0)) yield an overflow or an underflow if that value is not representable in the current exponent range.


Next: , Previous: Rounding Modes, Up: MPFR Basics

4.5 Floating-Point Values on Special Numbers

This section specifies the floating-point values (of type mpfr_t) returned by MPFR functions (where by “returned” we mean here the modified value of the destination object, which should not be mixed with the ternary return value of type int of those functions). For functions returning several values (like mpfr_sin_cos), the rules apply to each result separately.

Functions can have one or several input arguments. An input point is a mapping from these input arguments to the set of the MPFR numbers. When none of its components are NaN, an input point can also be seen as a tuple in the extended real numbers (the set of the real numbers with both infinities).

When the input point is in the domain of the mathematical function, the result is rounded as described in Section “Rounding Modes” (but see below for the specification of the sign of an exact zero). Otherwise the general rules from this section apply unless stated otherwise in the description of the MPFR function (MPFR Interface).

When the input point is not in the domain of the mathematical function but is in its closure in the extended real numbers and the function can be extended by continuity, the result is the obtained limit. Examples: mpfr_hypot on (+Inf,0) gives +Inf. But mpfr_pow cannot be defined on (1,+Inf) using this rule, as one can find sequences (x_n,y_n) such that x_n goes to 1, y_n goes to +Inf and x_n to the y_n goes to any positive value when n goes to the infinity.

When the input point is in the closure of the domain of the mathematical function and an input argument is +0 (resp. −0), one considers the limit when the corresponding argument approaches 0 from above (resp. below). If the limit is not defined (e.g., mpfr_log on −0), the behavior is specified in the description of the MPFR function.

When the result is equal to 0, its sign is determined by considering the limit as if the input point were not in the domain: If one approaches 0 from above (resp. below), the result is +0 (resp. −0); for example, mpfr_sin on +0 gives +0. In the other cases, the sign is specified in the description of the MPFR function; for example mpfr_max on −0 and +0 gives +0.

When the input point is not in the closure of the domain of the function, the result is NaN. Example: mpfr_sqrt on −17 gives NaN.

When an input argument is NaN, the result is NaN, possibly except when a partial function is constant on the finite floating-point numbers; such a case is always explicitly specified in MPFR Interface. Example: mpfr_hypot on (NaN,0) gives NaN, but mpfr_hypot on (NaN,+Inf) gives +Inf (as specified in Special Functions), since for any finite input x, mpfr_hypot on (x,+Inf) gives +Inf.


Next: , Previous: Floating-Point Values on Special Numbers, Up: MPFR Basics

4.6 Exceptions

MPFR supports 6 exception types:

MPFR has a global flag for each exception, which can be cleared, set or tested by functions described in Exception Related Functions.

Differences with the ISO C99 standard:


Previous: Exceptions, Up: MPFR Basics

4.7 Memory Handling

MPFR functions may create caches, e.g., when computing constants such as Pi, either because the user has called a function like mpfr_const_pi directly or because such a function was called internally by the MPFR library itself to compute some other function.

At any time, the user can free the various caches with mpfr_free_cache. It is strongly advised to do that before terminating a thread, or before exiting when using tools like ‘valgrind’ (to avoid memory leaks being reported).

MPFR internal data such as flags, the exponent range, the default precision and rounding mode, and caches (i.e., data that are not accessed via parameters) are either global (if MPFR has not been compiled as thread safe) or per-thread (thread local storage, TLS). The initial values of TLS data after a thread is created entirely depend on the compiler and thread implementation (MPFR simply does a conventional variable initialization, the variables being declared with an implementation-defined TLS specifier).


Next: , Previous: MPFR Basics, Up: Top

5 MPFR Interface

The floating-point functions expect arguments of type mpfr_t.

The MPFR floating-point functions have an interface that is similar to the GNU MP functions. The function prefix for floating-point operations is mpfr_.

The user has to specify the precision of each variable. A computation that assigns a variable will take place with the precision of the assigned variable; the cost of that computation should not depend on the precision of variables used as input (on average).

The semantics of a calculation in MPFR is specified as follows: Compute the requested operation exactly (with “infinite accuracy”), and round the result to the precision of the destination variable, with the given rounding mode. The MPFR floating-point functions are intended to be a smooth extension of the IEEE 754 arithmetic. The results obtained on a given computer are identical to those obtained on a computer with a different word size, or with a different compiler or operating system.

MPFR does not keep track of the accuracy of a computation. This is left to the user or to a higher layer (for example the MPFI library for interval arithmetic). As a consequence, if two variables are used to store only a few significant bits, and their product is stored in a variable with large precision, then MPFR will still compute the result with full precision.

The value of the standard C macro errno may be set to non-zero by any MPFR function or macro, whether or not there is an error.


Next: , Previous: MPFR Interface, Up: MPFR Interface

5.1 Initialization Functions

An mpfr_t object must be initialized before storing the first value in it. The functions mpfr_init and mpfr_init2 are used for that purpose.

— Function: void mpfr_init2 (mpfr_t x, mpfr_prec_t prec)

Initialize x, set its precision to be exactly prec bits and its value to NaN. (Warning: the corresponding MPF function initializes to zero instead.)

Normally, a variable should be initialized once only or at least be cleared, using mpfr_clear, between initializations. To change the precision of a variable which has already been initialized, use mpfr_set_prec. The precision prec must be an integer between MPFR_PREC_MIN and MPFR_PREC_MAX (otherwise the behavior is undefined).

— Function: void mpfr_inits2 (mpfr_prec_t prec, mpfr_t x, ...)

Initialize all the mpfr_t variables of the given variable argument va_list, set their precision to be exactly prec bits and their value to NaN. See mpfr_init2 for more details. The va_list is assumed to be composed only of type mpfr_t (or equivalently mpfr_ptr). It begins from x, and ends when it encounters a null pointer (whose type must also be mpfr_ptr).

— Function: void mpfr_clear (mpfr_t x)

Free the space occupied by the significand of x. Make sure to call this function for all mpfr_t variables when you are done with them.

— Function: void mpfr_clears (mpfr_t x, ...)

Free the space occupied by all the mpfr_t variables of the given va_list. See mpfr_clear for more details. The va_list is assumed to be composed only of type mpfr_t (or equivalently mpfr_ptr). It begins from x, and ends when it encounters a null pointer (whose type must also be mpfr_ptr).

Here is an example of how to use multiple initialization functions (since NULL is not necessarily defined in this context, we use (mpfr_ptr) 0 instead, but (mpfr_ptr) NULL is also correct).

     {
       mpfr_t x, y, z, t;
       mpfr_inits2 (256, x, y, z, t, (mpfr_ptr) 0);
       ...
       mpfr_clears (x, y, z, t, (mpfr_ptr) 0);
     }
— Function: void mpfr_init (mpfr_t x)

Initialize x, set its precision to the default precision, and set its value to NaN. The default precision can be changed by a call to mpfr_set_default_prec.

Warning! In a given program, some other libraries might change the default precision and not restore it. Thus it is safer to use mpfr_init2.

— Function: void mpfr_inits (mpfr_t x, ...)

Initialize all the mpfr_t variables of the given va_list, set their precision to the default precision and their value to NaN. See mpfr_init for more details. The va_list is assumed to be composed only of type mpfr_t (or equivalently mpfr_ptr). It begins from x, and ends when it encounters a null pointer (whose type must also be mpfr_ptr).

Warning! In a given program, some other libraries might change the default precision and not restore it. Thus it is safer to use mpfr_inits2.

— Macro: MPFR_DECL_INIT (name, prec)

This macro declares name as an automatic variable of type mpfr_t, initializes it and sets its precision to be exactly prec bits and its value to NaN. name must be a valid identifier. You must use this macro in the declaration section. This macro is much faster than using mpfr_init2 but has some drawbacks:

— Function: void mpfr_set_default_prec (mpfr_prec_t prec)

Set the default precision to be exactly prec bits, where prec can be any integer between MPFR_PREC_MIN and MPFR_PREC_MAX. The precision of a variable means the number of bits used to store its significand. All subsequent calls to mpfr_init or mpfr_inits will use this precision, but previously initialized variables are unaffected. The default precision is set to 53 bits initially.

Note: when MPFR is built with the --enable-thread-safe configure option, the default precision is local to each thread. See Memory Handling, for more information.

— Function: mpfr_prec_t mpfr_get_default_prec (void)

Return the current default MPFR precision in bits. See the documentation of mpfr_set_default_prec.

Here is an example on how to initialize floating-point variables:

     {
       mpfr_t x, y;
       mpfr_init (x);                /* use default precision */
       mpfr_init2 (y, 256);          /* precision exactly 256 bits */
       ...
       /* When the program is about to exit, do ... */
       mpfr_clear (x);
       mpfr_clear (y);
       mpfr_free_cache ();           /* free the cache for constants like pi */
     }

The following functions are useful for changing the precision during a calculation. A typical use would be for adjusting the precision gradually in iterative algorithms like Newton-Raphson, making the computation precision closely match the actual accurate part of the numbers.

— Function: void mpfr_set_prec (mpfr_t x, mpfr_prec_t prec)

Reset the precision of x to be exactly prec bits, and set its value to NaN. The previous value stored in x is lost. It is equivalent to a call to mpfr_clear(x) followed by a call to mpfr_init2(x, prec), but more efficient as no allocation is done in case the current allocated space for the significand of x is enough. The precision prec can be any integer between MPFR_PREC_MIN and MPFR_PREC_MAX. In case you want to keep the previous value stored in x, use mpfr_prec_round instead.

— Function: mpfr_prec_t mpfr_get_prec (mpfr_t x)

Return the precision of x, i.e., the number of bits used to store its significand.


Next: , Previous: Initialization Functions, Up: MPFR Interface

5.2 Assignment Functions

These functions assign new values to already initialized floats (see Initialization Functions).

— Function: int mpfr_set (mpfr_t rop, mpfr_t op, mpfr_rnd_t rnd)
— Function: int mpfr_set_ui (mpfr_t rop, unsigned long int op, mpfr_rnd_t rnd)
— Function: int mpfr_set_si (mpfr_t rop, long int op, mpfr_rnd_t rnd)
— Function: int mpfr_set_uj (mpfr_t rop, uintmax_t op, mpfr_rnd_t rnd)
— Function: int mpfr_set_sj (mpfr_t rop, intmax_t op, mpfr_rnd_t rnd)
— Function: int mpfr_set_flt (mpfr_t rop, float op, mpfr_rnd_t rnd)
— Function: int mpfr_set_d (mpfr_t rop, double op, mpfr_rnd_t rnd)
— Function: int mpfr_set_ld (mpfr_t rop, long double op, mpfr_rnd_t rnd)
— Function: int mpfr_set_decimal64 (mpfr_t rop, _Decimal64 op, mpfr_rnd_t rnd)
— Function: int mpfr_set_z (mpfr_t rop, mpz_t op, mpfr_rnd_t rnd)
— Function: int mpfr_set_q (mpfr_t rop, mpq_t op, mpfr_rnd_t rnd)
— Function: int mpfr_set_f (mpfr_t rop, mpf_t op, mpfr_rnd_t rnd)

Set the value of rop from op, rounded toward the given direction rnd. Note that the input 0 is converted to +0 by mpfr_set_ui, mpfr_set_si, mpfr_set_uj, mpfr_set_sj, mpfr_set_z, mpfr_set_q and mpfr_set_f, regardless of the rounding mode. If the system does not support the IEEE 754 standard, mpfr_set_flt, mpfr_set_d, mpfr_set_ld and mpfr_set_decimal64 might not preserve the signed zeros. The mpfr_set_decimal64 function is built only with the configure option ‘--enable-decimal-float’, which also requires ‘--with-gmp-build’, and when the compiler or system provides the ‘_Decimal64’ data type (recent versions of GCC support this data type). mpfr_set_q might fail if the numerator (or the denominator) can not be represented as a mpfr_t.

Note: If you want to store a floating-point constant to a mpfr_t, you should use mpfr_set_str (or one of the MPFR constant functions, such as mpfr_const_pi for Pi) instead of mpfr_set_flt, mpfr_set_d, mpfr_set_ld or mpfr_set_decimal64. Otherwise the floating-point constant will be first converted into a reduced-precision (e.g., 53-bit) binary (or decimal, for mpfr_set_decimal64) number before MPFR can work with it.

— Function: int mpfr_set_ui_2exp (mpfr_t rop, unsigned long int op, mpfr_exp_t e, mpfr_rnd_t rnd)
— Function: int mpfr_set_si_2exp (mpfr_t rop, long int op, mpfr_exp_t e, mpfr_rnd_t rnd)
— Function: int mpfr_set_uj_2exp (mpfr_t rop, uintmax_t op, intmax_t e, mpfr_rnd_t rnd)
— Function: int mpfr_set_sj_2exp (mpfr_t rop, intmax_t op, intmax_t e, mpfr_rnd_t rnd)
— Function: int mpfr_set_z_2exp (mpfr_t rop, mpz_t op, mpfr_exp_t e, mpfr_rnd_t rnd)

Set the value of rop from op multiplied by two to the power e, rounded toward the given direction rnd. Note that the input 0 is converted to +0.

— Function: int mpfr_set_str (mpfr_t rop, const char *s, int base, mpfr_rnd_t rnd)

Set rop to the value of the string s in base base, rounded in the direction rnd. See the documentation of mpfr_strtofr for a detailed description of the valid string formats. Contrary to mpfr_strtofr, mpfr_set_str requires the whole string to represent a valid floating-point number.

The meaning of the return value differs from other MPFR functions: it is 0 if the entire string up to the final null character is a valid number in base base; otherwise it is −1, and rop may have changed (users interested in the ternary value should use mpfr_strtofr instead).

Note: it is preferable to use mpfr_set_str if one wants to distinguish between an infinite rop value coming from an infinite s or from an overflow.

— Function: int mpfr_strtofr (mpfr_t rop, const char *nptr, char **endptr, int base, mpfr_rnd_t rnd)

Read a floating-point number from a string nptr in base base, rounded in the direction rnd; base must be either 0 (to detect the base, as described below) or a number from 2 to 62 (otherwise the behavior is undefined). If nptr starts with valid data, the result is stored in rop and *endptr points to the character just after the valid data (if endptr is not a null pointer); otherwise rop is set to zero (for consistency with strtod) and the value of nptr is stored in the location referenced by endptr (if endptr is not a null pointer). The usual ternary value is returned.

Parsing follows the standard C strtod function with some extensions. After optional leading whitespace, one has a subject sequence consisting of an optional sign (+ or -), and either numeric data or special data. The subject sequence is defined as the longest initial subsequence of the input string, starting with the first non-whitespace character, that is of the expected form.

The form of numeric data is a non-empty sequence of significand digits with an optional decimal point, and an optional exponent consisting of an exponent prefix followed by an optional sign and a non-empty sequence of decimal digits. A significand digit is either a decimal digit or a Latin letter (62 possible characters), with A = 10, B = 11, ..., Z = 35; case is ignored in bases less or equal to 36, in bases larger than 36, a = 36, b = 37, ..., z = 61. The value of a significand digit must be strictly less than the base. The decimal point can be either the one defined by the current locale or the period (the first one is accepted for consistency with the C standard and the practice, the second one is accepted to allow the programmer to provide MPFR numbers from strings in a way that does not depend on the current locale). The exponent prefix can be e or E for bases up to 10, or @ in any base; it indicates a multiplication by a power of the base. In bases 2 and 16, the exponent prefix can also be p or P, in which case the exponent, called binary exponent, indicates a multiplication by a power of 2 instead of the base (there is a difference only for base 16); in base 16 for example 1p2 represents 4 whereas 1@2 represents 256. The value of an exponent is always written in base 10.

If the argument base is 0, then the base is automatically detected as follows. If the significand starts with 0b or 0B, base 2 is assumed. If the significand starts with 0x or 0X, base 16 is assumed. Otherwise base 10 is assumed.

Note: The exponent (if present) must contain at least a digit. Otherwise the possible exponent prefix and sign are not part of the number (which ends with the significand). Similarly, if 0b, 0B, 0x or 0X is not followed by a binary/hexadecimal digit, then the subject sequence stops at the character 0, thus 0 is read.

Special data (for infinities and NaN) can be @inf@ or @nan@(n-char-sequence-opt), and if base <= 16, it can also be infinity, inf, nan or nan(n-char-sequence-opt), all case insensitive. A n-char-sequence-opt is a possibly empty string containing only digits, Latin letters and the underscore (0, 1, 2, ..., 9, a, b, ..., z, A, B, ..., Z, _). Note: one has an optional sign for all data, even NaN. For example, -@nAn@(This_Is_Not_17) is a valid representation for NaN in base 17.

— Function: void mpfr_set_nan (mpfr_t x)
— Function: void mpfr_set_inf (mpfr_t x, int sign)
— Function: void mpfr_set_zero (mpfr_t x, int sign)

Set the variable x to NaN (Not-a-Number), infinity or zero respectively. In mpfr_set_inf or mpfr_set_zero, x is set to plus infinity or plus zero iff sign is nonnegative; in mpfr_set_nan, the sign bit of the result is unspecified.

— Function: void mpfr_swap (mpfr_t x, mpfr_t y)

Swap the values x and y efficiently. Warning: the precisions are exchanged too; in case the precisions are different, mpfr_swap is thus not equivalent to three mpfr_set calls using a third auxiliary variable.


Next: , Previous: Assignment Functions, Up: MPFR Interface

5.3 Combined Initialization and Assignment Functions

— Macro: int mpfr_init_set (mpfr_t rop, mpfr_t op, mpfr_rnd_t rnd)
— Macro: int mpfr_init_set_ui (mpfr_t rop, unsigned long int op, mpfr_rnd_t rnd)
— Macro: int mpfr_init_set_si (mpfr_t rop, long int op, mpfr_rnd_t rnd)
— Macro: int mpfr_init_set_d (mpfr_t rop, double op, mpfr_rnd_t rnd)
— Macro: int mpfr_init_set_ld (mpfr_t rop, long double op, mpfr_rnd_t rnd)
— Macro: int mpfr_init_set_z (mpfr_t rop, mpz_t op, mpfr_rnd_t rnd)
— Macro: int mpfr_init_set_q (mpfr_t rop, mpq_t op, mpfr_rnd_t rnd)
— Macro: int mpfr_init_set_f (mpfr_t rop, mpf_t op, mpfr_rnd_t rnd)

Initialize rop and set its value from op, rounded in the direction rnd. The precision of rop will be taken from the active default precision, as set by mpfr_set_default_prec.

— Function: int mpfr_init_set_str (mpfr_t x, const char *s, int base, mpfr_rnd_t rnd)

Initialize x and set its value from the string s in base base, rounded in the direction rnd. See mpfr_set_str.


Next: , Previous: Combined Initialization and Assignment Functions, Up: MPFR Interface

5.4 Conversion Functions

— Function: float mpfr_get_flt (mpfr_t op, mpfr_rnd_t rnd)
— Function: double mpfr_get_d (mpfr_t op, mpfr_rnd_t rnd)
— Function: long double mpfr_get_ld (mpfr_t op, mpfr_rnd_t rnd)
— Function: _Decimal64 mpfr_get_decimal64 (mpfr_t op, mpfr_rnd_t rnd)

Convert op to a float (respectively double, long double or _Decimal64), using the rounding mode rnd. If op is NaN, some fixed NaN (either quiet or signaling) or the result of 0.0/0.0 is returned. If op is ±Inf, an infinity of the same sign or the result of ±1.0/0.0 is returned. If op is zero, these functions return a zero, trying to preserve its sign, if possible. The mpfr_get_decimal64 function is built only under some conditions: see the documentation of mpfr_set_decimal64.

— Function: long mpfr_get_si (mpfr_t op, mpfr_rnd_t rnd)
— Function: unsigned long mpfr_get_ui (mpfr_t op, mpfr_rnd_t rnd)
— Function: intmax_t mpfr_get_sj (mpfr_t op, mpfr_rnd_t rnd)
— Function: uintmax_t mpfr_get_uj (mpfr_t op, mpfr_rnd_t rnd)

Convert op to a long, an unsigned long, an intmax_t or an uintmax_t (respectively) after rounding it with respect to rnd. If op is NaN, 0 is returned and the erange flag is set. If op is too big for the return type, the function returns the maximum or the minimum of the corresponding C type, depending on the direction of the overflow; the erange flag is set too. See also mpfr_fits_slong_p, mpfr_fits_ulong_p, mpfr_fits_intmax_p and mpfr_fits_uintmax_p.

— Function: double mpfr_get_d_2exp (long *exp, mpfr_t op, mpfr_rnd_t rnd)
— Function: long double mpfr_get_ld_2exp (long *exp, mpfr_t op, mpfr_rnd_t rnd)

Return d and set exp (formally, the value pointed to by exp) such that 0.5<=abs(d)<1 and d times 2 raised to exp equals op rounded to double (resp. long double) precision, using the given rounding mode. If op is zero, then a zero of the same sign (or an unsigned zero, if the implementation does not have signed zeros) is returned, and exp is set to 0. If op is NaN or an infinity, then the corresponding double precision (resp. long-double precision) value is returned, and exp is undefined.

— Function: int mpfr_frexp (mpfr_exp_t *exp, mpfr_t y, mpfr_t x, mpfr_rnd_t rnd)

Set exp (formally, the value pointed to by exp) and y such that 0.5<=abs(y)<1 and y times 2 raised to exp equals x rounded to the precision of y, using the given rounding mode. If x is zero, then y is set to a zero of the same sign and exp is set to 0. If x is NaN or an infinity, then y is set to the same value and exp is undefined.

— Function: mpfr_exp_t mpfr_get_z_2exp (mpz_t rop, mpfr_t op)

Put the scaled significand of op (regarded as an integer, with the precision of op) into rop, and return the exponent exp (which may be outside the current exponent range) such that op exactly equals rop times 2 raised to the power exp. If op is zero, the minimal exponent emin is returned. If op is NaN or an infinity, the erange flag is set, rop is set to 0, and the the minimal exponent emin is returned. The returned exponent may be less than the minimal exponent emin of MPFR numbers in the current exponent range; in case the exponent is not representable in the mpfr_exp_t type, the erange flag is set and the minimal value of the mpfr_exp_t type is returned.

— Function: int mpfr_get_z (mpz_t rop, mpfr_t op, mpfr_rnd_t rnd)

Convert op to a mpz_t, after rounding it with respect to rnd. If op is NaN or an infinity, the erange flag is set, rop is set to 0, and 0 is returned.

— Function: int mpfr_get_f (mpf_t rop, mpfr_t op, mpfr_rnd_t rnd)

Convert op to a mpf_t, after rounding it with respect to rnd. The erange flag is set if op is NaN or an infinity, which do not exist in MPF. If op is NaN, then rop is undefined. If op is an +Inf (resp. −Inf), then rop is set to the maximum (resp. minimum) value in the precision of the MPF number; if a future MPF version supports infinities, this behavior will be considered incorrect and will change (portable programs should assume that rop is set either to this finite number or to an infinite number). Note that since MPFR currently has the same exponent type as MPF (but not with the same radix), the range of values is much larger in MPF than in MPFR, so that an overflow or underflow is not possible.

— Function: char * mpfr_get_str (char *str, mpfr_exp_t *expptr, int b, size_t n, mpfr_t op, mpfr_rnd_t rnd)

Convert op to a string of digits in base b, with rounding in the direction rnd, where n is either zero (see below) or the number of significant digits output in the string; in the latter case, n must be greater or equal to 2. The base may vary from 2 to 62. If the input number is an ordinary number, the exponent is written through the pointer expptr (for input 0, the current minimal exponent is written).

The generated string is a fraction, with an implicit radix point immediately to the left of the first digit. For example, the number −3.1416 would be returned as "−31416" in the string and 1 written at expptr. If rnd is to nearest, and op is exactly in the middle of two consecutive possible outputs, the one with an even significand is chosen, where both significands are considered with the exponent of op. Note that for an odd base, this may not correspond to an even last digit: for example with 2 digits in base 7, (14) and a half is rounded to (15) which is 12 in decimal, (16) and a half is rounded to (20) which is 14 in decimal, and (26) and a half is rounded to (26) which is 20 in decimal.

If n is zero, the number of digits of the significand is chosen large enough so that re-reading the printed value with the same precision, assuming both output and input use rounding to nearest, will recover the original value of op. More precisely, in most cases, the chosen precision of str is the minimal precision m depending only on p = PREC(op) and b that satisfies the above property, i.e., m = 1 + ceil(p*log(2)/log(b)), with p replaced by p−1 if b is a power of 2, but in some very rare cases, it might be m+1 (the smallest case for bases up to 62 is when p equals 186564318007 for bases 7 and 49).

If str is a null pointer, space for the significand is allocated using the current allocation function, and a pointer to the string is returned. To free the returned string, you must use mpfr_free_str.

If str is not a null pointer, it should point to a block of storage large enough for the significand, i.e., at least max(n + 2, 7). The extra two bytes are for a possible minus sign, and for the terminating null character, and the value 7 accounts for -@Inf@ plus the terminating null character.

A pointer to the string is returned, unless there is an error, in which case a null pointer is returned.

— Function: void mpfr_free_str (char *str)

Free a string allocated by mpfr_get_str using the current unallocation function. The block is assumed to be strlen(str)+1 bytes. For more information about how it is done: see Section “Custom Allocation” in GNU MP.

— Function: int mpfr_fits_ulong_p (mpfr_t op, mpfr_rnd_t rnd)
— Function: int mpfr_fits_slong_p (mpfr_t op, mpfr_rnd_t rnd)
— Function: int mpfr_fits_uint_p (mpfr_t op, mpfr_rnd_t rnd)
— Function: int mpfr_fits_sint_p (mpfr_t op, mpfr_rnd_t rnd)
— Function: int mpfr_fits_ushort_p (mpfr_t op, mpfr_rnd_t rnd)
— Function: int mpfr_fits_sshort_p (mpfr_t op, mpfr_rnd_t rnd)
— Function: int mpfr_fits_uintmax_p (mpfr_t op, mpfr_rnd_t rnd)
— Function: int mpfr_fits_intmax_p (mpfr_t op, mpfr_rnd_t rnd)

Return non-zero if op would fit in the respective C data type, respectively unsigned long, long, unsigned int, int, unsigned short, short, uintmax_t, intmax_t, when rounded to an integer in the direction rnd.


Next: , Previous: Conversion Functions, Up: MPFR Interface

5.5 Basic Arithmetic Functions

— Function: int mpfr_add (mpfr_t rop, mpfr_t op1, mpfr_t op2, mpfr_rnd_t rnd)
— Function: int mpfr_add_ui (mpfr_t rop, mpfr_t op1, unsigned long int op2, mpfr_rnd_t rnd)
— Function: int mpfr_add_si (mpfr_t rop, mpfr_t op1, long int op2, mpfr_rnd_t rnd)
— Function: int mpfr_add_d (mpfr_t rop, mpfr_t op1, double op2, mpfr_rnd_t rnd)
— Function: int mpfr_add_z (mpfr_t rop, mpfr_t op1, mpz_t op2, mpfr_rnd_t rnd)
— Function: int mpfr_add_q (mpfr_t rop, mpfr_t op1, mpq_t op2, mpfr_rnd_t rnd)

Set rop to op1 + op2 rounded in the direction rnd. For types having no signed zero, it is considered unsigned (i.e., (+0) + 0 = (+0) and (−0) + 0 = (−0)). The mpfr_add_d function assumes that the radix of the double type is a power of 2, with a precision at most that declared by the C implementation (macro IEEE_DBL_MANT_DIG, and if not defined 53 bits).

— Function: int mpfr_sub (mpfr_t rop, mpfr_t op1, mpfr_t op2, mpfr_rnd_t rnd)
— Function: int mpfr_ui_sub (mpfr_t rop, unsigned long int op1, mpfr_t op2, mpfr_rnd_t rnd)
— Function: int mpfr_sub_ui (mpfr_t rop, mpfr_t op1, unsigned long int op2, mpfr_rnd_t rnd)
— Function: int mpfr_si_sub (mpfr_t rop, long int op1, mpfr_t op2, mpfr_rnd_t rnd)
— Function: int mpfr_sub_si (mpfr_t rop, mpfr_t op1, long int op2, mpfr_rnd_t rnd)
— Function: int mpfr_d_sub (mpfr_t rop, double op1, mpfr_t op2, mpfr_rnd_t rnd)
— Function: int mpfr_sub_d (mpfr_t rop, mpfr_t op1, double op2, mpfr_rnd_t rnd)
— Function: int mpfr_z_sub (mpfr_t rop, mpz_t op1, mpfr_t op2, mpfr_rnd_t rnd)
— Function: int mpfr_sub_z (mpfr_t rop, mpfr_t op1, mpz_t op2, mpfr_rnd_t rnd)
— Function: int mpfr_sub_q (mpfr_t rop, mpfr_t op1, mpq_t op2, mpfr_rnd_t rnd)

Set rop to op1 - op2 rounded in the direction rnd. For types having no signed zero, it is considered unsigned (i.e., (+0) − 0 = (+0), (−0) − 0 = (−0), 0 − (+0) = (−0) and 0 − (−0) = (+0)). The same restrictions than for mpfr_add_d apply to mpfr_d_sub and mpfr_sub_d.

— Function: int mpfr_mul (mpfr_t rop, mpfr_t op1, mpfr_t op2, mpfr_rnd_t rnd)
— Function: int mpfr_mul_ui (mpfr_t rop, mpfr_t op1, unsigned long int op2, mpfr_rnd_t rnd)
— Function: int mpfr_mul_si (mpfr_t rop, mpfr_t op1, long int op2, mpfr_rnd_t rnd)
— Function: int mpfr_mul_d (mpfr_t rop, mpfr_t op1, double op2, mpfr_rnd_t rnd)
— Function: int mpfr_mul_z (mpfr_t rop, mpfr_t op1, mpz_t op2, mpfr_rnd_t rnd))sq varle mpfr_get_ld_2exp (rop, const char *s, int basquage rinted value wit>

Initialize <(+0)). The same restrictions than for mpfr_add_d apply to and mpfr_sub_d.

&mdaonsvar int mpfr_z_sub (mpfr_t rop, mpz_t ointonsmpfr_d_sub and )
— Function: int onsvar int mpfr_sub_z (mpfr_t rop, mpfr_t onst op1, mpfr_t op2, mpfr_rnd_t rnd)
— Function: onstmpfr_2sh; Function: int mpfr_set_d (mpfr_t ntonsmpfr_d_sub and <)
— Functiononsvarnction: int mpfr_mul (mpfr_t rop, mponstg int op2, mpfr_rnd_t rnd)
— Fonstm int2ul_ui (mpfr_t rop, mpfr_t op1, unsigneddtonsmpfr_d_sub and )
— Funconsvarmpfr_mul_si (mpfr_t rop, mpfr_t op1,onstg int op2, mpfr_rnd_t rnd)
&mdashonstmon:3int mpfr_mul_d (mpfr_t rop, mpfr_t oonstdouble op2, mpfr_rnd_t rnd)
&mdasonstmion3mpfr_sub_si (mpfr_t rop, mpfr_t op1, nst mpz_t op2, mpfr_rnd_t rnd))5.3 Combined Initialization and Assignment Functions

—pq sfmpfr_3on: int mpfr_frexp (mpfr_exp_tt char *s, int basquage roosecutive possible >

Initializ> tor_exp_tt char *s, innsideredvert op t nsidered,ass="samp" base.her to this of 754to e)um orr_exp_tt char *s, in a op topfr_set_ = (+0)). The same restrictions than for mpfr_add_d apply to 5.3 Combined Initialization and Assignment Functions

mpfr_get_pfr_exp_tt char *s, int baus;0ar>c..

Initializ. pfr_exp_tt char *s, inr an ert op t ±d,a+dvert op tnr an,git, theop topfr_set_ = (+0)). The same restrictions than for mpfr_add_d apply to 5.3 Combined Initialization and Assignment Functions

&mdapowva3ul_ui (mpfr_t rop, mpfr_t op1, unsignedpowt op1, mpfr_t op2, mpfr_rnd_t rnd)
— Function: powtmpfr_3mpfr_mul_si (mpfr_t rop, mpfr_t op1,powtg int op2, mpfr_rnd_t rnd)
— Fpowtm int4int mpfr_mul_d (mpfr_t rop, mpfr_t opowtdouble op2, mpfr_rnd_t rnd)
&mdaspowtmion4mpfr_sub_si (mpfr_t rop, mpfr_t op1,intpowt op1, mpfr_t op2, mpfr_rnd_t rnd))
— Function: int powtmpfr_4int mpfr_d_sub (mpfr_t rop, double ointpowmpfr_d_sub and )
— Function: int powva4le mpfr_get_ld_2exp (rop, const char *s, inq_t op2, mpfr_ry, the value pod)<">

Initialize mpfr_setage +0)dlith anr> in baser>
ised 993.141 of 754-2008 o esnd, i.e.,owmping no signed :and for t ow(±d,aring allocatr>ympfrd of the b> is Nbytesng t the isfyow(±d,aring allocatr>ympfrd of the b> is Nbytes isfyow(±d,aring allocatr>ympfrd of the b> is Nbytesng t the fr_t fyow(±d,aring allocatr>ympfrd of the b> is Nbytesfr_t fyow(-a nIf is N1e <(li>ow(+1,aring allocatr>ympfrd of the b> is N1 one wiy5<=abs(oth sa class(li>ow(ring allocatx>ympf nIf0rd of the b> is N1 one wiy5<=xbs(oth sa class(li>ow(ring allocatx>ympf nring allocatr>ympfrd of the b> is Ntheyyow(ring allocatx>ympf n- is Nbytes isfow(ring allocatx>ympf n+ is Nbytesfr_t f isfow(- an,gring allocatr>ympfrd of the b> is Nt the fr_t fyow(- an,gring allocatr>ympfrd of the b> is Nbytesfr_t fyow(- an,gring allocatr>ympfrd of the b> is Nt the isfyow(- an,gring allocatr>ympfrd of the b> is Nbytes isfyow(+ an,gring allocatr>ympfrd of the b> is Nbytesfr_t fy isfympfr_add_d apply to 5.3 Combined Initialization and Assignment Functions

5.3 Combined Initialization and Assignment Functions
&mdaonmva4 int mpfr_sub_q (mpfr_t rop, mpfr_t op1, mper or can al ase the ex rinted val1op, mpfr_rn6 would/var>)<"e minimted val1op, mpfnd_t rnd)o1op, mpfal datue pod)<">it, theo1op, mpf) = (+0)). The same restrictions than for mpfr_add_d apply to _2 op1, mpfr_t op2, mpfr_rnd_t rnd)
— Function: int m2pfr_4nction: int mpfr_mul (mpfr_t rop, mpfr_t2g int op2, mpfr_rnd_t rnd)
— Function:2 int4var>char *str, mpfr_exp_t *expptr7t rop, mpfr_t op1, mpq_t op2, mpfr_rponent ex value pod)<>

Initialize Ju_princer of two consevar> thad)<>wt exist in MPF. Ifr_rn6 would1 be retvretidons vale <(+0)). The same restrictions than for mpfr_add_d apply to )
— Function: onstm2pfr_4mpfr_mul_si (mpfr_t rop, mpfr_t op1,onst2g int op2, mpfr_rnd_t rnd)
— Fonstm2 int5int mpfr_mul_dex value pod)<>

Initialize Ju_prdecer of two consevar> thad)<>wt exist in MPF. Ifr_rn6 would1 be retvretidons vale <(+0)). The same restrictions than fos not equivalent to

rnd.

mname="Basic-Arithmetic-Functions">


Next:  Conversion Functions, Up:  s> (mpfr_t rop, long int op, mpfr_excmpp, mpfr_rnd_t rndvar>)mpfr_5int mpfr_add_d (mpfr_t rop, mpfr_t ocmptentation of mpfrar>m int5 int mpfr_sub_z (mpfr_t rop, mpfr_t cmptop, mpfr_rnd_t rndmdnt5sh; Function: int mpfr_set_d (mpfr_tcmpt op, mpfr_rnd_t rnd
mznt5ul_ui (mpfr_t rop, mpfr_t op1, unsignedcmpt mpz_t op2, mpfr_rn>)
mf-16int mpfr_mul_d)<. Rar> is r can al var> isinted val1op, mpfag d 6 would/var>)<, fr_t op, mpfr_r1op, mpfatue pod)<" pfr_set_ var> isimted val1op, mpfal d 6 would/var>)<. Boar>op) is zero,r> (regardase tht. Fo an> is is doubleop to a mpzut the scalfr_t, and for the puts: 7, s op flag us-99(see dispossuish voienough folog(ispossuish, op >erange ity)nr> in bas stri typeyset toe like this of 754tcto
se>-@I =But of inatc#Comparisonent th a precision at most that declared by the C implementation (macro IEEE_cmpp, alue and exp)
mpftm2ash;16mpfr_sub_si (mpfr_t rop, mpfr_t op1,cmptenalue and expmsftm2ash;16>mpfr_t rop, mpfr_t op1,m0">)< unctiplid(which may bvar>)<. Similar me="trIEEE_cmppbss="section">5.3 Coa _sub_dgnment Functions
)<|. Rar> is r can al var> isi |ted val1op, mp|fag d |6 would/var>)<|, fr_t op,|ted val1op, mp|f= |6 would/var>)<|, case pfr_set_ var> isi,|ted val1op, mp|fal d |6 would/var>)<|. Fo an> is is doubleop to a mpzut the scalfr_t, a precision at most that declared by the C implementation (macro IEEE_nand_t rnd)
mpfr_sub_z (mpfr_t rop, mpfr_t xponend_t rnd)
mpfr_mul (mpfr_t rop, mpregulard_t rnd)
— FunctionRar> is r can al var> isinted valop, mpfag d 0, fr_t op, mpfr_rop, mpfat0">it, pfr_set_ var> isi,ted valop, mpfal d 0nt digits > is isdoubleop to a mpzut the scalfr_t, aTigniurnequivaree retue, dependincmpp, ( rnd0rd of th, l(. If op is NaN or an infinity, the erange flag is sets eithd_t rnd)gnment Functions
>h; Fun17mpfr_sub_si (mpfr_t rop, mpfr_t op1,is s>erarnd)gnment Functions
>h; Fun17_2exp (mpfr_t rop, long int op, mpfr_exvar> >erarnd)gnment Functions
)<">ted val1op, mpfal d 6 would/var>)<">ted val1op, mpfal datue pod)<">ted val1op, mpfatue pod)it, fr_t otase 16 , aTput op) = (+0)). The same restrictions than for mpfr_add_d apply to )gnment Functions
mpfr_sub_q (mpfrb> (mpfr_t op, mpfr_r1op, mpf)

otase 16 e <(+0)). The same restrictions than fos not equivalentv

rnd.

rnOdigit name="Basic-Arithmetic-Functions">


Next: 
Allryput op pptr is ;y="n th var> ic-Ar. fr_t fnar>roperar> isvar> ,s r can al var> ifarge rer> isvar> . Note t, ar>ropera is " pfr_set_ var> iotase 16 esi: Imn of e rxuts: ar>pmvar>opopy)turnedpenset_,goth sfargr>p is zero,are consider/coderigonmvar>opmpfr_add_d apply to 5.3 Combined Initialization and Assignment Functions
5.3 Combined Initialization and Assignment Functions
5.3 Combined Initialization and Assignment Functions

Initialize op tansidered p1 anfr_t uld nompf_r> ex rr>IEEE_ue and exp

5.3 Combined Initialization and Assignment Functions
5.3 Combined Initialization and Assignment Functions

Initialize < precision at most that declared by the C implementation (macro IEEE_coss="section">5.3 Combined Initialization and Assignment Functions

mpfr_sub_z (mpfr_t rop, mpfr_t f et rnd)
nmpfr_add_d apply to )
mpfr_mul_si (mpfr_t rop, mpfr_t op1,coss="section">5.3 Combined Initialization and Assignment Functions
" cot to nsecutive possible x-mpfr_005finit_005fset_00te>

Initialize <(+0)). The same restrictions than for mpfr_add_d apply to 5.3 Combined Initialization and Assignment Functions

mpfr_fits_uint_p (mpfraf et rnd)
5.3 Combined Initiyned Initixization and Assignment Functions
5.3 Combined Initialization and Assignment Functions
5.3 Combined Initialization and Assignment Functions
5.3 Combined Initialization and Assignment Functions
5.3 Cosbined Initicbined Initialization and Assignment Functions
char *str, mpfr_exp_t *expptr7t rsiunctanehr>lar> thas char *s, int bahyperbolic scn printed value witce>r 6 wouc char *s, int bahyperbolic cosin ecutive possible x>

Initializ>r to thiss chosen, s 1ar> is zerote oundinalue witce>rn6 wouc char *sde>, af>n ase the t ofs are (rop> to/var>. For tysin_cosd of thifarge the detailithr> in ptzerote> isvar> th a precision at most that declared by the C implementation (macro IEEE_Dechs="section">5.3 Combined Initialization and Assignment Functions

5.3 Combined Initialization and Assignment Functions
5.3 Combined Initialization and Assignment Functions
" cot to nsecutive possible x-mpfr_005finit_005fset_00te>

Initialize <(+0)). The same restrictions than for mpfr_add_d apply to 5.3 Combined Initialization and Assignment Functions

5.3 Combined Initialization and Assignment Functions
5.3 Combined Initialization and Assignment Functions

—dacfmpfr2: int mpfr_add_zexp (mpfr_exp_tt char *s, int badactorde>mrinted value wit,-mpfr_005finit_005fset_00te>

Initialize <(+0)). The same restrictions than for mpfr_add_d apply to exp

5.3 Combined Initialization and Assignment Functions
5.3 Combined Initialization and Assignment Functions
, mntmest, wvsu rinEuler'ar>ropf e ,ote> mpfr_t op" --> andu fargk from 1, mppf_t(k) " op, mpfr_t op1, taret, in a (signiting ifr_0df5.3 Combined Initialization and Assignment Functions
— Function7t rop, mpfr_t op1, mpre..< andiior/div> rinted value wit,var>5.3 Combined Initialization and Assignment Functions
unsigned short, IEEE_lngammas="section">5.3 Combined Initialization and Assignment Functions
, ted vkhar *stbes 1aaar>mppfr_set_ ntIEEE_lgammas="section">5.3 Combine )
rint bapbsoluteg the prin"in Gammaonsigned z>nnted value wit,var> tha>), mpf_tmpr can al nt,fnsidere an arge rfr_set_ nt tha>),, ta> tha>),, t > and (2< --> anfr_te <(+0)). The same restrictions than for mpfr_add_d apply to 5.3 Combined Initialization and Assignment Functions
, < Wt exist ifr_t op1, ta pfr_set_ ntIEEE_zetas="section">5.3 Combined Initialization and Assignment Functions
&mdahypos-22mpfr_set_str (mpfr_t rop, const char *s, int baEuclidearonor rinted vxue wit>r_rn6 wouabs(r_rn6 wouabs(

Initialize mpfr_setage +0)dlith anr> in baser> ised 993.141 of 754-2008 o es: digted vxue wit>ympf_t = (+0)). The same restrictions than for mpfr_add_d apply to )xization and Assignment Functions

, < Wt exist ix>yy, yp us-de willar> iodlerese name= fur> e omparise < precision at most that declared by the C implementation (macro IEEE_constdior2s="section">5.3 Combined Ini and Assignment Functions
mpfr_mul_si (mpfr_t rop, mpfr_t op1,constdp int op2, mpfr_rnd_t rnd
mpfr_mul_si (mpfr_t rop, mpfr_t op1,constdeulerint op2, mpfr_rnd_t rnd
mpfr_sub_si (mpfr_t rop, mpfr_t op1,constdcatal et rnd)
mpfr_t rop, mpfr_t op1,m0"> rin2,pt ba the prinPi, rinEuler'ar>ropf e 0.577p...p,ote>Catal e'ar>ropf e 0.915p...p,s_005fintmax_x-mpfr_005finit_005fset_00 short, op ar> is zeroesmheq> se n e e, dependinf vo_caches=, deph a precision at most that declared by the C implementation (macrovoid- mpz_t of vo_caches=rndvoidt_005fset-64">
—d vo_s="dcache-23Function: int mexp (mF voi in
-@Iropf e sd op1,constdp inof thg
op1,constdeulerinof thir_rn6code> op1,constdcatal et of th)h aYourshouldac..x signivar>op vad,goth siFond idid potac..x si s opIEEE_Dummpfr_d_sub and ptri>ropf tabn: int[]<(ar>)mpfr_exp (mpfr_exp_tt char *s, int basu rin..x elereses rinted vtabn: intde>,ut . For tysummpof thedoethguag e e,>r) valx_0ar>rnd.


Next: , Previous: Conversion Functions, Up:  digit Tignifunctionr> in basopr>csamsp,e mpallowcmhmetic-fil" aor t.hr>csamsp/var> ng o prototypesnd, i.e.s opmpfr_add_d
siz/_code>IEEE_>di_strmpfr_d_subdi_s="dDtr-23v class="defun"> — FunctionOdigit ist ifr_t op1,ionstre.mr> tha>tre.mmp intdeme="nstrs 1arfdexgt e in bas r> thabas bs(ar>ary e>

Innue wit var0,,vnough exgt e somnge (ist ifr_t op1,can="sare.d back twropx_> to/var>. For tygei_strmpof th)h and for the Ie= ddifr_0d int bascopr/var>rin"in nent exgt trails 1atwo conseme=bas r10,ame="indpor &ls Fu;mhmetic-sams">eNNNr>csamsp&rs Fu;, ae cmehe p<. digted vbas bs(mhmetic-sams">@r>csamsp&rs Fu; willar> us-d ntstea --&ls Fu;mhmetic-sams">er>csamsp&rs Fu; asatwo consedelimiterh and for the b> ( is0h a precision at most that declared by the C implementation (macrosiz/_code>IEEE_pfe_strmpfr_d_sub and ,See>rngits in re.d fa> ame= const char *se <(n-FuTr oaegpresei@ize{bas }>n me="ind to an2/var62. , Upand fo(n-FuTr ostrs 1amsprint banor @sams{M@@N}ear,se. , wvscop ex --charackent between,r> tsp" h)ee>rngarg(< itxuis 1aor>. For tysei_strmpof thh aSee "indeocurese fr_0dopue, dependinstrtofrd of thifarge detailithr> in ptzer --> anvaridostrs 1afrematse <(n-Fuvmpfr_setcan="sare.d asifallowsn(gned as rdoethe stmate r):u in dn-Fu@of t{@@NaN@@},e@of t{@@Inf@@},e@of t{+@@Inf@@}ee>rn@of t{-@@Inf@@},e in dn-Fuenough yifallowdp a in dn-Fusid16,nt banollowossistrs 1etage >, Pp prn@of t{-Inf}. , Upand for the b> ( is0h a precision at most that den-Fu@a ntypevarovoid-IEEE_pfe_raw (/code> @ize{fa> } tre.m})e in dn-FuIhe s from stdio stre.mr@ize{>tre.m}ame="indpor asewrortenaby<, Updn-Fu@of t{IEEE_>di_raw}See>rngits innameis vn @ize{fa> }.<, Updn-Fu@enthr>ntypevaro, Updons than fos not equivalentFremate n-Odigit

rnd.


Next: , Previous: Conversion Functions, Up:  <>digit Tiethmetidopue, dependinmehe fs=ing no signed sn Fosiddsdpor ase nn>digit me= similar t nner me=, wvs e Cue, depmehe fs=ing n opopn, Pre t crosesi: Wt exuis 1aa>yprint bs ope he.dpribefhe cmhmetic-fil" aor t.hr>csamsp,e mpallowcmhmetic-fil" aor t.hr>csamsp/var> ng o prototypesnd, i.e.s opTietpor ases, Pp p, dependinmehe fs=ing no ta >mersenseerote>for t% [e>mps] [width] [.[r> is zer]] [type] [code>r>y]nc#Coa prreUp: &ls Fu;mhmetic-sams">e>mpsr>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">widthr>csamsp&rs Fu;,-aar>&ls Fu;mhmetic-sams">r> is zerr>csamsp&rs Fu; toe , wvs(+0)mears 1aasnd, , wvs e e, depmehe fs=ing nd(-@Imhmetic-sams">r> is zerr>csamsp&rs Fu; is rel_str mpich ieonen --exgt e display name="indbas rc,ut naby<&ls Fu;mhmetic-sams">c#Cor>csamsp&rs Fu;tr_rne stvel_str mpich nt is zerote>expoe, dependintd of th ofs are th a , dependinmehe fs=ing no>, Pp s , wvs(+0)&ls Fu;mhmetic-sams">typer>csamsp&rs Fu; smps e anthr>r> i_str &ls Fu;mhmetic-sams">qr>csamsp&rs Fu;,-u>e &ls Fu;mhmetic-sams">llr>csamsp&rs Fu; itstea ),a rellytr mlcntar>tnapfrc&ls Fu;mhmetic-sams">hr>csamsp&rs Fu;or atdr>tnapfrce, depsh ofd of th b/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">hhr>csamsp&rs Fu;o atdr>tnapfrce, depchard of th b/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">jr>csamsp&rs Fu;or atdr>tnapfrce, dephe maxntd of th /code>. uhe maxntd of th b/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">lr>csamsp&rs Fu; r atdr>tnapfrce, dep. wcharntd of th b/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">llr>csamsp&rs Fu; atdr>tnapfrce, dep/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">Lr>csamsp&rs Fu; r atdr>tnapfrce, dep/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">tr>csamsp&rs Fu; r atdr>tnapfrce, depptrase ntd of th b/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">zr>csamsp&rs Fu;or atdr>tnapfrce, depsiz/_cd of th :&nbs/b atdr>/trr>/tare n d+sion at mospp: aar>nmhmetic-sams">typer>csamsp&rs Fu; smhmetic-sams">Rr>csamsp&rs Fu; aar>&ls Fu;mhmetic-sams">Pr>csamsp&rs Fu;tscolumneme="indtare ebelowcsh ws , wvtypeote>c#Cor>csamsp&rs Fu; se wfith t,/v&ls Fu;mhmetic-sams">typer>csamsp&rs Fu; sntar>tnapfrc&ls Fu;mhmetic-sams">Fr>csamsp&rs Fu;or atdr>tnapfrce, dependntd of th,ofa> ac#Compariss b/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">Qr>csamsp&rs Fu;or atdr>tnapfrce, depenqntd of th,ont/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">Mr>csamsp&rs Fu;or atdr>tnapfrce, depen_limbntd of th,ont/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">Nr>csamsp&rs Fu;or atdr>tnapfrce, depen_limbntd of th arrao,ont/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">Zr>csamsp&rs Fu;or atdr>tnapfrce, depenzntd of th,ont/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">Pr>csamsp&rs Fu;or atdr>tnapfrce, dependinmeecntd of th,ont/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">Rr>csamsp&rs Fu; r atdr>tnapfrce, dependintd of th,ofa> ac#Compariss :&nbs/b atdr>/trr>/tare n d+sion at mospp: Tmhmetic-sams">typer>csamsp&rs Fu; soptyper>csamsp&rs Fu; smhmetic-sams">Rr>csamsp&rs Fu; aar>&ls Fu;mhmetic-sams">Pr>csamsp&rs Fu;)mage supn of nn>f , depgen_mehe fs=ing no nond r GMP build; signiiodliesange (, wvs e smhmetic-sams">tr>csamsp&rs Fu;,imu_prwlst be supn of nnvarnd r Cilibr thviFond iw e mpue> t bm.pp: Tmhmetic-sams">code>r>yr>csamsp&rs Fu; fidlnamsmhmetic-sams">Pr>csamsp&rs Fu;oaar>&ls Fu;mhmetic-sams">Rr>csamsp&rs Fu; types,a , dependinmehe fs=ing nobe toee twropx_mas >, depgen_mehe fs=ing n.pp: Tmhmetic-sams">Pr>csamsp&rs Fu;otypeosmhmetic-sams">or>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">ur>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">xr>csamsp&rs Fu;,-or &ls Fu;mhmetic-sams">Xr>csamsp&rs Fu;oc#Comparisos. Fendinmeecntd of th argpresent dt oubifedd t b or>. Fendinmeecntd of th typeodoethe stne Prearily cochosen, s mpa>mde>. ur>)apps=of thiargeiy5nixedvs e type < Tr o&ls Fu;mhmetic-sams">r> is zerr>csamsp&rs Fu; fidlnasmhmetic-sams">r> is zerr>csamsp&rs Fu; is 1 for t)x; for tmhmetic-sams">Rr>csamsp&rs Fu; typeosmhmetic-sams">ar>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">Ar>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">br>csamsp&rs Fu;, &ls Fu;mhmetic-sams">er>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">Er>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">fr>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">Fr>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">yr>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">Gr>csamsp&rs Fu;,-or-&ls Fu;mhmetic-sams">rr>csamsp&rs Fu; c#Comparisos. Fendintd of th argpresent Tr o&ls Fu;mhmetic-sams">Rr>csamsp&rs Fu; typeocan="safallowdmhmetic-sams">code>r>yr>csamsp&rs Fu; sntar>tnapfrc&ls Fu;mhmetic-sams">Ur>csamsp&rs Fu; r atdr>tnapfrccode>anowr>e bytespf_t/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">Dr>csamsp&rs Fu; r atdr>tnapfrccode>anowr>e t the pf_t/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">Yr>csamsp&rs Fu; r atdr>tnapfrccode>aawah from >

b/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">Zr>csamsp&rs Fu;or atdr>tnapfrccode>anowr>e >

b/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">Nr>csamsp&rs Fu;or atdr>tnapfrccode>anotneagesc (r to tiesanogoth ) b/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">*r>csamsp&rs Fu;or atdr>tnapfrccode>r>y. Fendin and d of th argprese jfhe c</trr>/tare n d+sion at mospp: Tr>yr>y veaconsideetage rquipfrese:etprethmetic-conside">for t)x; for tr>y

mhmetic-sams">Yr>csamsp&rs Fu; cecaue> ised geservdsange &ls Fu;mhmetic-sams">Ar>csamsp&rs Fu; sdigit to/ below).pp: Tdigit &ls Fu;mhmetic-sams">c#Cor>csamsp&rs Fu; sntar>tnapfrc&ls Fu;mhmetic-sams">ar>csamsp&rs Fu; &ls Fu;mhmetic-sams">Ar>csamsp&rs Fu; atdr>tnapfrchexnda> ,d 993style b/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">br>csamsp&rs Fu;nd for t tnapfrcbin thv>digit b/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">er>csamsp&rs Fu; &ls Fu;mhmetic-sams">Er>csamsp&rs Fu; tnapfrcscieetdfic por aseda> b/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">fr>csamsp&rs Fu;-&ls Fu;mhmetic-sams">Fr>csamsp&rs Fu; tnapfrcnixedv the da> b/trr>tr mlcntar>tnapfrc&ls Fu;mhmetic-sams">yr>csamsp&rs Fu; &ls Fu;mhmetic-sams">Gr>csamsp&rs Fu; tnapfrcnixedv, iscieetdfic pa> :&nbs/b atdr>/trr>/tare n d+sion at mospp: Tmhmetic-sams">br>csamsp&rs Fu;nw, af>displays="indaegpreseime=bin thvis s. Fdoure d of th argpresenpp: I> rinr>mpdcodmath>digit,n>f mpfr_setage alwaytadisplay naas >, depn td of th,o>, dep-pf_d of th,or_rn6code>pf_d of th for-&ls Fu;mhmetic-sams">ar>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">br>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">er>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">fr>csamsp&rs Fu;,-aar>&ls Fu;mhmetic-sams">yr>csamsp&rs Fu; s, dep-INFd of th,or_rn6code>INFd of th for-&ls Fu;mhmetic-sams">Ar>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">Er>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">Fr>csamsp&rs Fu;,- a&ls Fu;mhmetic-sams">Gr>csamsp&rs Fu; smhmetic-sams">r> is zerr>csamsp&rs Fu; fidlnams is zeroee="index-mpfr_0dsr>y /f tnt digits r> is zeroesm>

r>ymhmetic-sams">c#Cor>csamsp&rs Fu; smhmetic-sams">ar>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">Ar>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">br>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">er>csamsp&rs Fu;,a&ls Fu;mhmetic-sams">Er>csamsp&rs Fu;,-tie vs code> na mpoth swt exieiliet between twoi>ropecuntma pfr_setaod is zerow, af> toe , wvs(+0)two cons, otase 16 art naawah from >

r to thi por asesmhmetic-sams">yr>csamsp&rs Fu; then <&ls Fu;mhmetic-sams">Gr>csamsp&rs Fu;)vc#Comparisos an&ls Fu;mhmetic-sams">er>csamsp&rs Fu; then <&ls Fu;mhmetic-sams">Er>csamsp&rs Fu;)3stylent digits r> is zeroesmret inaivar> igs eith t, id, gen e, depapps=of thart siresex_0aeducithrown mpe, depINT_MAXs=ing n.pp: If(, wv&ls Fu;mhmetic-sams">r> is zerr>csamsp&rs Fu; fidlnamsr toa&ls Fu;mhmetic-sams">c#Cor>csamsp&rs Fu; smhmetic-sams">er>csamsp&rs Fu; aar>&ls Fu;mhmetic-sams">Er>csamsp&rs Fu;,-tch ieonen vs display nar toavnough exgt e somnge (it,can="sare.d back twropx_"aassu ossie>e (t baihe sce>r >digit ofs are t toe , wvs(+0)r> is zeroaar>nrv>digit code>r>yr>y. For tygei_strmpof th)ht Tr oa nais r> is zerod, genmhmetic-sams">r> is zerr>csamsp&rs Fu; fidlnar to &ls Fu;mhmetic-sams">c#Cor>csamsp&rs Fu;tsmhmetic-sams">fr>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">Fr>csamsp&rs Fu;,-&ls Fu;mhmetic-sams">yr>csamsp&rs Fu;,-aar>&ls Fu;mhmetic-sams">Gr>csamsp&rs Fu; vs 6.ctih4thmetic-fubfunctions-99.3 name="Basici4hmetp>>opoughtdid of th,ovalue pobufcode>,Sevalue postrmpment b t bavar>op isansidere1/ctors="inde to a e>mp,-aar>(in POSIX system >f <)ue, deperrnos=ing no taret ine, depEOVERFLOWs=ing n.ppions than for mpfr_add_d apply to ropf char *templ_st,o>r>p...pt_005fset-64">
—dmehe f-24 int mpfr_z_sub (mpfr_t rop, mpz_t ovdmehe fs=fr_d_subropf char *templ_st,ova_listmapt_005fset-64">
—vdmehe f-24 int mpfr_add_zexp (mPr tha>tre.mmp intnt baoptzere>margpreseeede> rc< templ_stostrs 1ated vtempl_sthar *se ( is. an err, occurhede <(n-FuI. oughtop isa@sider{}1/ctors="ind@emph{e to a} e>mp,-aar>(ina in dn-FuPOSIX system >f <)u@of t{errno}o taret in@of t{EOVERFLOW}.u in d+0)). The same restrictions than for mpfr_add_d apply to ropf char *templ_st,o>r>p...pt_005fset-64">
—mehe f-24sh; Function: int mpfr_set_d (mpfr_tvmehe fs=fr_d_sub<>ropf char *templ_st,ova_listmapt_005fset-64">
—vmehe f-24mpfr_set_str (mpfr_t Pr did of thnt baoptzere>margpreseeede> rc< ( is. an err, occurhede <(n-FuI. oughtdi}Set bavar>op isa@sider{}1/ctors="ind@emph{e to a} e>mp,-, Updn-Fuaar>(inaPOSIX system >f <)u@of t{errno}o taret in@of t{EOVERFLOW}.u in d+0)). The same restrictions than for mpfr_add_d apply to har *bufSe>ropf char *templ_st,o>r>p...pt_005fset-64">
—smehe f-24ul_ui
(mpfr_t rop, mpfr_t op1, unsignedvsmehe fs=fr_d_sub<>har *bufSe>ropf char *templ_st,ova_listmapt_005fset-64">
—vsmehe f-24v class="defun"> — FunctionFremaaars t-margpreseeede> r <rngr ,. No oomplap, tab/rsite nnbetween,ue pobufcode>, aar>n (mp,-aar>(inaPOSIX system >f <)u, Updn-Fuof t{errno}o taret in@of t{EOVERFLOW}.u in d+0)). The same restrictions than for mpfr_add_d apply to har *bufSesiz/_conne>ropf char *templ_st,o>r>p...pt_005fset-64">
—snmehe f-250l_ui (mpfr_t rop, mpfr_t op1, unsignedvsnmehe fs=fr_d_sub<>har *bufSesiz/_conne>ropf char *templ_st,ova_listmapt_005fset-64">
—vsnmehe f-25nction: int mpf> (mpfr_t Fremaaars t-margpreseeede> r <rngr ,. Ie>

Innue wit var>

Seiotas 1ams wrortenar_rn6 woubufcode>, sicaag aars th the pr, otase 16 ar"ind

Innue witnsidere1 nent charackent age wrortename=ue pobufcode>, aar>nInnue wit-th, ta ps thcharackennt b> (be sufficieeex_0 Not, potacodetr>y thi tersidndoss rs thcharacken, arge rfr_set_ var> is. an err, occurhede <(n-FuI. margpreseeede> rc<op isa@sider{}1/ctors="ind@emph{e to a} e>mp,-aar>, Updn-Fu(inaPOSIX system >f <)u@of t{errno}o taret in@of t{EOVERFLOW}.u in d+0)). The same restrictions than for mpfr_add_d apply to har **strne>ropf char *templ_st,o>r>p...pt_005fset-64">
—asmehe f-25Function: int mpfr_fits_uint_p (mpfrvasmehe fs=fr_d_sub<>har **strne>ropf char *templ_st,ova_listmapt_005fset-64">
—vasmehe f-25Function: int mexp (mWror weheirv>digit ata ps th d vodxuis 1aor>. For tyd vo_strmpof thh aThs he scaivar> ista"indleonen --charackent wrorten me="indstrs 1,goxclu>r>y "indle t- is. an err, occurhede <(n-FuI. margpreseeede> rc<tr}, ta ps th the pr, t bavar>op isa@sider{}1/ctors= in dn-Fusind@emph{e to a} e>mp,-aar>(inaPOSIX system >f <)u@of t{errno}o taret in, Updn-Fu@of t{EOVERFLOW}.u in d+0)). The same restrictions than fos not equivalentIhrnd.

r>y-Rel_str
r>y Rel_str name="Basic-Arithmetic-Functions">


Next: , Previous: Conversion Functions, Up: mpfr_add_d
apply to 5.3 Combined Initialization and Assignment Functions
5.3 Combined Initialgnment Functions
mpfr_set_str apply to int op2, mpfr_rnd_t rnd
— Functionpfr_exp_tt char *s, inist ifr_t op1,code> na mpanonts mpich ieagescr> sese re ent,Se6code> op1,ceils=of thicode>s mpich iext highve 0r,var> ar>r> sese re ent op1,floorinof thnto ich iext linus;0r,var> ar>r> sese re ent op1,rode>inof thntodr> sese re entr>ysaawah from >

(as itot bacode>TiesToAwah /f tr> sese re ente >

h and for the Ths he sca napfr_soesm>

mpfr_sote>

Inalhar *sSee>rnrfr_set_ wt exieimsar>p is ax_x-ths he sca napfr_soesm0 wt exist ifr_t op1, ta >mpfr> sese re ent= const char *s, 1 rransidere1 wt exist ifr_t op1, ta >mpf sese re ent= const char *s, 2 rransidere2 wt exist ifr_t op1, t e strn nt op1,rode>inof thnvs diffehe t from or>. Fendinrapps=of thicpr>ysaare,code> na mpanooth ntr>y< tab/rpor ed;nd, iopf ec ar10.5 (1010.1ime=bin th) navar>, dependinrapps=of thir toacode>r>y is zer,/cecaue> t b twoienclososs rsonenstver> sese re on twoibt eaare,8ee>rn12, aar>n na mpanonta10.5 sid10ar toavth scode>r>y, aar>n code> na mp8eegaiear to vth scode>r>y.) a precision at most that declared by the C implementation (macro IEEE_rapp,ceils="section">5.3 Combined Initialization and Assignment Functions

(mpfr_t rop, mpfr_t op1, unsignedrappsfloorint op2, mpfr_rnd_t rnd
mpfr_sub_si (mpfr_t rop, mpfr_t op1,rappsrode>int op2, mpfr_rnd_t rnd
i26Function: int mpfr_fits_uint_p (mpfrrappstr mpint op2, mpfr_rnd_t rnd
mexp (mpfr_exp_tt char *s, inist ifr_t op1,code> na mpanonts mpich iext highve 0r,var> ant antinof thntodr>ysaawah from >

,or_rn6code>>mpfrrappstr mpinof thnto ich iext nte >

ht digits heeis vare stver> sese re art name="index-mpfr_0d short, < Tr ohe sca napfr_soesmthi tern thvpfr_so byoci_str r to thie>ropi> redacode>-to-ntop name="inds(+0)wah ata nodotase mathematnc..avar>opopr>y: nent ist ifr_t op1, taar>Cott ex, oubifagesc sese re ) mpfr_exp (mpfr_exp_tt char *s, int bafraptzere>m

Inalhar *sSehavs 1a<Inalhar *sSecode> name="index-mpfr_0d short, (unlike itodeng nendinrapps=of th, short, affeces rf mmIEEE_/f fint op2, mpfr_rnd_i rnd

, r to thi cochosen, s 1or> is zerote>ue poi char *s,r_rn6 wouf char *s,(rquipfrese, i 6, dependintr mp(s=of thue poi char *s=of thue po char *s=of thue pot,. For tyd ap(s=of thue pof char *s=of thue po char *s=of thue pot, diffehe t. b> ( in ptzerote thi he scaivar> th a precision at most that declared by the C implementation (macro IEEE_d/f int op2, mpfr_rnd_tnd
ri26mpfr_set_str apply to