1 This is mpfr.info, produced by makeinfo version 4.13 from mpfr.texi.
3 This manual documents how to install and use the Multiple Precision
4 Floating-Point Reliable Library, version 3.0.1.
6 Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
7 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free
8 Software Foundation, Inc.
10 Permission is granted to copy, distribute and/or modify this
11 document under the terms of the GNU Free Documentation License, Version
12 1.2 or any later version published by the Free Software Foundation;
13 with no Invariant Sections, with no Front-Cover Texts, and with no
14 Back-Cover Texts. A copy of the license is included in *note GNU Free
15 Documentation License::.
17 INFO-DIR-SECTION Software libraries
19 * mpfr: (mpfr). Multiple Precision Floating-Point Reliable Library.
23 File: mpfr.info, Node: Top, Next: Copying, Prev: (dir), Up: (dir)
28 This manual documents how to install and use the Multiple Precision
29 Floating-Point Reliable Library, version 3.0.1.
31 Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
32 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free
33 Software Foundation, Inc.
35 Permission is granted to copy, distribute and/or modify this
36 document under the terms of the GNU Free Documentation License, Version
37 1.2 or any later version published by the Free Software Foundation;
38 with no Invariant Sections, with no Front-Cover Texts, and with no
39 Back-Cover Texts. A copy of the license is included in *note GNU Free
40 Documentation License::.
45 * Copying:: MPFR Copying Conditions (LGPL).
46 * Introduction to MPFR:: Brief introduction to GNU MPFR.
47 * Installing MPFR:: How to configure and compile the MPFR library.
48 * Reporting Bugs:: How to usefully report bugs.
49 * MPFR Basics:: What every MPFR user should now.
50 * MPFR Interface:: MPFR functions and macros.
51 * API Compatibility:: API compatibility with previous MPFR versions.
54 * GNU Free Documentation License::
59 File: mpfr.info, Node: Copying, Next: Introduction to MPFR, Prev: Top, Up: Top
61 MPFR Copying Conditions
62 ***********************
64 The GNU MPFR library (or MPFR for short) is "free"; this means that
65 everyone is free to use it and free to redistribute it on a free basis.
66 The library is not in the public domain; it is copyrighted and there
67 are restrictions on its distribution, but these restrictions are
68 designed to permit everything that a good cooperating citizen would
69 want to do. What is not allowed is to try to prevent others from
70 further sharing any version of this library that they might get from
73 Specifically, we want to make sure that you have the right to give
74 away copies of the library, that you receive source code or else can
75 get it if you want it, that you can change this library or use pieces
76 of it in new free programs, and that you know you can do these things.
78 To make sure that everyone has such rights, we have to forbid you to
79 deprive anyone else of these rights. For example, if you distribute
80 copies of the GNU MPFR library, you must give the recipients all the
81 rights that you have. You must make sure that they, too, receive or
82 can get the source code. And you must tell them their rights.
84 Also, for our own protection, we must make certain that everyone
85 finds out that there is no warranty for the GNU MPFR library. If it is
86 modified by someone else and passed on, we want their recipients to
87 know that what they have is not what we distributed, so that any
88 problems introduced by others will not reflect on our reputation.
90 The precise conditions of the license for the GNU MPFR library are
91 found in the Lesser General Public License that accompanies the source
92 code. See the file COPYING.LESSER.
95 File: mpfr.info, Node: Introduction to MPFR, Next: Installing MPFR, Prev: Copying, Up: Top
97 1 Introduction to MPFR
98 **********************
100 MPFR is a portable library written in C for arbitrary precision
101 arithmetic on floating-point numbers. It is based on the GNU MP library.
102 It aims to provide a class of floating-point numbers with precise
103 semantics. The main characteristics of MPFR, which make it differ from
104 most arbitrary precision floating-point software tools, are:
106 * the MPFR code is portable, i.e., the result of any operation does
107 not depend on the machine word size `mp_bits_per_limb' (64 on most
110 * the precision in bits can be set _exactly_ to any valid value for
111 each variable (including very small precision);
113 * MPFR provides the four rounding modes from the IEEE 754-1985
114 standard, plus away-from-zero, as well as for basic operations as
115 for other mathematical functions.
117 In particular, with a precision of 53 bits, MPFR is able to exactly
118 reproduce all computations with double-precision machine floating-point
119 numbers (e.g., `double' type in C, with a C implementation that
120 rigorously follows Annex F of the ISO C99 standard and `FP_CONTRACT'
121 pragma set to `OFF') on the four arithmetic operations and the square
122 root, except the default exponent range is much wider and subnormal
123 numbers are not implemented (but can be emulated).
125 This version of MPFR is released under the GNU Lesser General Public
126 License, version 3 or any later version. It is permitted to link MPFR
127 to most non-free programs, as long as when distributing them the MPFR
128 source code and a means to re-link with a modified MPFR library is
131 1.1 How to Use This Manual
132 ==========================
134 Everyone should read *note MPFR Basics::. If you need to install the
135 library yourself, you need to read *note Installing MPFR::, too. To
136 use the library you will need to refer to *note MPFR Interface::.
138 The rest of the manual can be used for later reference, although it
139 is probably a good idea to glance through it.
142 File: mpfr.info, Node: Installing MPFR, Next: Reporting Bugs, Prev: Introduction to MPFR, Up: Top
147 The MPFR library is already installed on some GNU/Linux distributions,
148 but the development files necessary to the compilation such as `mpfr.h'
149 are not always present. To check that MPFR is fully installed on your
150 computer, you can check the presence of the file `mpfr.h' in
151 `/usr/include', or try to compile a small program having `#include
152 <mpfr.h>' (since `mpfr.h' may be installed somewhere else). For
153 instance, you can try to compile:
159 printf ("MPFR library: %-12s\nMPFR header: %s (based on %d.%d.%d)\n",
160 mpfr_get_version (), MPFR_VERSION_STRING, MPFR_VERSION_MAJOR,
161 MPFR_VERSION_MINOR, MPFR_VERSION_PATCHLEVEL);
167 cc -o version version.c -lmpfr -lgmp
169 and if you get errors whose first line looks like
171 version.c:2:19: error: mpfr.h: No such file or directory
173 then MPFR is probably not installed. Running this program will give you
176 If MPFR is not installed on your computer, or if you want to install
177 a different version, please follow the steps below.
182 Here are the steps needed to install the library on Unix systems (more
183 details are provided in the `INSTALL' file):
185 1. To build MPFR, you first have to install GNU MP (version 4.1 or
186 higher) on your computer. You need a C compiler, preferably GCC,
187 but any reasonable compiler should work. And you need the
188 standard Unix `make' command, plus some other standard Unix
191 Then, in the MPFR build directory, type the following commands.
195 This will prepare the build and setup the options according to
196 your system. You can give options to specify the install
197 directories (instead of the default `/usr/local'), threading
198 support, and so on. See the `INSTALL' file and/or the output of
199 `./configure --help' for more information, in particular if you
204 This will compile MPFR, and create a library archive file
205 `libmpfr.a'. On most platforms, a dynamic library will be
210 This will make sure MPFR was built correctly. If you get error
211 messages, please report this to `mpfr@loria.fr'. (*Note Reporting
212 Bugs::, for information on what to include in useful bug reports.)
216 This will copy the files `mpfr.h' and `mpf2mpfr.h' to the directory
217 `/usr/local/include', the library files (`libmpfr.a' and possibly
218 others) to the directory `/usr/local/lib', the file `mpfr.info' to
219 the directory `/usr/local/share/info', and some other documentation
220 files to the directory `/usr/local/share/doc/mpfr' (or if you
221 passed the `--prefix' option to `configure', using the prefix
222 directory given as argument to `--prefix' instead of `/usr/local').
224 2.2 Other `make' Targets
225 ========================
227 There are some other useful make targets:
229 * `mpfr.info' or `info'
231 Create or update an info version of the manual, in `mpfr.info'.
233 This file is already provided in the MPFR archives.
235 * `mpfr.pdf' or `pdf'
237 Create a PDF version of the manual, in `mpfr.pdf'.
239 * `mpfr.dvi' or `dvi'
241 Create a DVI version of the manual, in `mpfr.dvi'.
245 Create a Postscript version of the manual, in `mpfr.ps'.
247 * `mpfr.html' or `html'
249 Create a HTML version of the manual, in several pages in the
250 directory `mpfr.html'; if you want only one output HTML file, then
251 type `makeinfo --html --no-split mpfr.texi' instead.
255 Delete all object files and archive files, but not the
260 Delete all generated files not included in the distribution.
264 Delete all files copied by `make install'.
269 In case of problem, please read the `INSTALL' file carefully before
270 reporting a bug, in particular section "In case of problem". Some
271 problems are due to bad configuration on the user side (not specific to
272 MPFR). Problems are also mentioned in the FAQ
273 `http://www.mpfr.org/faq.html'.
275 Please report problems to `mpfr@loria.fr'. *Note Reporting Bugs::.
276 Some bug fixes are available on the MPFR 3.0.1 web page
277 `http://www.mpfr.org/mpfr-3.0.1/'.
279 2.4 Getting the Latest Version of MPFR
280 ======================================
282 The latest version of MPFR is available from
283 `ftp://ftp.gnu.org/gnu/mpfr/' or `http://www.mpfr.org/'.
286 File: mpfr.info, Node: Reporting Bugs, Next: MPFR Basics, Prev: Installing MPFR, Up: Top
291 If you think you have found a bug in the MPFR library, first have a look
292 on the MPFR 3.0.1 web page `http://www.mpfr.org/mpfr-3.0.1/' and the
293 FAQ `http://www.mpfr.org/faq.html': perhaps this bug is already known,
294 in which case you may find there a workaround for it. You might also
295 look in the archives of the MPFR mailing-list:
296 `http://websympa.loria.fr/wwsympa/arc/mpfr'. Otherwise, please
297 investigate and report it. We have made this library available to you,
298 and it is not to ask too much from you, to ask you to report the bugs
301 There are a few things you should think about when you put your bug
304 You have to send us a test case that makes it possible for us to
305 reproduce the bug, i.e., a small self-content program, using no other
306 library than MPFR. Include instructions on how to run the test case.
308 You also have to explain what is wrong; if you get a crash, or if
309 the results you get are incorrect and in that case, in what way.
311 Please include compiler version information in your bug report. This
312 can be extracted using `cc -V' on some machines, or, if you're using
313 GCC, `gcc -v'. Also, include the output from `uname -a' and the MPFR
314 version (the GMP version may be useful too).
316 If your bug report is good, we will do our best to help you to get a
317 corrected version of the library; if the bug report is poor, we will
318 not do anything about it (aside of chiding you to send better bug
321 Send your bug report to: `mpfr@loria.fr'.
323 If you think something in this manual is unclear, or downright
324 incorrect, or if the language needs to be improved, please send a note
328 File: mpfr.info, Node: MPFR Basics, Next: MPFR Interface, Prev: Reporting Bugs, Up: Top
333 4.1 Headers and Libraries
334 =========================
336 All declarations needed to use MPFR are collected in the include file
337 `mpfr.h'. It is designed to work with both C and C++ compilers. You
338 should include that file in any program using the MPFR library:
342 Note however that prototypes for MPFR functions with `FILE *'
343 parameters are provided only if `<stdio.h>' is included too (before
349 Likewise `<stdarg.h>' (or `<varargs.h>') is required for prototypes
350 with `va_list' parameters, such as `mpfr_vprintf'.
352 And for any functions using `intmax_t', you must include
353 `<stdint.h>' or `<inttypes.h>' before `mpfr.h', to allow `mpfr.h' to
354 define prototypes for these functions. Moreover, users of C++ compilers
355 under some platforms may need to define `MPFR_USE_INTMAX_T' (and should
356 do it for portability) before `mpfr.h' has been included; of course, it
357 is possible to do that on the command line, e.g., with
358 `-DMPFR_USE_INTMAX_T'.
360 Note: If `mpfr.h' and/or `gmp.h' (used by `mpfr.h') are included
361 several times (possibly from another header file), the aforementioned
362 standard headers should be included *before* the first inclusion of
363 `mpfr.h' or `gmp.h'. For the time being, this problem is not avoidable
364 in MPFR without a change in GMP.
366 When calling a MPFR macro, it is not allowed to have previously
367 defined a macro with the same name as some keywords (currently `do',
368 `while' and `sizeof').
370 You can avoid the use of MPFR macros encapsulating functions by
371 defining the `MPFR_USE_NO_MACRO' macro before `mpfr.h' is included. In
372 general this should not be necessary, but this can be useful when
373 debugging user code: with some macros, the compiler may emit spurious
374 warnings with some warning options, and macros can prevent some
377 All programs using MPFR must link against both `libmpfr' and
378 `libgmp' libraries. On a typical Unix-like system this can be done
379 with `-lmpfr -lgmp' (in that order), for example:
381 gcc myprogram.c -lmpfr -lgmp
383 MPFR is built using Libtool and an application can use that to link
384 if desired, *note GNU Libtool: (libtool.info)Top.
386 If MPFR has been installed to a non-standard location, then it may be
387 necessary to set up environment variables such as `C_INCLUDE_PATH' and
388 `LIBRARY_PATH', or use `-I' and `-L' compiler options, in order to
389 point to the right directories. For a shared library, it may also be
390 necessary to set up some sort of run-time library path (e.g.,
391 `LD_LIBRARY_PATH') on some systems. Please read the `INSTALL' file for
392 additional information.
394 4.2 Nomenclature and Types
395 ==========================
397 A "floating-point number", or "float" for short, is an arbitrary
398 precision significand (also called mantissa) with a limited precision
399 exponent. The C data type for such objects is `mpfr_t' (internally
400 defined as a one-element array of a structure, and `mpfr_ptr' is the C
401 data type representing a pointer to this structure). A floating-point
402 number can have three special values: Not-a-Number (NaN) or plus or
403 minus Infinity. NaN represents an uninitialized object, the result of
404 an invalid operation (like 0 divided by 0), or a value that cannot be
405 determined (like +Infinity minus +Infinity). Moreover, like in the IEEE
406 754 standard, zero is signed, i.e., there are both +0 and -0; the
407 behavior is the same as in the IEEE 754 standard and it is generalized
408 to the other functions supported by MPFR. Unless documented otherwise,
409 the sign bit of a NaN is unspecified.
411 The "precision" is the number of bits used to represent the significand
412 of a floating-point number; the corresponding C data type is
413 `mpfr_prec_t'. The precision can be any integer between
414 `MPFR_PREC_MIN' and `MPFR_PREC_MAX'. In the current implementation,
415 `MPFR_PREC_MIN' is equal to 2.
417 Warning! MPFR needs to increase the precision internally, in order to
418 provide accurate results (and in particular, correct rounding). Do not
419 attempt to set the precision to any value near `MPFR_PREC_MAX',
420 otherwise MPFR will abort due to an assertion failure. Moreover, you
421 may reach some memory limit on your platform, in which case the program
422 may abort, crash or have undefined behavior (depending on your C
425 The "rounding mode" specifies the way to round the result of a
426 floating-point operation, in case the exact result can not be
427 represented exactly in the destination significand; the corresponding C
428 data type is `mpfr_rnd_t'.
430 4.3 MPFR Variable Conventions
431 =============================
433 Before you can assign to an MPFR variable, you need to initialize it by
434 calling one of the special initialization functions. When you're done
435 with a variable, you need to clear it out, using one of the functions
436 for that purpose. A variable should only be initialized once, or at
437 least cleared out between each initialization. After a variable has
438 been initialized, it may be assigned to any number of times. For
439 efficiency reasons, avoid to initialize and clear out a variable in
440 loops. Instead, initialize it before entering the loop, and clear it
441 out after the loop has exited. You do not need to be concerned about
442 allocating additional space for MPFR variables, since any variable has
443 a significand of fixed size. Hence unless you change its precision, or
444 clear and reinitialize it, a floating-point variable will have the same
445 allocated space during all its life.
447 As a general rule, all MPFR functions expect output arguments before
448 input arguments. This notation is based on an analogy with the
449 assignment operator. MPFR allows you to use the same variable for both
450 input and output in the same expression. For example, the main
451 function for floating-point multiplication, `mpfr_mul', can be used
452 like this: `mpfr_mul (x, x, x, rnd)'. This computes the square of X
453 with rounding mode `rnd' and puts the result back in X.
458 The following five rounding modes are supported:
460 * `MPFR_RNDN': round to nearest (roundTiesToEven in IEEE 754-2008),
462 * `MPFR_RNDZ': round toward zero (roundTowardZero in IEEE 754-2008),
464 * `MPFR_RNDU': round toward plus infinity (roundTowardPositive in
467 * `MPFR_RNDD': round toward minus infinity (roundTowardNegative in
470 * `MPFR_RNDA': round away from zero (experimental).
472 The `round to nearest' mode works as in the IEEE 754 standard: in
473 case the number to be rounded lies exactly in the middle of two
474 representable numbers, it is rounded to the one with the least
475 significant bit set to zero. For example, the number 2.5, which is
476 represented by (10.1) in binary, is rounded to (10.0)=2 with a
477 precision of two bits, and not to (11.0)=3. This rule avoids the
478 "drift" phenomenon mentioned by Knuth in volume 2 of The Art of
479 Computer Programming (Section 4.2.2).
481 Most MPFR functions take as first argument the destination variable,
482 as second and following arguments the input variables, as last argument
483 a rounding mode, and have a return value of type `int', called the
484 "ternary value". The value stored in the destination variable is
485 correctly rounded, i.e., MPFR behaves as if it computed the result with
486 an infinite precision, then rounded it to the precision of this
487 variable. The input variables are regarded as exact (in particular,
488 their precision does not affect the result).
490 As a consequence, in case of a non-zero real rounded result, the
491 error on the result is less or equal to 1/2 ulp (unit in the last
492 place) of that result in the rounding to nearest mode, and less than 1
493 ulp of that result in the directed rounding modes (a ulp is the weight
494 of the least significant represented bit of the result after rounding).
496 Unless documented otherwise, functions returning an `int' return a
497 ternary value. If the ternary value is zero, it means that the value
498 stored in the destination variable is the exact result of the
499 corresponding mathematical function. If the ternary value is positive
500 (resp. negative), it means the value stored in the destination variable
501 is greater (resp. lower) than the exact result. For example with the
502 `MPFR_RNDU' rounding mode, the ternary value is usually positive,
503 except when the result is exact, in which case it is zero. In the case
504 of an infinite result, it is considered as inexact when it was obtained
505 by overflow, and exact otherwise. A NaN result (Not-a-Number) always
506 corresponds to an exact return value. The opposite of a returned
507 ternary value is guaranteed to be representable in an `int'.
509 Unless documented otherwise, functions returning as result the value
510 `1' (or any other value specified in this manual) for special cases
511 (like `acos(0)') yield an overflow or an underflow if that value is not
512 representable in the current exponent range.
514 4.5 Floating-Point Values on Special Numbers
515 ============================================
517 This section specifies the floating-point values (of type `mpfr_t')
518 returned by MPFR functions (where by "returned" we mean here the
519 modified value of the destination object, which should not be mixed
520 with the ternary return value of type `int' of those functions). For
521 functions returning several values (like `mpfr_sin_cos'), the rules
522 apply to each result separately.
524 Functions can have one or several input arguments. An input point is
525 a mapping from these input arguments to the set of the MPFR numbers.
526 When none of its components are NaN, an input point can also be seen as
527 a tuple in the extended real numbers (the set of the real numbers with
530 When the input point is in the domain of the mathematical function,
531 the result is rounded as described in Section "Rounding Modes" (but see
532 below for the specification of the sign of an exact zero). Otherwise
533 the general rules from this section apply unless stated otherwise in
534 the description of the MPFR function (*note MPFR Interface::).
536 When the input point is not in the domain of the mathematical
537 function but is in its closure in the extended real numbers and the
538 function can be extended by continuity, the result is the obtained
539 limit. Examples: `mpfr_hypot' on (+Inf,0) gives +Inf. But `mpfr_pow'
540 cannot be defined on (1,+Inf) using this rule, as one can find
541 sequences (X_N,Y_N) such that X_N goes to 1, Y_N goes to +Inf and X_N
542 to the Y_N goes to any positive value when N goes to the infinity.
544 When the input point is in the closure of the domain of the
545 mathematical function and an input argument is +0 (resp. -0), one
546 considers the limit when the corresponding argument approaches 0 from
547 above (resp. below). If the limit is not defined (e.g., `mpfr_log' on
548 -0), the behavior is specified in the description of the MPFR function.
550 When the result is equal to 0, its sign is determined by considering
551 the limit as if the input point were not in the domain: If one
552 approaches 0 from above (resp. below), the result is +0 (resp. -0); for
553 example, `mpfr_sin' on +0 gives +0. In the other cases, the sign is
554 specified in the description of the MPFR function; for example
555 `mpfr_max' on -0 and +0 gives +0.
557 When the input point is not in the closure of the domain of the
558 function, the result is NaN. Example: `mpfr_sqrt' on -17 gives NaN.
560 When an input argument is NaN, the result is NaN, possibly except
561 when a partial function is constant on the finite floating-point
562 numbers; such a case is always explicitly specified in *note MPFR
563 Interface::. Example: `mpfr_hypot' on (NaN,0) gives NaN, but
564 `mpfr_hypot' on (NaN,+Inf) gives +Inf (as specified in *note Special
565 Functions::), since for any finite input X, `mpfr_hypot' on (X,+Inf)
571 MPFR supports 5 exception types:
573 * Underflow: An underflow occurs when the exact result of a function
574 is a non-zero real number and the result obtained after the
575 rounding, assuming an unbounded exponent range (for the rounding),
576 has an exponent smaller than the minimum value of the current
577 exponent range. (In the round-to-nearest mode, the halfway case is
578 rounded toward zero.)
580 Note: This is not the single possible definition of the underflow.
581 MPFR chooses to consider the underflow _after_ rounding. The
582 underflow before rounding can also be defined. For instance,
583 consider a function that has the exact result 7 multiplied by two
584 to the power E-4, where E is the smallest exponent (for a
585 significand between 1/2 and 1), with a 2-bit target precision and
586 rounding toward plus infinity. The exact result has the exponent
587 E-1. With the underflow before rounding, such a function call
588 would yield an underflow, as E-1 is outside the current exponent
589 range. However, MPFR first considers the rounded result assuming
590 an unbounded exponent range. The exact result cannot be
591 represented exactly in precision 2, and here, it is rounded to 0.5
592 times 2 to E, which is representable in the current exponent
593 range. As a consequence, this will not yield an underflow in MPFR.
595 * Overflow: An overflow occurs when the exact result of a function
596 is a non-zero real number and the result obtained after the
597 rounding, assuming an unbounded exponent range (for the rounding),
598 has an exponent larger than the maximum value of the current
599 exponent range. In the round-to-nearest mode, the result is
600 infinite. Note: unlike the underflow case, there is only one
601 possible definition of overflow here.
603 * NaN: A NaN exception occurs when the result of a function is NaN.
605 * Inexact: An inexact exception occurs when the result of a function
606 cannot be represented exactly and must be rounded.
608 * Range error: A range exception occurs when a function that does
609 not return a MPFR number (such as comparisons and conversions to
610 an integer) has an invalid result (e.g., an argument is NaN in
611 `mpfr_cmp', or a conversion to an integer cannot be represented in
615 MPFR has a global flag for each exception, which can be cleared, set
616 or tested by functions described in *note Exception Related Functions::.
618 Differences with the ISO C99 standard:
620 * In C, only quiet NaNs are specified, and a NaN propagation does not
621 raise an invalid exception. Unless explicitly stated otherwise,
622 MPFR sets the NaN flag whenever a NaN is generated, even when a
623 NaN is propagated (e.g., in NaN + NaN), as if all NaNs were
626 * An invalid exception in C corresponds to either a NaN exception or
627 a range error in MPFR.
633 MPFR functions may create caches, e.g., when computing constants such
634 as Pi, either because the user has called a function like
635 `mpfr_const_pi' directly or because such a function was called
636 internally by the MPFR library itself to compute some other function.
638 At any time, the user can free the various caches with
639 `mpfr_free_cache'. It is strongly advised to do that before terminating
640 a thread, or before exiting when using tools like `valgrind' (to avoid
641 memory leaks being reported).
643 MPFR internal data such as flags, the exponent range, the default
644 precision and rounding mode, and caches (i.e., data that are not
645 accessed via parameters) are either global (if MPFR has not been
646 compiled as thread safe) or per-thread (thread local storage).
649 File: mpfr.info, Node: MPFR Interface, Next: API Compatibility, Prev: MPFR Basics, Up: Top
654 The floating-point functions expect arguments of type `mpfr_t'.
656 The MPFR floating-point functions have an interface that is similar
657 to the GNU MP functions. The function prefix for floating-point
658 operations is `mpfr_'.
660 The user has to specify the precision of each variable. A
661 computation that assigns a variable will take place with the precision
662 of the assigned variable; the cost of that computation should not
663 depend on the precision of variables used as input (on average).
665 The semantics of a calculation in MPFR is specified as follows:
666 Compute the requested operation exactly (with "infinite accuracy"), and
667 round the result to the precision of the destination variable, with the
668 given rounding mode. The MPFR floating-point functions are intended to
669 be a smooth extension of the IEEE 754 arithmetic. The results obtained
670 on a given computer are identical to those obtained on a computer with
671 a different word size, or with a different compiler or operating system.
673 MPFR _does not keep track_ of the accuracy of a computation. This is
674 left to the user or to a higher layer (for example the MPFI library for
675 interval arithmetic). As a consequence, if two variables are used to
676 store only a few significant bits, and their product is stored in a
677 variable with large precision, then MPFR will still compute the result
680 The value of the standard C macro `errno' may be set to non-zero by
681 any MPFR function or macro, whether or not there is an error.
685 * Initialization Functions::
686 * Assignment Functions::
687 * Combined Initialization and Assignment Functions::
688 * Conversion Functions::
689 * Basic Arithmetic Functions::
690 * Comparison Functions::
691 * Special Functions::
692 * Input and Output Functions::
693 * Formatted Output Functions::
694 * Integer Related Functions::
695 * Rounding Related Functions::
696 * Miscellaneous Functions::
697 * Exception Related Functions::
698 * Compatibility with MPF::
703 File: mpfr.info, Node: Initialization Functions, Next: Assignment Functions, Prev: MPFR Interface, Up: MPFR Interface
705 5.1 Initialization Functions
706 ============================
708 An `mpfr_t' object must be initialized before storing the first value in
709 it. The functions `mpfr_init' and `mpfr_init2' are used for that
712 -- Function: void mpfr_init2 (mpfr_t X, mpfr_prec_t PREC)
713 Initialize X, set its precision to be *exactly* PREC bits and its
714 value to NaN. (Warning: the corresponding MPF function initializes
717 Normally, a variable should be initialized once only or at least
718 be cleared, using `mpfr_clear', between initializations. To
719 change the precision of a variable which has already been
720 initialized, use `mpfr_set_prec'. The precision PREC must be an
721 integer between `MPFR_PREC_MIN' and `MPFR_PREC_MAX' (otherwise the
722 behavior is undefined).
724 -- Function: void mpfr_inits2 (mpfr_prec_t PREC, mpfr_t X, ...)
725 Initialize all the `mpfr_t' variables of the given variable
726 argument `va_list', set their precision to be *exactly* PREC bits
727 and their value to NaN. See `mpfr_init2' for more details. The
728 `va_list' is assumed to be composed only of type `mpfr_t' (or
729 equivalently `mpfr_ptr'). It begins from X, and ends when it
730 encounters a null pointer (whose type must also be `mpfr_ptr').
732 -- Function: void mpfr_clear (mpfr_t X)
733 Free the space occupied by the significand of X. Make sure to
734 call this function for all `mpfr_t' variables when you are done
737 -- Function: void mpfr_clears (mpfr_t X, ...)
738 Free the space occupied by all the `mpfr_t' variables of the given
739 `va_list'. See `mpfr_clear' for more details. The `va_list' is
740 assumed to be composed only of type `mpfr_t' (or equivalently
741 `mpfr_ptr'). It begins from X, and ends when it encounters a null
742 pointer (whose type must also be `mpfr_ptr').
744 Here is an example of how to use multiple initialization functions
745 (since `NULL' is not necessarily defined in this context, we use
746 `(mpfr_ptr) 0' instead, but `(mpfr_ptr) NULL' is also correct).
750 mpfr_inits2 (256, x, y, z, t, (mpfr_ptr) 0);
752 mpfr_clears (x, y, z, t, (mpfr_ptr) 0);
755 -- Function: void mpfr_init (mpfr_t X)
756 Initialize X, set its precision to the default precision, and set
757 its value to NaN. The default precision can be changed by a call
758 to `mpfr_set_default_prec'.
760 Warning! In a given program, some other libraries might change the
761 default precision and not restore it. Thus it is safer to use
764 -- Function: void mpfr_inits (mpfr_t X, ...)
765 Initialize all the `mpfr_t' variables of the given `va_list', set
766 their precision to the default precision and their value to NaN.
767 See `mpfr_init' for more details. The `va_list' is assumed to be
768 composed only of type `mpfr_t' (or equivalently `mpfr_ptr'). It
769 begins from X, and ends when it encounters a null pointer (whose
770 type must also be `mpfr_ptr').
772 Warning! In a given program, some other libraries might change the
773 default precision and not restore it. Thus it is safer to use
776 -- Macro: MPFR_DECL_INIT (NAME, PREC)
777 This macro declares NAME as an automatic variable of type `mpfr_t',
778 initializes it and sets its precision to be *exactly* PREC bits
779 and its value to NaN. NAME must be a valid identifier. You must
780 use this macro in the declaration section. This macro is much
781 faster than using `mpfr_init2' but has some drawbacks:
783 * You *must not* call `mpfr_clear' with variables created with
784 this macro (the storage is allocated at the point of
785 declaration and deallocated when the brace-level is exited).
787 * You *cannot* change their precision.
789 * You *should not* create variables with huge precision with
792 * Your compiler must support `Non-Constant Initializers'
793 (standard in C++ and ISO C99) and `Token Pasting' (standard
794 in ISO C89). If PREC is not a constant expression, your
795 compiler must support `variable-length automatic arrays'
796 (standard in ISO C99). GCC 2.95.3 and above supports all
797 these features. If you compile your program with GCC in C89
798 mode and with `-pedantic', you may want to define the
799 `MPFR_USE_EXTENSION' macro to avoid warnings due to the
800 `MPFR_DECL_INIT' implementation.
802 -- Function: void mpfr_set_default_prec (mpfr_prec_t PREC)
803 Set the default precision to be *exactly* PREC bits, where PREC
804 can be any integer between `MPFR_PREC_MIN' and `MPFR_PREC_MAX'.
805 The precision of a variable means the number of bits used to store
806 its significand. All subsequent calls to `mpfr_init' or
807 `mpfr_inits' will use this precision, but previously initialized
808 variables are unaffected. The default precision is set to 53 bits
811 -- Function: mpfr_prec_t mpfr_get_default_prec (void)
812 Return the current default MPFR precision in bits.
814 Here is an example on how to initialize floating-point variables:
818 mpfr_init (x); /* use default precision */
819 mpfr_init2 (y, 256); /* precision _exactly_ 256 bits */
821 /* When the program is about to exit, do ... */
824 mpfr_free_cache (); /* free the cache for constants like pi */
827 The following functions are useful for changing the precision during
828 a calculation. A typical use would be for adjusting the precision
829 gradually in iterative algorithms like Newton-Raphson, making the
830 computation precision closely match the actual accurate part of the
833 -- Function: void mpfr_set_prec (mpfr_t X, mpfr_prec_t PREC)
834 Reset the precision of X to be *exactly* PREC bits, and set its
835 value to NaN. The previous value stored in X is lost. It is
836 equivalent to a call to `mpfr_clear(x)' followed by a call to
837 `mpfr_init2(x, prec)', but more efficient as no allocation is done
838 in case the current allocated space for the significand of X is
839 enough. The precision PREC can be any integer between
840 `MPFR_PREC_MIN' and `MPFR_PREC_MAX'. In case you want to keep the
841 previous value stored in X, use `mpfr_prec_round' instead.
843 -- Function: mpfr_prec_t mpfr_get_prec (mpfr_t X)
844 Return the precision of X, i.e., the number of bits used to store
848 File: mpfr.info, Node: Assignment Functions, Next: Combined Initialization and Assignment Functions, Prev: Initialization Functions, Up: MPFR Interface
850 5.2 Assignment Functions
851 ========================
853 These functions assign new values to already initialized floats (*note
854 Initialization Functions::).
856 -- Function: int mpfr_set (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
857 -- Function: int mpfr_set_ui (mpfr_t ROP, unsigned long int OP,
859 -- Function: int mpfr_set_si (mpfr_t ROP, long int OP, mpfr_rnd_t RND)
860 -- Function: int mpfr_set_uj (mpfr_t ROP, uintmax_t OP, mpfr_rnd_t RND)
861 -- Function: int mpfr_set_sj (mpfr_t ROP, intmax_t OP, mpfr_rnd_t RND)
862 -- Function: int mpfr_set_flt (mpfr_t ROP, float OP, mpfr_rnd_t RND)
863 -- Function: int mpfr_set_d (mpfr_t ROP, double OP, mpfr_rnd_t RND)
864 -- Function: int mpfr_set_ld (mpfr_t ROP, long double OP, mpfr_rnd_t
866 -- Function: int mpfr_set_decimal64 (mpfr_t ROP, _Decimal64 OP,
868 -- Function: int mpfr_set_z (mpfr_t ROP, mpz_t OP, mpfr_rnd_t RND)
869 -- Function: int mpfr_set_q (mpfr_t ROP, mpq_t OP, mpfr_rnd_t RND)
870 -- Function: int mpfr_set_f (mpfr_t ROP, mpf_t OP, mpfr_rnd_t RND)
871 Set the value of ROP from OP, rounded toward the given direction
872 RND. Note that the input 0 is converted to +0 by `mpfr_set_ui',
873 `mpfr_set_si', `mpfr_set_uj', `mpfr_set_sj', `mpfr_set_z',
874 `mpfr_set_q' and `mpfr_set_f', regardless of the rounding mode.
875 If the system does not support the IEEE 754 standard,
876 `mpfr_set_flt', `mpfr_set_d', `mpfr_set_ld' and
877 `mpfr_set_decimal64' might not preserve the signed zeros. The
878 `mpfr_set_decimal64' function is built only with the configure
879 option `--enable-decimal-float', which also requires
880 `--with-gmp-build', and when the compiler or system provides the
881 `_Decimal64' data type (recent versions of GCC support this data
882 type). `mpfr_set_q' might fail if the numerator (or the
883 denominator) can not be represented as a `mpfr_t'.
885 Note: If you want to store a floating-point constant to a `mpfr_t',
886 you should use `mpfr_set_str' (or one of the MPFR constant
887 functions, such as `mpfr_const_pi' for Pi) instead of
888 `mpfr_set_flt', `mpfr_set_d', `mpfr_set_ld' or
889 `mpfr_set_decimal64'. Otherwise the floating-point constant will
890 be first converted into a reduced-precision (e.g., 53-bit) binary
891 number before MPFR can work with it.
893 -- Function: int mpfr_set_ui_2exp (mpfr_t ROP, unsigned long int OP,
894 mpfr_exp_t E, mpfr_rnd_t RND)
895 -- Function: int mpfr_set_si_2exp (mpfr_t ROP, long int OP, mpfr_exp_t
897 -- Function: int mpfr_set_uj_2exp (mpfr_t ROP, uintmax_t OP, intmax_t
899 -- Function: int mpfr_set_sj_2exp (mpfr_t ROP, intmax_t OP, intmax_t
901 -- Function: int mpfr_set_z_2exp (mpfr_t ROP, mpz_t OP, mpfr_exp_t E,
903 Set the value of ROP from OP multiplied by two to the power E,
904 rounded toward the given direction RND. Note that the input 0 is
907 -- Function: int mpfr_set_str (mpfr_t ROP, const char *S, int BASE,
909 Set ROP to the value of the string S in base BASE, rounded in the
910 direction RND. See the documentation of `mpfr_strtofr' for a
911 detailed description of the valid string formats. Contrary to
912 `mpfr_strtofr', `mpfr_set_str' requires the _whole_ string to
913 represent a valid floating-point number. This function returns 0
914 if the entire string up to the final null character is a valid
915 number in base BASE; otherwise it returns -1, and ROP may have
916 changed. Note: it is preferable to use `mpfr_set_str' if one
917 wants to distinguish between an infinite ROP value coming from an
918 infinite S or from an overflow.
920 -- Function: int mpfr_strtofr (mpfr_t ROP, const char *NPTR, char
921 **ENDPTR, int BASE, mpfr_rnd_t RND)
922 Read a floating-point number from a string NPTR in base BASE,
923 rounded in the direction RND; BASE must be either 0 (to detect the
924 base, as described below) or a number from 2 to 62 (otherwise the
925 behavior is undefined). If NPTR starts with valid data, the result
926 is stored in ROP and `*ENDPTR' points to the character just after
927 the valid data (if ENDPTR is not a null pointer); otherwise ROP is
928 set to zero (for consistency with `strtod') and the value of NPTR
929 is stored in the location referenced by ENDPTR (if ENDPTR is not a
930 null pointer). The usual ternary value is returned.
932 Parsing follows the standard C `strtod' function with some
933 extensions. After optional leading whitespace, one has a subject
934 sequence consisting of an optional sign (`+' or `-'), and either
935 numeric data or special data. The subject sequence is defined as
936 the longest initial subsequence of the input string, starting with
937 the first non-whitespace character, that is of the expected form.
939 The form of numeric data is a non-empty sequence of significand
940 digits with an optional decimal point, and an optional exponent
941 consisting of an exponent prefix followed by an optional sign and
942 a non-empty sequence of decimal digits. A significand digit is
943 either a decimal digit or a Latin letter (62 possible characters),
944 with `A' = 10, `B' = 11, ..., `Z' = 35; case is ignored in bases
945 less or equal to 36, in bases larger than 36, `a' = 36, `b' = 37,
946 ..., `z' = 61. The value of a significand digit must be strictly
947 less than the base. The decimal point can be either the one
948 defined by the current locale or the period (the first one is
949 accepted for consistency with the C standard and the practice, the
950 second one is accepted to allow the programmer to provide MPFR
951 numbers from strings in a way that does not depend on the current
952 locale). The exponent prefix can be `e' or `E' for bases up to
953 10, or `@' in any base; it indicates a multiplication by a power
954 of the base. In bases 2 and 16, the exponent prefix can also be
955 `p' or `P', in which case the exponent, called _binary exponent_,
956 indicates a multiplication by a power of 2 instead of the base
957 (there is a difference only for base 16); in base 16 for example
958 `1p2' represents 4 whereas `1@2' represents 256. The value of an
959 exponent is always written in base 10.
961 If the argument BASE is 0, then the base is automatically detected
962 as follows. If the significand starts with `0b' or `0B', base 2 is
963 assumed. If the significand starts with `0x' or `0X', base 16 is
964 assumed. Otherwise base 10 is assumed.
966 Note: The exponent (if present) must contain at least a digit.
967 Otherwise the possible exponent prefix and sign are not part of
968 the number (which ends with the significand). Similarly, if `0b',
969 `0B', `0x' or `0X' is not followed by a binary/hexadecimal digit,
970 then the subject sequence stops at the character `0', thus 0 is
973 Special data (for infinities and NaN) can be `@inf@' or
974 `@nan@(n-char-sequence-opt)', and if BASE <= 16, it can also be
975 `infinity', `inf', `nan' or `nan(n-char-sequence-opt)', all case
976 insensitive. A `n-char-sequence-opt' is a possibly empty string
977 containing only digits, Latin letters and the underscore (0, 1, 2,
978 ..., 9, a, b, ..., z, A, B, ..., Z, _). Note: one has an optional
979 sign for all data, even NaN. For example,
980 `-@nAn@(This_Is_Not_17)' is a valid representation for NaN in base
984 -- Function: void mpfr_set_nan (mpfr_t X)
985 -- Function: void mpfr_set_inf (mpfr_t X, int SIGN)
986 -- Function: void mpfr_set_zero (mpfr_t X, int SIGN)
987 Set the variable X to NaN (Not-a-Number), infinity or zero
988 respectively. In `mpfr_set_inf' or `mpfr_set_zero', X is set to
989 plus infinity or plus zero iff SIGN is nonnegative; in
990 `mpfr_set_nan', the sign bit of the result is unspecified.
992 -- Function: void mpfr_swap (mpfr_t X, mpfr_t Y)
993 Swap the values X and Y efficiently. Warning: the precisions are
994 exchanged too; in case the precisions are different, `mpfr_swap'
995 is thus not equivalent to three `mpfr_set' calls using a third
999 File: mpfr.info, Node: Combined Initialization and Assignment Functions, Next: Conversion Functions, Prev: Assignment Functions, Up: MPFR Interface
1001 5.3 Combined Initialization and Assignment Functions
1002 ====================================================
1004 -- Macro: int mpfr_init_set (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1005 -- Macro: int mpfr_init_set_ui (mpfr_t ROP, unsigned long int OP,
1007 -- Macro: int mpfr_init_set_si (mpfr_t ROP, long int OP, mpfr_rnd_t
1009 -- Macro: int mpfr_init_set_d (mpfr_t ROP, double OP, mpfr_rnd_t RND)
1010 -- Macro: int mpfr_init_set_ld (mpfr_t ROP, long double OP, mpfr_rnd_t
1012 -- Macro: int mpfr_init_set_z (mpfr_t ROP, mpz_t OP, mpfr_rnd_t RND)
1013 -- Macro: int mpfr_init_set_q (mpfr_t ROP, mpq_t OP, mpfr_rnd_t RND)
1014 -- Macro: int mpfr_init_set_f (mpfr_t ROP, mpf_t OP, mpfr_rnd_t RND)
1015 Initialize ROP and set its value from OP, rounded in the direction
1016 RND. The precision of ROP will be taken from the active default
1017 precision, as set by `mpfr_set_default_prec'.
1019 -- Function: int mpfr_init_set_str (mpfr_t X, const char *S, int BASE,
1021 Initialize X and set its value from the string S in base BASE,
1022 rounded in the direction RND. See `mpfr_set_str'.
1025 File: mpfr.info, Node: Conversion Functions, Next: Basic Arithmetic Functions, Prev: Combined Initialization and Assignment Functions, Up: MPFR Interface
1027 5.4 Conversion Functions
1028 ========================
1030 -- Function: float mpfr_get_flt (mpfr_t OP, mpfr_rnd_t RND)
1031 -- Function: double mpfr_get_d (mpfr_t OP, mpfr_rnd_t RND)
1032 -- Function: long double mpfr_get_ld (mpfr_t OP, mpfr_rnd_t RND)
1033 -- Function: _Decimal64 mpfr_get_decimal64 (mpfr_t OP, mpfr_rnd_t RND)
1034 Convert OP to a `float' (respectively `double', `long double' or
1035 `_Decimal64'), using the rounding mode RND. If OP is NaN, some
1036 fixed NaN (either quiet or signaling) or the result of 0.0/0.0 is
1037 returned. If OP is ±Inf, an infinity of the same sign or the
1038 result of ±1.0/0.0 is returned. If OP is zero, these functions
1039 return a zero, trying to preserve its sign, if possible. The
1040 `mpfr_get_decimal64' function is built only under some conditions:
1041 see the documentation of `mpfr_set_decimal64'.
1043 -- Function: long mpfr_get_si (mpfr_t OP, mpfr_rnd_t RND)
1044 -- Function: unsigned long mpfr_get_ui (mpfr_t OP, mpfr_rnd_t RND)
1045 -- Function: intmax_t mpfr_get_sj (mpfr_t OP, mpfr_rnd_t RND)
1046 -- Function: uintmax_t mpfr_get_uj (mpfr_t OP, mpfr_rnd_t RND)
1047 Convert OP to a `long', an `unsigned long', an `intmax_t' or an
1048 `uintmax_t' (respectively) after rounding it with respect to RND.
1049 If OP is NaN, 0 is returned and the _erange_ flag is set. If OP
1050 is too big for the return type, the function returns the maximum
1051 or the minimum of the corresponding C type, depending on the
1052 direction of the overflow; the _erange_ flag is set too. See also
1053 `mpfr_fits_slong_p', `mpfr_fits_ulong_p', `mpfr_fits_intmax_p' and
1054 `mpfr_fits_uintmax_p'.
1056 -- Function: double mpfr_get_d_2exp (long *EXP, mpfr_t OP, mpfr_rnd_t
1058 -- Function: long double mpfr_get_ld_2exp (long *EXP, mpfr_t OP,
1060 Return D and set EXP (formally, the value pointed to by EXP) such
1061 that 0.5<=abs(D)<1 and D times 2 raised to EXP equals OP rounded
1062 to double (resp. long double) precision, using the given rounding
1063 mode. If OP is zero, then a zero of the same sign (or an unsigned
1064 zero, if the implementation does not have signed zeros) is
1065 returned, and EXP is set to 0. If OP is NaN or an infinity, then
1066 the corresponding double precision (resp. long-double precision)
1067 value is returned, and EXP is undefined.
1069 -- Function: mpfr_exp_t mpfr_get_z_2exp (mpz_t ROP, mpfr_t OP)
1070 Put the scaled significand of OP (regarded as an integer, with the
1071 precision of OP) into ROP, and return the exponent EXP (which may
1072 be outside the current exponent range) such that OP exactly equals
1073 ROP times 2 raised to the power EXP. If OP is zero, the minimal
1074 exponent `emin' is returned. If OP is NaN or an infinity, the
1075 _erange_ flag is set, ROP is set to 0, and the the minimal
1076 exponent `emin' is returned. The returned exponent may be less
1077 than the minimal exponent `emin' of MPFR numbers in the current
1078 exponent range; in case the exponent is not representable in the
1079 `mpfr_exp_t' type, the _erange_ flag is set and the minimal value
1080 of the `mpfr_exp_t' type is returned.
1082 -- Function: int mpfr_get_z (mpz_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1083 Convert OP to a `mpz_t', after rounding it with respect to RND. If
1084 OP is NaN or an infinity, the _erange_ flag is set, ROP is set to
1085 0, and 0 is returned.
1087 -- Function: int mpfr_get_f (mpf_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1088 Convert OP to a `mpf_t', after rounding it with respect to RND.
1089 The _erange_ flag is set if OP is NaN or Inf, which do not exist in
1092 -- Function: char * mpfr_get_str (char *STR, mpfr_exp_t *EXPPTR, int
1093 B, size_t N, mpfr_t OP, mpfr_rnd_t RND)
1094 Convert OP to a string of digits in base B, with rounding in the
1095 direction RND, where N is either zero (see below) or the number of
1096 significant digits output in the string; in the latter case, N
1097 must be greater or equal to 2. The base may vary from 2 to 62. If
1098 the input number is an ordinary number, the exponent is written
1099 through the pointer EXPPTR (for input 0, the current minimal
1100 exponent is written).
1102 The generated string is a fraction, with an implicit radix point
1103 immediately to the left of the first digit. For example, the
1104 number -3.1416 would be returned as "-31416" in the string and 1
1105 written at EXPPTR. If RND is to nearest, and OP is exactly in the
1106 middle of two consecutive possible outputs, the one with an even
1107 significand is chosen, where both significands are considered with
1108 the exponent of OP. Note that for an odd base, this may not
1109 correspond to an even last digit: for example with 2 digits in
1110 base 7, (14) and a half is rounded to (15) which is 12 in decimal,
1111 (16) and a half is rounded to (20) which is 14 in decimal, and
1112 (26) and a half is rounded to (26) which is 20 in decimal.
1114 If N is zero, the number of digits of the significand is chosen
1115 large enough so that re-reading the printed value with the same
1116 precision, assuming both output and input use rounding to nearest,
1117 will recover the original value of OP. More precisely, in most
1118 cases, the chosen precision of STR is the minimal precision m
1119 depending only on P = PREC(OP) and B that satisfies the above
1120 property, i.e., m = 1 + ceil(P*log(2)/log(B)), with P replaced by
1121 P-1 if B is a power of 2, but in some very rare cases, it might be
1122 m+1 (the smallest case for bases up to 62 is when P equals
1123 186564318007 for bases 7 and 49).
1125 If STR is a null pointer, space for the significand is allocated
1126 using the current allocation function, and a pointer to the string
1127 is returned. To free the returned string, you must use
1130 If STR is not a null pointer, it should point to a block of storage
1131 large enough for the significand, i.e., at least `max(N + 2, 7)'.
1132 The extra two bytes are for a possible minus sign, and for the
1133 terminating null character, and the value 7 accounts for `-@Inf@'
1134 plus the terminating null character.
1136 A pointer to the string is returned, unless there is an error, in
1137 which case a null pointer is returned.
1139 -- Function: void mpfr_free_str (char *STR)
1140 Free a string allocated by `mpfr_get_str' using the current
1141 unallocation function. The block is assumed to be `strlen(STR)+1'
1142 bytes. For more information about how it is done: *note Custom
1143 Allocation: (gmp.info)Custom Allocation.
1145 -- Function: int mpfr_fits_ulong_p (mpfr_t OP, mpfr_rnd_t RND)
1146 -- Function: int mpfr_fits_slong_p (mpfr_t OP, mpfr_rnd_t RND)
1147 -- Function: int mpfr_fits_uint_p (mpfr_t OP, mpfr_rnd_t RND)
1148 -- Function: int mpfr_fits_sint_p (mpfr_t OP, mpfr_rnd_t RND)
1149 -- Function: int mpfr_fits_ushort_p (mpfr_t OP, mpfr_rnd_t RND)
1150 -- Function: int mpfr_fits_sshort_p (mpfr_t OP, mpfr_rnd_t RND)
1151 -- Function: int mpfr_fits_uintmax_p (mpfr_t OP, mpfr_rnd_t RND)
1152 -- Function: int mpfr_fits_intmax_p (mpfr_t OP, mpfr_rnd_t RND)
1153 Return non-zero if OP would fit in the respective C data type,
1154 respectively `unsigned long', `long', `unsigned int', `int',
1155 `unsigned short', `short', `uintmax_t', `intmax_t', when rounded
1156 to an integer in the direction RND.
1159 File: mpfr.info, Node: Basic Arithmetic Functions, Next: Comparison Functions, Prev: Conversion Functions, Up: MPFR Interface
1161 5.5 Basic Arithmetic Functions
1162 ==============================
1164 -- Function: int mpfr_add (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2,
1166 -- Function: int mpfr_add_ui (mpfr_t ROP, mpfr_t OP1, unsigned long
1167 int OP2, mpfr_rnd_t RND)
1168 -- Function: int mpfr_add_si (mpfr_t ROP, mpfr_t OP1, long int OP2,
1170 -- Function: int mpfr_add_d (mpfr_t ROP, mpfr_t OP1, double OP2,
1172 -- Function: int mpfr_add_z (mpfr_t ROP, mpfr_t OP1, mpz_t OP2,
1174 -- Function: int mpfr_add_q (mpfr_t ROP, mpfr_t OP1, mpq_t OP2,
1176 Set ROP to OP1 + OP2 rounded in the direction RND. For types
1177 having no signed zero, it is considered unsigned (i.e., (+0) + 0 =
1178 (+0) and (-0) + 0 = (-0)). The `mpfr_add_d' function assumes that
1179 the radix of the `double' type is a power of 2, with a precision
1180 at most that declared by the C implementation (macro
1181 `IEEE_DBL_MANT_DIG', and if not defined 53 bits).
1183 -- Function: int mpfr_sub (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2,
1185 -- Function: int mpfr_ui_sub (mpfr_t ROP, unsigned long int OP1,
1186 mpfr_t OP2, mpfr_rnd_t RND)
1187 -- Function: int mpfr_sub_ui (mpfr_t ROP, mpfr_t OP1, unsigned long
1188 int OP2, mpfr_rnd_t RND)
1189 -- Function: int mpfr_si_sub (mpfr_t ROP, long int OP1, mpfr_t OP2,
1191 -- Function: int mpfr_sub_si (mpfr_t ROP, mpfr_t OP1, long int OP2,
1193 -- Function: int mpfr_d_sub (mpfr_t ROP, double OP1, mpfr_t OP2,
1195 -- Function: int mpfr_sub_d (mpfr_t ROP, mpfr_t OP1, double OP2,
1197 -- Function: int mpfr_sub_z (mpfr_t ROP, mpfr_t OP1, mpz_t OP2,
1199 -- Function: int mpfr_sub_q (mpfr_t ROP, mpfr_t OP1, mpq_t OP2,
1201 Set ROP to OP1 - OP2 rounded in the direction RND. For types
1202 having no signed zero, it is considered unsigned (i.e., (+0) - 0 =
1203 (+0), (-0) - 0 = (-0), 0 - (+0) = (-0) and 0 - (-0) = (+0)). The
1204 same restrictions than for `mpfr_add_d' apply to `mpfr_d_sub' and
1207 -- Function: int mpfr_mul (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2,
1209 -- Function: int mpfr_mul_ui (mpfr_t ROP, mpfr_t OP1, unsigned long
1210 int OP2, mpfr_rnd_t RND)
1211 -- Function: int mpfr_mul_si (mpfr_t ROP, mpfr_t OP1, long int OP2,
1213 -- Function: int mpfr_mul_d (mpfr_t ROP, mpfr_t OP1, double OP2,
1215 -- Function: int mpfr_mul_z (mpfr_t ROP, mpfr_t OP1, mpz_t OP2,
1217 -- Function: int mpfr_mul_q (mpfr_t ROP, mpfr_t OP1, mpq_t OP2,
1219 Set ROP to OP1 times OP2 rounded in the direction RND. When a
1220 result is zero, its sign is the product of the signs of the
1221 operands (for types having no signed zero, it is considered
1222 positive). The same restrictions than for `mpfr_add_d' apply to
1225 -- Function: int mpfr_sqr (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1226 Set ROP to the square of OP rounded in the direction RND.
1228 -- Function: int mpfr_div (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2,
1230 -- Function: int mpfr_ui_div (mpfr_t ROP, unsigned long int OP1,
1231 mpfr_t OP2, mpfr_rnd_t RND)
1232 -- Function: int mpfr_div_ui (mpfr_t ROP, mpfr_t OP1, unsigned long
1233 int OP2, mpfr_rnd_t RND)
1234 -- Function: int mpfr_si_div (mpfr_t ROP, long int OP1, mpfr_t OP2,
1236 -- Function: int mpfr_div_si (mpfr_t ROP, mpfr_t OP1, long int OP2,
1238 -- Function: int mpfr_d_div (mpfr_t ROP, double OP1, mpfr_t OP2,
1240 -- Function: int mpfr_div_d (mpfr_t ROP, mpfr_t OP1, double OP2,
1242 -- Function: int mpfr_div_z (mpfr_t ROP, mpfr_t OP1, mpz_t OP2,
1244 -- Function: int mpfr_div_q (mpfr_t ROP, mpfr_t OP1, mpq_t OP2,
1246 Set ROP to OP1/OP2 rounded in the direction RND. When a result is
1247 zero, its sign is the product of the signs of the operands (for
1248 types having no signed zero, it is considered positive). The same
1249 restrictions than for `mpfr_add_d' apply to `mpfr_d_div' and
1252 -- Function: int mpfr_sqrt (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1253 -- Function: int mpfr_sqrt_ui (mpfr_t ROP, unsigned long int OP,
1255 Set ROP to the square root of OP rounded in the direction RND (set
1256 ROP to -0 if OP is -0, to be consistent with the IEEE 754
1257 standard). Set ROP to NaN if OP is negative.
1259 -- Function: int mpfr_rec_sqrt (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1260 Set ROP to the reciprocal square root of OP rounded in the
1261 direction RND. Set ROP to +Inf if OP is ±0, +0 if OP is +Inf, and
1262 NaN if OP is negative.
1264 -- Function: int mpfr_cbrt (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1265 -- Function: int mpfr_root (mpfr_t ROP, mpfr_t OP, unsigned long int
1267 Set ROP to the cubic root (resp. the Kth root) of OP rounded in
1268 the direction RND. For K odd (resp. even) and OP negative
1269 (including -Inf), set ROP to a negative number (resp. NaN). The
1270 Kth root of -0 is defined to be -0, whatever the parity of K.
1272 -- Function: int mpfr_pow (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2,
1274 -- Function: int mpfr_pow_ui (mpfr_t ROP, mpfr_t OP1, unsigned long
1275 int OP2, mpfr_rnd_t RND)
1276 -- Function: int mpfr_pow_si (mpfr_t ROP, mpfr_t OP1, long int OP2,
1278 -- Function: int mpfr_pow_z (mpfr_t ROP, mpfr_t OP1, mpz_t OP2,
1280 -- Function: int mpfr_ui_pow_ui (mpfr_t ROP, unsigned long int OP1,
1281 unsigned long int OP2, mpfr_rnd_t RND)
1282 -- Function: int mpfr_ui_pow (mpfr_t ROP, unsigned long int OP1,
1283 mpfr_t OP2, mpfr_rnd_t RND)
1284 Set ROP to OP1 raised to OP2, rounded in the direction RND.
1285 Special values are handled as described in the ISO C99 and IEEE
1286 754-2008 standards for the `pow' function:
1287 * `pow(±0, Y)' returns plus or minus infinity for Y a negative
1290 * `pow(±0, Y)' returns plus infinity for Y negative and not an
1293 * `pow(±0, Y)' returns plus or minus zero for Y a positive odd
1296 * `pow(±0, Y)' returns plus zero for Y positive and not an odd
1299 * `pow(-1, ±Inf)' returns 1.
1301 * `pow(+1, Y)' returns 1 for any Y, even a NaN.
1303 * `pow(X, ±0)' returns 1 for any X, even a NaN.
1305 * `pow(X, Y)' returns NaN for finite negative X and finite
1308 * `pow(X, -Inf)' returns plus infinity for 0 < abs(x) < 1, and
1309 plus zero for abs(x) > 1.
1311 * `pow(X, +Inf)' returns plus zero for 0 < abs(x) < 1, and plus
1312 infinity for abs(x) > 1.
1314 * `pow(-Inf, Y)' returns minus zero for Y a negative odd
1317 * `pow(-Inf, Y)' returns plus zero for Y negative and not an
1320 * `pow(-Inf, Y)' returns minus infinity for Y a positive odd
1323 * `pow(-Inf, Y)' returns plus infinity for Y positive and not
1326 * `pow(+Inf, Y)' returns plus zero for Y negative, and plus
1327 infinity for Y positive.
1329 -- Function: int mpfr_neg (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1330 -- Function: int mpfr_abs (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1331 Set ROP to -OP and the absolute value of OP respectively, rounded
1332 in the direction RND. Just changes or adjusts the sign if ROP and
1333 OP are the same variable, otherwise a rounding might occur if the
1334 precision of ROP is less than that of OP.
1336 -- Function: int mpfr_dim (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2,
1338 Set ROP to the positive difference of OP1 and OP2, i.e., OP1 - OP2
1339 rounded in the direction RND if OP1 > OP2, +0 if OP1 <= OP2, and
1340 NaN if OP1 or OP2 is NaN.
1342 -- Function: int mpfr_mul_2ui (mpfr_t ROP, mpfr_t OP1, unsigned long
1343 int OP2, mpfr_rnd_t RND)
1344 -- Function: int mpfr_mul_2si (mpfr_t ROP, mpfr_t OP1, long int OP2,
1346 Set ROP to OP1 times 2 raised to OP2 rounded in the direction RND.
1347 Just increases the exponent by OP2 when ROP and OP1 are identical.
1349 -- Function: int mpfr_div_2ui (mpfr_t ROP, mpfr_t OP1, unsigned long
1350 int OP2, mpfr_rnd_t RND)
1351 -- Function: int mpfr_div_2si (mpfr_t ROP, mpfr_t OP1, long int OP2,
1353 Set ROP to OP1 divided by 2 raised to OP2 rounded in the direction
1354 RND. Just decreases the exponent by OP2 when ROP and OP1 are
1358 File: mpfr.info, Node: Comparison Functions, Next: Special Functions, Prev: Basic Arithmetic Functions, Up: MPFR Interface
1360 5.6 Comparison Functions
1361 ========================
1363 -- Function: int mpfr_cmp (mpfr_t OP1, mpfr_t OP2)
1364 -- Function: int mpfr_cmp_ui (mpfr_t OP1, unsigned long int OP2)
1365 -- Function: int mpfr_cmp_si (mpfr_t OP1, long int OP2)
1366 -- Function: int mpfr_cmp_d (mpfr_t OP1, double OP2)
1367 -- Function: int mpfr_cmp_ld (mpfr_t OP1, long double OP2)
1368 -- Function: int mpfr_cmp_z (mpfr_t OP1, mpz_t OP2)
1369 -- Function: int mpfr_cmp_q (mpfr_t OP1, mpq_t OP2)
1370 -- Function: int mpfr_cmp_f (mpfr_t OP1, mpf_t OP2)
1371 Compare OP1 and OP2. Return a positive value if OP1 > OP2, zero
1372 if OP1 = OP2, and a negative value if OP1 < OP2. Both OP1 and OP2
1373 are considered to their full own precision, which may differ. If
1374 one of the operands is NaN, set the _erange_ flag and return zero.
1376 Note: These functions may be useful to distinguish the three
1377 possible cases. If you need to distinguish two cases only, it is
1378 recommended to use the predicate functions (e.g., `mpfr_equal_p'
1379 for the equality) described below; they behave like the IEEE 754
1380 comparisons, in particular when one or both arguments are NaN. But
1381 only floating-point numbers can be compared (you may need to do a
1384 -- Function: int mpfr_cmp_ui_2exp (mpfr_t OP1, unsigned long int OP2,
1386 -- Function: int mpfr_cmp_si_2exp (mpfr_t OP1, long int OP2,
1388 Compare OP1 and OP2 multiplied by two to the power E. Similar as
1391 -- Function: int mpfr_cmpabs (mpfr_t OP1, mpfr_t OP2)
1392 Compare |OP1| and |OP2|. Return a positive value if |OP1| >
1393 |OP2|, zero if |OP1| = |OP2|, and a negative value if |OP1| <
1394 |OP2|. If one of the operands is NaN, set the _erange_ flag and
1397 -- Function: int mpfr_nan_p (mpfr_t OP)
1398 -- Function: int mpfr_inf_p (mpfr_t OP)
1399 -- Function: int mpfr_number_p (mpfr_t OP)
1400 -- Function: int mpfr_zero_p (mpfr_t OP)
1401 -- Function: int mpfr_regular_p (mpfr_t OP)
1402 Return non-zero if OP is respectively NaN, an infinity, an ordinary
1403 number (i.e., neither NaN nor an infinity), zero, or a regular
1404 number (i.e., neither NaN, nor an infinity nor zero). Return zero
1407 -- Macro: int mpfr_sgn (mpfr_t OP)
1408 Return a positive value if OP > 0, zero if OP = 0, and a negative
1409 value if OP < 0. If the operand is NaN, set the _erange_ flag and
1410 return zero. This is equivalent to `mpfr_cmp_ui (op, 0)', but
1413 -- Function: int mpfr_greater_p (mpfr_t OP1, mpfr_t OP2)
1414 -- Function: int mpfr_greaterequal_p (mpfr_t OP1, mpfr_t OP2)
1415 -- Function: int mpfr_less_p (mpfr_t OP1, mpfr_t OP2)
1416 -- Function: int mpfr_lessequal_p (mpfr_t OP1, mpfr_t OP2)
1417 -- Function: int mpfr_equal_p (mpfr_t OP1, mpfr_t OP2)
1418 Return non-zero if OP1 > OP2, OP1 >= OP2, OP1 < OP2, OP1 <= OP2,
1419 OP1 = OP2 respectively, and zero otherwise. Those functions
1420 return zero whenever OP1 and/or OP2 is NaN.
1422 -- Function: int mpfr_lessgreater_p (mpfr_t OP1, mpfr_t OP2)
1423 Return non-zero if OP1 < OP2 or OP1 > OP2 (i.e., neither OP1, nor
1424 OP2 is NaN, and OP1 <> OP2), zero otherwise (i.e., OP1 and/or OP2
1425 is NaN, or OP1 = OP2).
1427 -- Function: int mpfr_unordered_p (mpfr_t OP1, mpfr_t OP2)
1428 Return non-zero if OP1 or OP2 is a NaN (i.e., they cannot be
1429 compared), zero otherwise.
1432 File: mpfr.info, Node: Special Functions, Next: Input and Output Functions, Prev: Comparison Functions, Up: MPFR Interface
1434 5.7 Special Functions
1435 =====================
1437 All those functions, except explicitly stated (for example
1438 `mpfr_sin_cos'), return a ternary value as defined in Section "Rounding
1439 Modes", i.e., zero for an exact return value, a positive value for a
1440 return value larger than the exact result, and a negative value
1443 Important note: in some domains, computing special functions (either
1444 with correct or incorrect rounding) is expensive, even for small
1445 precision, for example the trigonometric and Bessel functions for large
1448 -- Function: int mpfr_log (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1449 -- Function: int mpfr_log2 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1450 -- Function: int mpfr_log10 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1451 Set ROP to the natural logarithm of OP, log2(OP) or log10(OP),
1452 respectively, rounded in the direction RND. Set ROP to -Inf if OP
1453 is -0 (i.e., the sign of the zero has no influence on the result).
1455 -- Function: int mpfr_exp (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1456 -- Function: int mpfr_exp2 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1457 -- Function: int mpfr_exp10 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1458 Set ROP to the exponential of OP, to 2 power of OP or to 10 power
1459 of OP, respectively, rounded in the direction RND.
1461 -- Function: int mpfr_cos (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1462 -- Function: int mpfr_sin (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1463 -- Function: int mpfr_tan (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1464 Set ROP to the cosine of OP, sine of OP, tangent of OP, rounded in
1467 -- Function: int mpfr_sin_cos (mpfr_t SOP, mpfr_t COP, mpfr_t OP,
1469 Set simultaneously SOP to the sine of OP and COP to the cosine of
1470 OP, rounded in the direction RND with the corresponding precisions
1471 of SOP and COP, which must be different variables. Return 0 iff
1472 both results are exact, more precisely it returns s+4c where s=0
1473 if SOP is exact, s=1 if SOP is larger than the sine of OP, s=2 if
1474 SOP is smaller than the sine of OP, and similarly for c and the
1477 -- Function: int mpfr_sec (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1478 -- Function: int mpfr_csc (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1479 -- Function: int mpfr_cot (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1480 Set ROP to the secant of OP, cosecant of OP, cotangent of OP,
1481 rounded in the direction RND.
1483 -- Function: int mpfr_acos (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1484 -- Function: int mpfr_asin (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1485 -- Function: int mpfr_atan (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1486 Set ROP to the arc-cosine, arc-sine or arc-tangent of OP, rounded
1487 in the direction RND. Note that since `acos(-1)' returns the
1488 floating-point number closest to Pi according to the given
1489 rounding mode, this number might not be in the output range 0 <=
1490 ROP < \pi of the arc-cosine function; still, the result lies in
1491 the image of the output range by the rounding function. The same
1492 holds for `asin(-1)', `asin(1)', `atan(-Inf)', `atan(+Inf)' or for
1493 `atan(op)' with large OP and small precision of ROP.
1495 -- Function: int mpfr_atan2 (mpfr_t ROP, mpfr_t Y, mpfr_t X,
1497 Set ROP to the arc-tangent2 of Y and X, rounded in the direction
1498 RND: if `x > 0', `atan2(y, x) = atan (y/x)'; if `x < 0', `atan2(y,
1499 x) = sign(y)*(Pi - atan (abs(y/x)))', thus a number from -Pi to Pi.
1500 As for `atan', in case the exact mathematical result is +Pi or -Pi,
1501 its rounded result might be outside the function output range.
1503 `atan2(y, 0)' does not raise any floating-point exception.
1504 Special values are handled as described in the ISO C99 and IEEE
1505 754-2008 standards for the `atan2' function:
1506 * `atan2(+0, -0)' returns +Pi.
1508 * `atan2(-0, -0)' returns -Pi.
1510 * `atan2(+0, +0)' returns +0.
1512 * `atan2(-0, +0)' returns -0.
1514 * `atan2(+0, x)' returns +Pi for x < 0.
1516 * `atan2(-0, x)' returns -Pi for x < 0.
1518 * `atan2(+0, x)' returns +0 for x > 0.
1520 * `atan2(-0, x)' returns -0 for x > 0.
1522 * `atan2(y, 0)' returns -Pi/2 for y < 0.
1524 * `atan2(y, 0)' returns +Pi/2 for y > 0.
1526 * `atan2(+Inf, -Inf)' returns +3*Pi/4.
1528 * `atan2(-Inf, -Inf)' returns -3*Pi/4.
1530 * `atan2(+Inf, +Inf)' returns +Pi/4.
1532 * `atan2(-Inf, +Inf)' returns -Pi/4.
1534 * `atan2(+Inf, x)' returns +Pi/2 for finite x.
1536 * `atan2(-Inf, x)' returns -Pi/2 for finite x.
1538 * `atan2(y, -Inf)' returns +Pi for finite y > 0.
1540 * `atan2(y, -Inf)' returns -Pi for finite y < 0.
1542 * `atan2(y, +Inf)' returns +0 for finite y > 0.
1544 * `atan2(y, +Inf)' returns -0 for finite y < 0.
1546 -- Function: int mpfr_cosh (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1547 -- Function: int mpfr_sinh (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1548 -- Function: int mpfr_tanh (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1549 Set ROP to the hyperbolic cosine, sine or tangent of OP, rounded
1550 in the direction RND.
1552 -- Function: int mpfr_sinh_cosh (mpfr_t SOP, mpfr_t COP, mpfr_t OP,
1554 Set simultaneously SOP to the hyperbolic sine of OP and COP to the
1555 hyperbolic cosine of OP, rounded in the direction RND with the
1556 corresponding precision of SOP and COP, which must be different
1557 variables. Return 0 iff both results are exact (see
1558 `mpfr_sin_cos' for a more detailed description of the return
1561 -- Function: int mpfr_sech (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1562 -- Function: int mpfr_csch (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1563 -- Function: int mpfr_coth (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1564 Set ROP to the hyperbolic secant of OP, cosecant of OP, cotangent
1565 of OP, rounded in the direction RND.
1567 -- Function: int mpfr_acosh (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1568 -- Function: int mpfr_asinh (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1569 -- Function: int mpfr_atanh (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1570 Set ROP to the inverse hyperbolic cosine, sine or tangent of OP,
1571 rounded in the direction RND.
1573 -- Function: int mpfr_fac_ui (mpfr_t ROP, unsigned long int OP,
1575 Set ROP to the factorial of OP, rounded in the direction RND.
1577 -- Function: int mpfr_log1p (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1578 Set ROP to the logarithm of one plus OP, rounded in the direction
1581 -- Function: int mpfr_expm1 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1582 Set ROP to the exponential of OP followed by a subtraction by one,
1583 rounded in the direction RND.
1585 -- Function: int mpfr_eint (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1586 Set ROP to the exponential integral of OP, rounded in the
1587 direction RND. For positive OP, the exponential integral is the
1588 sum of Euler's constant, of the logarithm of OP, and of the sum
1589 for k from 1 to infinity of OP to the power k, divided by k and
1590 factorial(k). For negative OP, ROP is set to NaN.
1592 -- Function: int mpfr_li2 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1593 Set ROP to real part of the dilogarithm of OP, rounded in the
1594 direction RND. MPFR defines the dilogarithm function as the
1595 integral of -log(1-t)/t from 0 to OP.
1597 -- Function: int mpfr_gamma (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1598 Set ROP to the value of the Gamma function on OP, rounded in the
1599 direction RND. When OP is a negative integer, ROP is set to NaN.
1601 -- Function: int mpfr_lngamma (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1602 Set ROP to the value of the logarithm of the Gamma function on OP,
1603 rounded in the direction RND. When -2K-1 <= OP <= -2K, K being a
1604 non-negative integer, ROP is set to NaN. See also `mpfr_lgamma'.
1606 -- Function: int mpfr_lgamma (mpfr_t ROP, int *SIGNP, mpfr_t OP,
1608 Set ROP to the value of the logarithm of the absolute value of the
1609 Gamma function on OP, rounded in the direction RND. The sign (1 or
1610 -1) of Gamma(OP) is returned in the object pointed to by SIGNP.
1611 When OP is an infinity or a non-positive integer, set ROP to +Inf.
1612 When OP is NaN, -Inf or a negative integer, *SIGNP is undefined,
1613 and when OP is ±0, *SIGNP is the sign of the zero.
1615 -- Function: int mpfr_digamma (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1616 Set ROP to the value of the Digamma (sometimes also called Psi)
1617 function on OP, rounded in the direction RND. When OP is a
1618 negative integer, set ROP to NaN.
1620 -- Function: int mpfr_zeta (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1621 -- Function: int mpfr_zeta_ui (mpfr_t ROP, unsigned long OP,
1623 Set ROP to the value of the Riemann Zeta function on OP, rounded
1624 in the direction RND.
1626 -- Function: int mpfr_erf (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1627 -- Function: int mpfr_erfc (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1628 Set ROP to the value of the error function on OP (resp. the
1629 complementary error function on OP) rounded in the direction RND.
1631 -- Function: int mpfr_j0 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1632 -- Function: int mpfr_j1 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1633 -- Function: int mpfr_jn (mpfr_t ROP, long N, mpfr_t OP, mpfr_rnd_t
1635 Set ROP to the value of the first kind Bessel function of order 0,
1636 (resp. 1 and N) on OP, rounded in the direction RND. When OP is
1637 NaN, ROP is always set to NaN. When OP is plus or minus Infinity,
1638 ROP is set to +0. When OP is zero, and N is not zero, ROP is set
1639 to +0 or -0 depending on the parity and sign of N, and the sign of
1642 -- Function: int mpfr_y0 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1643 -- Function: int mpfr_y1 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1644 -- Function: int mpfr_yn (mpfr_t ROP, long N, mpfr_t OP, mpfr_rnd_t
1646 Set ROP to the value of the second kind Bessel function of order 0
1647 (resp. 1 and N) on OP, rounded in the direction RND. When OP is
1648 NaN or negative, ROP is always set to NaN. When OP is +Inf, ROP is
1649 set to +0. When OP is zero, ROP is set to +Inf or -Inf depending
1650 on the parity and sign of N.
1652 -- Function: int mpfr_fma (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, mpfr_t
1653 OP3, mpfr_rnd_t RND)
1654 -- Function: int mpfr_fms (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, mpfr_t
1655 OP3, mpfr_rnd_t RND)
1656 Set ROP to (OP1 times OP2) + OP3 (resp. (OP1 times OP2) - OP3)
1657 rounded in the direction RND.
1659 -- Function: int mpfr_agm (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2,
1661 Set ROP to the arithmetic-geometric mean of OP1 and OP2, rounded
1662 in the direction RND. The arithmetic-geometric mean is the common
1663 limit of the sequences U_N and V_N, where U_0=OP1, V_0=OP2,
1664 U_(N+1) is the arithmetic mean of U_N and V_N, and V_(N+1) is the
1665 geometric mean of U_N and V_N. If any operand is negative, set
1668 -- Function: int mpfr_hypot (mpfr_t ROP, mpfr_t X, mpfr_t Y,
1670 Set ROP to the Euclidean norm of X and Y, i.e., the square root of
1671 the sum of the squares of X and Y, rounded in the direction RND.
1672 Special values are handled as described in Section F.9.4.3 of the
1673 ISO C99 and IEEE 754-2008 standards: If X or Y is an infinity,
1674 then +Inf is returned in ROP, even if the other number is NaN.
1676 -- Function: int mpfr_ai (mpfr_t ROP, mpfr_t X, mpfr_rnd_t RND)
1677 Set ROP to the value of the Airy function Ai on X, rounded in the
1678 direction RND. When X is NaN, ROP is always set to NaN. When X is
1679 +Inf or -Inf, ROP is +0. The current implementation is not
1680 intended to be used with large arguments. It works with abs(X)
1681 typically smaller than 500. For larger arguments, other methods
1682 should be used and will be implemented in a future version.
1684 -- Function: int mpfr_const_log2 (mpfr_t ROP, mpfr_rnd_t RND)
1685 -- Function: int mpfr_const_pi (mpfr_t ROP, mpfr_rnd_t RND)
1686 -- Function: int mpfr_const_euler (mpfr_t ROP, mpfr_rnd_t RND)
1687 -- Function: int mpfr_const_catalan (mpfr_t ROP, mpfr_rnd_t RND)
1688 Set ROP to the logarithm of 2, the value of Pi, of Euler's
1689 constant 0.577..., of Catalan's constant 0.915..., respectively,
1690 rounded in the direction RND. These functions cache the computed
1691 values to avoid other calculations if a lower or equal precision
1692 is requested. To free these caches, use `mpfr_free_cache'.
1694 -- Function: void mpfr_free_cache (void)
1695 Free various caches used by MPFR internally, in particular the
1696 caches used by the functions computing constants
1697 (`mpfr_const_log2', `mpfr_const_pi', `mpfr_const_euler' and
1698 `mpfr_const_catalan'). You should call this function before
1699 terminating a thread, even if you did not call these functions
1700 directly (they could have been called internally).
1702 -- Function: int mpfr_sum (mpfr_t ROP, mpfr_ptr const TAB[], unsigned
1703 long int N, mpfr_rnd_t RND)
1704 Set ROP to the sum of all elements of TAB, whose size is N,
1705 rounded in the direction RND. Warning: for efficiency reasons, TAB
1706 is an array of pointers to `mpfr_t', not an array of `mpfr_t'. If
1707 the returned `int' value is zero, ROP is guaranteed to be the
1708 exact sum; otherwise ROP might be smaller than, equal to, or
1709 larger than the exact sum (in accordance to the rounding mode).
1710 However, `mpfr_sum' does guarantee the result is correctly rounded.
1713 File: mpfr.info, Node: Input and Output Functions, Next: Formatted Output Functions, Prev: Special Functions, Up: MPFR Interface
1715 5.8 Input and Output Functions
1716 ==============================
1718 This section describes functions that perform input from an input/output
1719 stream, and functions that output to an input/output stream. Passing a
1720 null pointer for a `stream' to any of these functions will make them
1721 read from `stdin' and write to `stdout', respectively.
1723 When using any of these functions, you must include the `<stdio.h>'
1724 standard header before `mpfr.h', to allow `mpfr.h' to define prototypes
1725 for these functions.
1727 -- Function: size_t mpfr_out_str (FILE *STREAM, int BASE, size_t N,
1728 mpfr_t OP, mpfr_rnd_t RND)
1729 Output OP on stream STREAM, as a string of digits in base BASE,
1730 rounded in the direction RND. The base may vary from 2 to 62.
1731 Print N significant digits exactly, or if N is 0, enough digits so
1732 that OP can be read back exactly (see `mpfr_get_str').
1734 In addition to the significant digits, a decimal point (defined by
1735 the current locale) at the right of the first digit and a trailing
1736 exponent in base 10, in the form `eNNN', are printed. If BASE is
1737 greater than 10, `@' will be used instead of `e' as exponent
1740 Return the number of characters written, or if an error occurred,
1743 -- Function: size_t mpfr_inp_str (mpfr_t ROP, FILE *STREAM, int BASE,
1745 Input a string in base BASE from stream STREAM, rounded in the
1746 direction RND, and put the read float in ROP.
1748 This function reads a word (defined as a sequence of characters
1749 between whitespace) and parses it using `mpfr_set_str'. See the
1750 documentation of `mpfr_strtofr' for a detailed description of the
1751 valid string formats.
1753 Return the number of bytes read, or if an error occurred, return 0.
1756 File: mpfr.info, Node: Formatted Output Functions, Next: Integer Related Functions, Prev: Input and Output Functions, Up: MPFR Interface
1758 5.9 Formatted Output Functions
1759 ==============================
1764 The class of `mpfr_printf' functions provides formatted output in a
1765 similar manner as the standard C `printf'. These functions are defined
1766 only if your system supports ISO C variadic functions and the
1767 corresponding argument access macros.
1769 When using any of these functions, you must include the `<stdio.h>'
1770 standard header before `mpfr.h', to allow `mpfr.h' to define prototypes
1771 for these functions.
1776 The format specification accepted by `mpfr_printf' is an extension of
1777 the `printf' one. The conversion specification is of the form:
1778 % [flags] [width] [.[precision]] [type] [rounding] conv
1779 `flags', `width', and `precision' have the same meaning as for the
1780 standard `printf' (in particular, notice that the `precision' is
1781 related to the number of digits displayed in the base chosen by `conv'
1782 and not related to the internal precision of the `mpfr_t' variable).
1783 `mpfr_printf' accepts the same `type' specifiers as GMP (except the
1784 non-standard and deprecated `q', use `ll' instead), namely the length
1785 modifiers defined in the C standard:
1789 `j' `intmax_t' or `uintmax_t'
1790 `l' `long' or `wchar_t'
1796 and the `type' specifiers defined in GMP plus `R' and `P' specific
1797 to MPFR (the second column in the table below shows the type of the
1798 argument read in the argument list and the kind of `conv' specifier to
1799 use after the `type' specifier):
1801 `F' `mpf_t', float conversions
1802 `Q' `mpq_t', integer conversions
1803 `M' `mp_limb_t', integer conversions
1804 `N' `mp_limb_t' array, integer conversions
1805 `Z' `mpz_t', integer conversions
1806 `P' `mpfr_prec_t', integer conversions
1807 `R' `mpfr_t', float conversions
1809 The `type' specifiers have the same restrictions as those mentioned
1810 in the GMP documentation: *note Formatted Output Strings:
1811 (gmp.info)Formatted Output Strings. In particular, the `type'
1812 specifiers (except `R' and `P') are supported only if they are
1813 supported by `gmp_printf' in your GMP build; this implies that the
1814 standard specifiers, such as `t', must _also_ be supported by your C
1815 library if you want to use them.
1817 The `rounding' field is specific to `mpfr_t' arguments and should
1818 not be used with other types.
1820 With conversion specification not involving `P' and `R' types,
1821 `mpfr_printf' behaves exactly as `gmp_printf'.
1823 The `P' type specifies that a following `o', `u', `x', or `X'
1824 conversion specifier applies to a `mpfr_prec_t' argument. It is needed
1825 because the `mpfr_prec_t' type does not necessarily correspond to an
1826 `unsigned int' or any fixed standard type. The `precision' field
1827 specifies the minimum number of digits to appear. The default
1828 `precision' is 1. For example:
1833 p = mpfr_get_prec (x);
1834 mpfr_printf ("variable x with %Pu bits", p);
1836 The `R' type specifies that a following `a', `A', `b', `e', `E',
1837 `f', `F', `g', `G', or `n' conversion specifier applies to a `mpfr_t'
1838 argument. The `R' type can be followed by a `rounding' specifier
1839 denoted by one of the following characters:
1841 `U' round toward plus infinity
1842 `D' round toward minus infinity
1843 `Y' round away from zero
1844 `Z' round toward zero
1845 `N' round to nearest
1846 `*' rounding mode indicated by the
1847 `mpfr_rnd_t' argument just before the
1848 corresponding `mpfr_t' variable.
1850 The default rounding mode is rounding to nearest. The following
1851 three examples are equivalent:
1855 mpfr_printf ("%.128Rf", x);
1856 mpfr_printf ("%.128RNf", x);
1857 mpfr_printf ("%.128R*f", MPFR_RNDN, x);
1859 Note that the rounding away from zero mode is specified with `Y'
1860 because ISO C reserves the `A' specifier for hexadecimal output (see
1863 The output `conv' specifiers allowed with `mpfr_t' parameter are:
1865 `a' `A' hex float, C99 style
1867 `e' `E' scientific format float
1868 `f' `F' fixed point float
1869 `g' `G' fixed or scientific float
1871 The conversion specifier `b' which displays the argument in binary is
1872 specific to `mpfr_t' arguments and should not be used with other types.
1873 Other conversion specifiers have the same meaning as for a `double'
1876 In case of non-decimal output, only the significand is written in the
1877 specified base, the exponent is always displayed in decimal. Special
1878 values are always displayed as `nan', `-inf', and `inf' for `a', `b',
1879 `e', `f', and `g' specifiers and `NAN', `-INF', and `INF' for `A', `E',
1880 `F', and `G' specifiers.
1882 If the `precision' field is not empty, the `mpfr_t' number is
1883 rounded to the given precision in the direction specified by the
1884 rounding mode. If the precision is zero with rounding to nearest mode
1885 and one of the following `conv' specifiers: `a', `A', `b', `e', `E',
1886 tie case is rounded to even when it lies between two consecutive values
1887 at the wanted precision which have the same exponent, otherwise, it is
1888 rounded away from zero. For instance, 85 is displayed as "8e+1" and 95
1889 is displayed as "1e+2" with the format specification `"%.0RNe"'. This
1890 also applies when the `g' (resp. `G') conversion specifier uses the `e'
1891 (resp. `E') style. If the precision is set to a value greater than the
1892 maximum value for an `int', it will be silently reduced down to
1895 If the `precision' field is empty (as in `%Re' or `%.RE') with
1896 `conv' specifier `e' and `E', the number is displayed with enough
1897 digits so that it can be read back exactly, assuming that the input and
1898 output variables have the same precision and that the input and output
1899 rounding modes are both rounding to nearest (as for `mpfr_get_str').
1900 The default precision for an empty `precision' field with `conv'
1901 specifiers `f', `F', `g', and `G' is 6.
1906 For all the following functions, if the number of characters which
1907 ought to be written appears to exceed the maximum limit for an `int',
1908 nothing is written in the stream (resp. to `stdout', to BUF, to STR),
1909 the function returns -1, sets the _erange_ flag, and (in POSIX system
1910 only) `errno' is set to `EOVERFLOW'.
1912 -- Function: int mpfr_fprintf (FILE *STREAM, const char *TEMPLATE, ...)
1913 -- Function: int mpfr_vfprintf (FILE *STREAM, const char *TEMPLATE,
1915 Print to the stream STREAM the optional arguments under the
1916 control of the template string TEMPLATE. Return the number of
1917 characters written or a negative value if an error occurred.
1919 -- Function: int mpfr_printf (const char *TEMPLATE, ...)
1920 -- Function: int mpfr_vprintf (const char *TEMPLATE, va_list AP)
1921 Print to `stdout' the optional arguments under the control of the
1922 template string TEMPLATE. Return the number of characters written
1923 or a negative value if an error occurred.
1925 -- Function: int mpfr_sprintf (char *BUF, const char *TEMPLATE, ...)
1926 -- Function: int mpfr_vsprintf (char *BUF, const char *TEMPLATE,
1928 Form a null-terminated string corresponding to the optional
1929 arguments under the control of the template string TEMPLATE, and
1930 print it in BUF. No overlap is permitted between BUF and the other
1931 arguments. Return the number of characters written in the array
1932 BUF _not counting_ the terminating null character or a negative
1933 value if an error occurred.
1935 -- Function: int mpfr_snprintf (char *BUF, size_t N, const char
1937 -- Function: int mpfr_vsnprintf (char *BUF, size_t N, const char
1938 *TEMPLATE, va_list AP)
1939 Form a null-terminated string corresponding to the optional
1940 arguments under the control of the template string TEMPLATE, and
1941 print it in BUF. If N is zero, nothing is written and BUF may be a
1942 null pointer, otherwise, the N-1 first characters are written in
1943 BUF and the N-th is a null character. Return the number of
1944 characters that would have been written had N be sufficiently
1945 large, _not counting_ the terminating null character, or a
1946 negative value if an error occurred.
1948 -- Function: int mpfr_asprintf (char **STR, const char *TEMPLATE, ...)
1949 -- Function: int mpfr_vasprintf (char **STR, const char *TEMPLATE,
1951 Write their output as a null terminated string in a block of
1952 memory allocated using the current allocation function. A pointer
1953 to the block is stored in STR. The block of memory must be freed
1954 using `mpfr_free_str'. The return value is the number of
1955 characters written in the string, excluding the null-terminator,
1956 or a negative value if an error occurred.
1959 File: mpfr.info, Node: Integer Related Functions, Next: Rounding Related Functions, Prev: Formatted Output Functions, Up: MPFR Interface
1961 5.10 Integer and Remainder Related Functions
1962 ============================================
1964 -- Function: int mpfr_rint (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1965 -- Function: int mpfr_ceil (mpfr_t ROP, mpfr_t OP)
1966 -- Function: int mpfr_floor (mpfr_t ROP, mpfr_t OP)
1967 -- Function: int mpfr_round (mpfr_t ROP, mpfr_t OP)
1968 -- Function: int mpfr_trunc (mpfr_t ROP, mpfr_t OP)
1969 Set ROP to OP rounded to an integer. `mpfr_rint' rounds to the
1970 nearest representable integer in the given direction RND,
1971 `mpfr_ceil' rounds to the next higher or equal representable
1972 integer, `mpfr_floor' to the next lower or equal representable
1973 integer, `mpfr_round' to the nearest representable integer,
1974 rounding halfway cases away from zero (as in the roundTiesToAway
1975 mode of IEEE 754-2008), and `mpfr_trunc' to the next representable
1976 integer toward zero.
1978 The returned value is zero when the result is exact, positive when
1979 it is greater than the original value of OP, and negative when it
1980 is smaller. More precisely, the returned value is 0 when OP is an
1981 integer representable in ROP, 1 or -1 when OP is an integer that
1982 is not representable in ROP, 2 or -2 when OP is not an integer.
1984 Note that `mpfr_round' is different from `mpfr_rint' called with
1985 the rounding to nearest mode (where halfway cases are rounded to
1986 an even integer or significand). Note also that no double rounding
1987 is performed; for instance, 10.5 (1010.1 in binary) is rounded by
1988 `mpfr_rint' with rounding to nearest to 12 (1100 in binary) in
1989 2-bit precision, because the two enclosing numbers representable
1990 on two bits are 8 and 12, and the closest is 12. (If one first
1991 rounded to an integer, one would round 10.5 to 10 with even
1992 rounding, and then 10 would be rounded to 8 again with even
1995 -- Function: int mpfr_rint_ceil (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
1996 -- Function: int mpfr_rint_floor (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t
1998 -- Function: int mpfr_rint_round (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t
2000 -- Function: int mpfr_rint_trunc (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t
2002 Set ROP to OP rounded to an integer. `mpfr_rint_ceil' rounds to
2003 the next higher or equal integer, `mpfr_rint_floor' to the next
2004 lower or equal integer, `mpfr_rint_round' to the nearest integer,
2005 rounding halfway cases away from zero, and `mpfr_rint_trunc' to
2006 the next integer toward zero. If the result is not representable,
2007 it is rounded in the direction RND. The returned value is the
2008 ternary value associated with the considered round-to-integer
2009 function (regarded in the same way as any other mathematical
2010 function). Contrary to `mpfr_rint', those functions do perform a
2011 double rounding: first OP is rounded to the nearest integer in the
2012 direction given by the function name, then this nearest integer
2013 (if not representable) is rounded in the given direction RND. For
2014 example, `mpfr_rint_round' with rounding to nearest and a precision
2015 of two bits rounds 6.5 to 7 (halfway cases away from zero), then 7
2016 is rounded to 8 by the round-even rule, despite the fact that 6 is
2017 also representable on two bits, and is closer to 6.5 than 8.
2019 -- Function: int mpfr_frac (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
2020 Set ROP to the fractional part of OP, having the same sign as OP,
2021 rounded in the direction RND (unlike in `mpfr_rint', RND affects
2022 only how the exact fractional part is rounded, not how the
2023 fractional part is generated).
2025 -- Function: int mpfr_modf (mpfr_t IOP, mpfr_t FOP, mpfr_t OP,
2027 Set simultaneously IOP to the integral part of OP and FOP to the
2028 fractional part of OP, rounded in the direction RND with the
2029 corresponding precision of IOP and FOP (equivalent to
2030 `mpfr_trunc(IOP, OP, RND)' and `mpfr_frac(FOP, OP, RND)'). The
2031 variables IOP and FOP must be different. Return 0 iff both results
2032 are exact (see `mpfr_sin_cos' for a more detailed description of
2035 -- Function: int mpfr_fmod (mpfr_t R, mpfr_t X, mpfr_t Y, mpfr_rnd_t
2037 -- Function: int mpfr_remainder (mpfr_t R, mpfr_t X, mpfr_t Y,
2039 -- Function: int mpfr_remquo (mpfr_t R, long* Q, mpfr_t X, mpfr_t Y,
2041 Set R to the value of X - NY, rounded according to the direction
2042 RND, where N is the integer quotient of X divided by Y, defined as
2043 follows: N is rounded toward zero for `mpfr_fmod', and to the
2044 nearest integer (ties rounded to even) for `mpfr_remainder' and
2047 Special values are handled as described in Section F.9.7.1 of the
2048 ISO C99 standard: If X is infinite or Y is zero, R is NaN. If Y
2049 is infinite and X is finite, R is X rounded to the precision of R.
2050 If R is zero, it has the sign of X. The return value is the
2051 ternary value corresponding to R.
2053 Additionally, `mpfr_remquo' stores the low significant bits from
2054 the quotient N in *Q (more precisely the number of bits in a
2055 `long' minus one), with the sign of X divided by Y (except if
2056 those low bits are all zero, in which case zero is returned).
2057 Note that X may be so large in magnitude relative to Y that an
2058 exact representation of the quotient is not practical. The
2059 `mpfr_remainder' and `mpfr_remquo' functions are useful for
2060 additive argument reduction.
2062 -- Function: int mpfr_integer_p (mpfr_t OP)
2063 Return non-zero iff OP is an integer.
2066 File: mpfr.info, Node: Rounding Related Functions, Next: Miscellaneous Functions, Prev: Integer Related Functions, Up: MPFR Interface
2068 5.11 Rounding Related Functions
2069 ===============================
2071 -- Function: void mpfr_set_default_rounding_mode (mpfr_rnd_t RND)
2072 Set the default rounding mode to RND. The default rounding mode
2073 is to nearest initially.
2075 -- Function: mpfr_rnd_t mpfr_get_default_rounding_mode (void)
2076 Get the default rounding mode.
2078 -- Function: int mpfr_prec_round (mpfr_t X, mpfr_prec_t PREC,
2080 Round X according to RND with precision PREC, which must be an
2081 integer between `MPFR_PREC_MIN' and `MPFR_PREC_MAX' (otherwise the
2082 behavior is undefined). If PREC is greater or equal to the
2083 precision of X, then new space is allocated for the significand,
2084 and it is filled with zeros. Otherwise, the significand is
2085 rounded to precision PREC with the given direction. In both cases,
2086 the precision of X is changed to PREC.
2088 Here is an example of how to use `mpfr_prec_round' to implement
2089 Newton's algorithm to compute the inverse of A, assuming X is
2090 already an approximation to N bits:
2091 mpfr_set_prec (t, 2 * n);
2092 mpfr_set (t, a, MPFR_RNDN); /* round a to 2n bits */
2093 mpfr_mul (t, t, x, MPFR_RNDN); /* t is correct to 2n bits */
2094 mpfr_ui_sub (t, 1, t, MPFR_RNDN); /* high n bits cancel with 1 */
2095 mpfr_prec_round (t, n, MPFR_RNDN); /* t is correct to n bits */
2096 mpfr_mul (t, t, x, MPFR_RNDN); /* t is correct to n bits */
2097 mpfr_prec_round (x, 2 * n, MPFR_RNDN); /* exact */
2098 mpfr_add (x, x, t, MPFR_RNDN); /* x is correct to 2n bits */
2100 -- Function: int mpfr_can_round (mpfr_t B, mpfr_exp_t ERR, mpfr_rnd_t
2101 RND1, mpfr_rnd_t RND2, mpfr_prec_t PREC)
2102 Assuming B is an approximation of an unknown number X in the
2103 direction RND1 with error at most two to the power E(b)-ERR where
2104 E(b) is the exponent of B, return a non-zero value if one is able
2105 to round correctly X to precision PREC with the direction RND2,
2106 and 0 otherwise (including for NaN and Inf). This function *does
2107 not modify* its arguments.
2109 If RND1 is `MPFR_RNDN', then the sign of the error is unknown, but
2110 its absolute value is the same, so that the possible range is
2111 twice as large as with a directed rounding for RND1.
2113 Note: if one wants to also determine the correct ternary value
2114 when rounding B to precision PREC with rounding mode RND, a useful
2115 trick is the following: if (mpfr_can_round (b, err, MPFR_RNDN, MPFR_RNDZ, prec + (rnd == MPFR_RNDN)))
2117 Indeed, if RND is `MPFR_RNDN', this will check if one can round
2118 to PREC+1 bits with a directed rounding: if so, one can surely
2119 round to nearest to PREC bits, and in addition one can determine
2120 the correct ternary value, which would not be the case when B is
2121 near from a value exactly representable on PREC bits.
2123 -- Function: mpfr_prec_t mpfr_min_prec (mpfr_t X)
2124 Return the minimal number of bits required to store the
2125 significand of X, and 0 for special values, including 0. (Warning:
2126 the returned value can be less than `MPFR_PREC_MIN'.)
2128 The function name is subject to change.
2130 -- Function: const char * mpfr_print_rnd_mode (mpfr_rnd_t RND)
2131 Return a string ("MPFR_RNDD", "MPFR_RNDU", "MPFR_RNDN",
2132 "MPFR_RNDZ", "MPFR_RNDA") corresponding to the rounding mode RND,
2133 or a null pointer if RND is an invalid rounding mode.
2136 File: mpfr.info, Node: Miscellaneous Functions, Next: Exception Related Functions, Prev: Rounding Related Functions, Up: MPFR Interface
2138 5.12 Miscellaneous Functions
2139 ============================
2141 -- Function: void mpfr_nexttoward (mpfr_t X, mpfr_t Y)
2142 If X or Y is NaN, set X to NaN. If X and Y are equal, X is
2143 unchanged. Otherwise, if X is different from Y, replace X by the
2144 next floating-point number (with the precision of X and the
2145 current exponent range) in the direction of Y (the infinite values
2146 are seen as the smallest and largest floating-point numbers). If
2147 the result is zero, it keeps the same sign. No underflow or
2148 overflow is generated.
2150 -- Function: void mpfr_nextabove (mpfr_t X)
2151 -- Function: void mpfr_nextbelow (mpfr_t X)
2152 Equivalent to `mpfr_nexttoward' where Y is plus infinity (resp.
2155 -- Function: int mpfr_min (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2,
2157 -- Function: int mpfr_max (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2,
2159 Set ROP to the minimum (resp. maximum) of OP1 and OP2. If OP1 and
2160 OP2 are both NaN, then ROP is set to NaN. If OP1 or OP2 is NaN,
2161 then ROP is set to the numeric value. If OP1 and OP2 are zeros of
2162 different signs, then ROP is set to -0 (resp. +0).
2164 -- Function: int mpfr_urandomb (mpfr_t ROP, gmp_randstate_t STATE)
2165 Generate a uniformly distributed random float in the interval 0 <=
2166 ROP < 1. More precisely, the number can be seen as a float with a
2167 random non-normalized significand and exponent 0, which is then
2168 normalized (thus if E denotes the exponent after normalization,
2169 then the least -E significant bits of the significand are always
2172 Return 0, unless the exponent is not in the current exponent
2173 range, in which case ROP is set to NaN and a non-zero value is
2174 returned (this should never happen in practice, except in very
2175 specific cases). The second argument is a `gmp_randstate_t'
2176 structure which should be created using the GMP `gmp_randinit'
2177 function (see the GMP manual).
2179 -- Function: int mpfr_urandom (mpfr_t ROP, gmp_randstate_t STATE,
2181 Generate a uniformly distributed random float. The floating-point
2182 number ROP can be seen as if a random real number is generated
2183 according to the continuous uniform distribution on the interval
2184 [0, 1] and then rounded in the direction RND.
2186 The second argument is a `gmp_randstate_t' structure which should
2187 be created using the GMP `gmp_randinit' function (see the GMP
2190 -- Function: mpfr_exp_t mpfr_get_exp (mpfr_t X)
2191 Return the exponent of X, assuming that X is a non-zero ordinary
2192 number and the significand is considered in [1/2,1). The behavior
2193 for NaN, infinity or zero is undefined.
2195 -- Function: int mpfr_set_exp (mpfr_t X, mpfr_exp_t E)
2196 Set the exponent of X if E is in the current exponent range, and
2197 return 0 (even if X is not a non-zero ordinary number); otherwise,
2198 return a non-zero value. The significand is assumed to be in
2201 -- Function: int mpfr_signbit (mpfr_t OP)
2202 Return a non-zero value iff OP has its sign bit set (i.e., if it is
2203 negative, -0, or a NaN whose representation has its sign bit set).
2205 -- Function: int mpfr_setsign (mpfr_t ROP, mpfr_t OP, int S,
2207 Set the value of ROP from OP, rounded toward the given direction
2208 RND, then set (resp. clear) its sign bit if S is non-zero (resp.
2209 zero), even when OP is a NaN.
2211 -- Function: int mpfr_copysign (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2,
2213 Set the value of ROP from OP1, rounded toward the given direction
2214 RND, then set its sign bit to that of OP2 (even when OP1 or OP2 is
2215 a NaN). This function is equivalent to `mpfr_setsign (ROP, OP1,
2216 mpfr_signbit (OP2), RND)'.
2218 -- Function: const char * mpfr_get_version (void)
2219 Return the MPFR version, as a null-terminated string.
2221 -- Macro: MPFR_VERSION
2222 -- Macro: MPFR_VERSION_MAJOR
2223 -- Macro: MPFR_VERSION_MINOR
2224 -- Macro: MPFR_VERSION_PATCHLEVEL
2225 -- Macro: MPFR_VERSION_STRING
2226 `MPFR_VERSION' is the version of MPFR as a preprocessing constant.
2227 `MPFR_VERSION_MAJOR', `MPFR_VERSION_MINOR' and
2228 `MPFR_VERSION_PATCHLEVEL' are respectively the major, minor and
2229 patch level of MPFR version, as preprocessing constants.
2230 `MPFR_VERSION_STRING' is the version (with an optional suffix, used
2231 in development and pre-release versions) as a string constant,
2232 which can be compared to the result of `mpfr_get_version' to check
2233 at run time the header file and library used match:
2234 if (strcmp (mpfr_get_version (), MPFR_VERSION_STRING))
2235 fprintf (stderr, "Warning: header and library do not match\n");
2236 Note: Obtaining different strings is not necessarily an error, as
2237 in general, a program compiled with some old MPFR version can be
2238 dynamically linked with a newer MPFR library version (if allowed
2239 by the library versioning system).
2241 -- Macro: long MPFR_VERSION_NUM (MAJOR, MINOR, PATCHLEVEL)
2242 Create an integer in the same format as used by `MPFR_VERSION'
2243 from the given MAJOR, MINOR and PATCHLEVEL. Here is an example of
2244 how to check the MPFR version at compile time:
2245 #if (!defined(MPFR_VERSION) || (MPFR_VERSION<MPFR_VERSION_NUM(3,0,0)))
2246 # error "Wrong MPFR version."
2249 -- Function: const char * mpfr_get_patches (void)
2250 Return a null-terminated string containing the ids of the patches
2251 applied to the MPFR library (contents of the `PATCHES' file),
2252 separated by spaces. Note: If the program has been compiled with
2253 an older MPFR version and is dynamically linked with a new MPFR
2254 library version, the identifiers of the patches applied to the old
2255 (compile-time) MPFR version are not available (however this
2256 information should not have much interest in general).
2258 -- Function: int mpfr_buildopt_tls_p (void)
2259 Return a non-zero value if MPFR was compiled as thread safe using
2260 compiler-level Thread Local Storage (that is MPFR was built with
2261 the `--enable-thread-safe' configure option, see `INSTALL' file),
2262 return zero otherwise.
2264 -- Function: int mpfr_buildopt_decimal_p (void)
2265 Return a non-zero value if MPFR was compiled with decimal float
2266 support (that is MPFR was built with the `--enable-decimal-float'
2267 configure option), return zero otherwise.
2270 File: mpfr.info, Node: Exception Related Functions, Next: Compatibility with MPF, Prev: Miscellaneous Functions, Up: MPFR Interface
2272 5.13 Exception Related Functions
2273 ================================
2275 -- Function: mpfr_exp_t mpfr_get_emin (void)
2276 -- Function: mpfr_exp_t mpfr_get_emax (void)
2277 Return the (current) smallest and largest exponents allowed for a
2278 floating-point variable. The smallest positive value of a
2279 floating-point variable is one half times 2 raised to the smallest
2280 exponent and the largest value has the form (1 - epsilon) times 2
2281 raised to the largest exponent, where epsilon depends on the
2282 precision of the considered variable.
2284 -- Function: int mpfr_set_emin (mpfr_exp_t EXP)
2285 -- Function: int mpfr_set_emax (mpfr_exp_t EXP)
2286 Set the smallest and largest exponents allowed for a
2287 floating-point variable. Return a non-zero value when EXP is not
2288 in the range accepted by the implementation (in that case the
2289 smallest or largest exponent is not changed), and zero otherwise.
2290 If the user changes the exponent range, it is her/his
2291 responsibility to check that all current floating-point variables
2292 are in the new allowed range (for example using
2293 `mpfr_check_range'), otherwise the subsequent behavior will be
2294 undefined, in the sense of the ISO C standard.
2296 -- Function: mpfr_exp_t mpfr_get_emin_min (void)
2297 -- Function: mpfr_exp_t mpfr_get_emin_max (void)
2298 -- Function: mpfr_exp_t mpfr_get_emax_min (void)
2299 -- Function: mpfr_exp_t mpfr_get_emax_max (void)
2300 Return the minimum and maximum of the exponents allowed for
2301 `mpfr_set_emin' and `mpfr_set_emax' respectively. These values
2302 are implementation dependent, thus a program using
2303 `mpfr_set_emax(mpfr_get_emax_max())' or
2304 `mpfr_set_emin(mpfr_get_emin_min())' may not be portable.
2306 -- Function: int mpfr_check_range (mpfr_t X, int T, mpfr_rnd_t RND)
2307 This function assumes that X is the correctly-rounded value of some
2308 real value Y in the direction RND and some extended exponent
2309 range, and that T is the corresponding ternary value. For
2310 example, one performed `t = mpfr_log (x, u, rnd)', and Y is the
2311 exact logarithm of U. Thus T is negative if X is smaller than Y,
2312 positive if X is larger than Y, and zero if X equals Y. This
2313 function modifies X if needed to be in the current range of
2314 acceptable values: It generates an underflow or an overflow if the
2315 exponent of X is outside the current allowed range; the value of T
2316 may be used to avoid a double rounding. This function returns zero
2317 if the new value of X equals the exact one Y, a positive value if
2318 that new value is larger than Y, and a negative value if it is
2319 smaller than Y. Note that unlike most functions, the new result X
2320 is compared to the (unknown) exact one Y, not the input value X,
2321 i.e., the ternary value is propagated.
2323 Note: If X is an infinity and T is different from zero (i.e., if
2324 the rounded result is an inexact infinity), then the overflow flag
2325 is set. This is useful because `mpfr_check_range' is typically
2326 called (at least in MPFR functions) after restoring the flags that
2327 could have been set due to internal computations.
2329 -- Function: int mpfr_subnormalize (mpfr_t X, int T, mpfr_rnd_t RND)
2330 This function rounds X emulating subnormal number arithmetic: if X
2331 is outside the subnormal exponent range, it just propagates the
2332 ternary value T; otherwise, it rounds X to precision
2333 `EXP(x)-emin+1' according to rounding mode RND and previous
2334 ternary value T, avoiding double rounding problems. More
2335 precisely in the subnormal domain, denoting by E the value of
2336 `emin', X is rounded in fixed-point arithmetic to an integer
2337 multiple of two to the power E-1; as a consequence, 1.5 multiplied
2338 by two to the power E-1 when T is zero is rounded to two to the
2339 power E with rounding to nearest.
2341 `PREC(x)' is not modified by this function. RND and T must be the
2342 rounding mode and the returned ternary value used when computing X
2343 (as in `mpfr_check_range'). The subnormal exponent range is from
2344 `emin' to `emin+PREC(x)-1'. If the result cannot be represented
2345 in the current exponent range (due to a too small `emax'), the
2346 behavior is undefined. Note that unlike most functions, the
2347 result is compared to the exact one, not the input value X, i.e.,
2348 the ternary value is propagated.
2350 As usual, if the returned ternary value is non zero, the inexact
2351 flag is set. Moreover, if a second rounding occurred (because the
2352 input X was in the subnormal range), the underflow flag is set.
2354 This is an example of how to emulate binary double IEEE 754
2355 arithmetic (binary64 in IEEE 754-2008) using MPFR:
2358 mpfr_t xa, xb; int i; volatile double a, b;
2360 mpfr_set_default_prec (53);
2361 mpfr_set_emin (-1073); mpfr_set_emax (1024);
2363 mpfr_init (xa); mpfr_init (xb);
2365 b = 34.3; mpfr_set_d (xb, b, MPFR_RNDN);
2366 a = 0x1.1235P-1021; mpfr_set_d (xa, a, MPFR_RNDN);
2369 i = mpfr_div (xa, xa, xb, MPFR_RNDN);
2370 i = mpfr_subnormalize (xa, i, MPFR_RNDN); /* new ternary value */
2372 mpfr_clear (xa); mpfr_clear (xb);
2375 Warning: this emulates a double IEEE 754 arithmetic with correct
2376 rounding in the subnormal range, which may not be the case for your
2379 -- Function: void mpfr_clear_underflow (void)
2380 -- Function: void mpfr_clear_overflow (void)
2381 -- Function: void mpfr_clear_nanflag (void)
2382 -- Function: void mpfr_clear_inexflag (void)
2383 -- Function: void mpfr_clear_erangeflag (void)
2384 Clear the underflow, overflow, invalid, inexact and _erange_ flags.
2386 -- Function: void mpfr_set_underflow (void)
2387 -- Function: void mpfr_set_overflow (void)
2388 -- Function: void mpfr_set_nanflag (void)
2389 -- Function: void mpfr_set_inexflag (void)
2390 -- Function: void mpfr_set_erangeflag (void)
2391 Set the underflow, overflow, invalid, inexact and _erange_ flags.
2393 -- Function: void mpfr_clear_flags (void)
2394 Clear all global flags (underflow, overflow, invalid, inexact,
2397 -- Function: int mpfr_underflow_p (void)
2398 -- Function: int mpfr_overflow_p (void)
2399 -- Function: int mpfr_nanflag_p (void)
2400 -- Function: int mpfr_inexflag_p (void)
2401 -- Function: int mpfr_erangeflag_p (void)
2402 Return the corresponding (underflow, overflow, invalid, inexact,
2403 _erange_) flag, which is non-zero iff the flag is set.
2406 File: mpfr.info, Node: Compatibility with MPF, Next: Custom Interface, Prev: Exception Related Functions, Up: MPFR Interface
2408 5.14 Compatibility With MPF
2409 ===========================
2411 A header file `mpf2mpfr.h' is included in the distribution of MPFR for
2412 compatibility with the GNU MP class MPF. By inserting the following
2413 two lines after the `#include <gmp.h>' line,
2415 #include <mpf2mpfr.h>
2416 any program written for MPF can be compiled directly with MPFR without
2417 any changes (except the `gmp_printf' functions will not work for
2418 arguments of type `mpfr_t'). All operations are then performed with
2419 the default MPFR rounding mode, which can be reset with
2420 `mpfr_set_default_rounding_mode'.
2422 Warning: the `mpf_init' and `mpf_init2' functions initialize to
2423 zero, whereas the corresponding MPFR functions initialize to NaN: this
2424 is useful to detect uninitialized values, but is slightly incompatible
2427 -- Function: void mpfr_set_prec_raw (mpfr_t X, mpfr_prec_t PREC)
2428 Reset the precision of X to be *exactly* PREC bits. The only
2429 difference with `mpfr_set_prec' is that PREC is assumed to be
2430 small enough so that the significand fits into the current
2431 allocated memory space for X. Otherwise the behavior is undefined.
2433 -- Function: int mpfr_eq (mpfr_t OP1, mpfr_t OP2, unsigned long int
2435 Return non-zero if OP1 and OP2 are both non-zero ordinary numbers
2436 with the same exponent and the same first OP3 bits, both zero, or
2437 both infinities of the same sign. Return zero otherwise. This
2438 function is defined for compatibility with MPF, we do not recommend
2439 to use it otherwise. Do not use it either if you want to know
2440 whether two numbers are close to each other; for instance,
2441 1.011111 and 1.100000 are regarded as different for any value of
2444 -- Function: void mpfr_reldiff (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2,
2446 Compute the relative difference between OP1 and OP2 and store the
2447 result in ROP. This function does not guarantee the correct
2448 rounding on the relative difference; it just computes
2449 |OP1-OP2|/OP1, using the precision of ROP and the rounding mode
2450 RND for all operations.
2452 -- Function: int mpfr_mul_2exp (mpfr_t ROP, mpfr_t OP1, unsigned long
2453 int OP2, mpfr_rnd_t RND)
2454 -- Function: int mpfr_div_2exp (mpfr_t ROP, mpfr_t OP1, unsigned long
2455 int OP2, mpfr_rnd_t RND)
2456 These functions are identical to `mpfr_mul_2ui' and `mpfr_div_2ui'
2457 respectively. These functions are only kept for compatibility
2458 with MPF, one should prefer `mpfr_mul_2ui' and `mpfr_div_2ui'
2462 File: mpfr.info, Node: Custom Interface, Next: Internals, Prev: Compatibility with MPF, Up: MPFR Interface
2464 5.15 Custom Interface
2465 =====================
2467 Some applications use a stack to handle the memory and their objects.
2468 However, the MPFR memory design is not well suited for such a thing. So
2469 that such applications are able to use MPFR, an auxiliary memory
2470 interface has been created: the Custom Interface.
2472 The following interface allows one to use MPFR in two ways:
2473 * Either directly store a floating-point number as a `mpfr_t' on the
2476 * Either store its own representation on the stack and construct a
2477 new temporary `mpfr_t' each time it is needed.
2478 Nothing has to be done to destroy the floating-point numbers except
2479 garbaging the used memory: all the memory management (allocating,
2480 destroying, garbaging) is left to the application.
2482 Each function in this interface is also implemented as a macro for
2483 efficiency reasons: for example `mpfr_custom_init (s, p)' uses the
2484 macro, while `(mpfr_custom_init) (s, p)' uses the function.
2486 Note 1: MPFR functions may still initialize temporary floating-point
2487 numbers using `mpfr_init' and similar functions. See Custom Allocation
2490 Note 2: MPFR functions may use the cached functions (`mpfr_const_pi'
2491 for example), even if they are not explicitly called. You have to call
2492 `mpfr_free_cache' each time you garbage the memory iff `mpfr_init',
2493 through GMP Custom Allocation, allocates its memory on the application
2496 -- Function: size_t mpfr_custom_get_size (mpfr_prec_t PREC)
2497 Return the needed size in bytes to store the significand of a
2498 floating-point number of precision PREC.
2500 -- Function: void mpfr_custom_init (void *SIGNIFICAND, mpfr_prec_t
2502 Initialize a significand of precision PREC, where SIGNIFICAND must
2503 be an area of `mpfr_custom_get_size (prec)' bytes at least and be
2504 suitably aligned for an array of `mp_limb_t' (GMP type, *note
2507 -- Function: void mpfr_custom_init_set (mpfr_t X, int KIND, mpfr_exp_t
2508 EXP, mpfr_prec_t PREC, void *SIGNIFICAND)
2509 Perform a dummy initialization of a `mpfr_t' and set it to:
2510 * if `ABS(kind) == MPFR_NAN_KIND', X is set to NaN;
2512 * if `ABS(kind) == MPFR_INF_KIND', X is set to the infinity of
2515 * if `ABS(kind) == MPFR_ZERO_KIND', X is set to the zero of
2518 * if `ABS(kind) == MPFR_REGULAR_KIND', X is set to a regular
2519 number: `x = sign(kind)*significand*2^exp'.
2520 In all cases, it uses SIGNIFICAND directly for further computing
2521 involving X. It will not allocate anything. A floating-point
2522 number initialized with this function cannot be resized using
2523 `mpfr_set_prec' or `mpfr_prec_round', or cleared using
2524 `mpfr_clear'! The SIGNIFICAND must have been initialized with
2525 `mpfr_custom_init' using the same precision PREC.
2527 -- Function: int mpfr_custom_get_kind (mpfr_t X)
2528 Return the current kind of a `mpfr_t' as created by
2529 `mpfr_custom_init_set'. The behavior of this function for any
2530 `mpfr_t' not initialized with `mpfr_custom_init_set' is undefined.
2532 -- Function: void * mpfr_custom_get_significand (mpfr_t X)
2533 Return a pointer to the significand used by a `mpfr_t' initialized
2534 with `mpfr_custom_init_set'. The behavior of this function for
2535 any `mpfr_t' not initialized with `mpfr_custom_init_set' is
2538 -- Function: mpfr_exp_t mpfr_custom_get_exp (mpfr_t X)
2539 Return the exponent of X, assuming that X is a non-zero ordinary
2540 number. The return value for NaN, Infinity or zero is unspecified
2541 but does not produce any trap. The behavior of this function for
2542 any `mpfr_t' not initialized with `mpfr_custom_init_set' is
2545 -- Function: void mpfr_custom_move (mpfr_t X, void *NEW_POSITION)
2546 Inform MPFR that the significand of X has moved due to a garbage
2547 collect and update its new position to `new_position'. However
2548 the application has to move the significand and the `mpfr_t'
2549 itself. The behavior of this function for any `mpfr_t' not
2550 initialized with `mpfr_custom_init_set' is undefined.
2553 File: mpfr.info, Node: Internals, Prev: Custom Interface, Up: MPFR Interface
2558 A "limb" means the part of a multi-precision number that fits in a
2559 single word. Usually a limb contains 32 or 64 bits. The C data type
2560 for a limb is `mp_limb_t'.
2562 The `mpfr_t' type is internally defined as a one-element array of a
2563 structure, and `mpfr_ptr' is the C data type representing a pointer to
2564 this structure. The `mpfr_t' type consists of four fields:
2566 * The `_mpfr_prec' field is used to store the precision of the
2567 variable (in bits); this is not less than `MPFR_PREC_MIN'.
2569 * The `_mpfr_sign' field is used to store the sign of the variable.
2571 * The `_mpfr_exp' field stores the exponent. An exponent of 0 means
2572 a radix point just above the most significant limb. Non-zero
2573 values n are a multiplier 2^n relative to that point. A NaN, an
2574 infinity and a zero are indicated by special values of the exponent
2577 * Finally, the `_mpfr_d' field is a pointer to the limbs, least
2578 significant limbs stored first. The number of limbs in use is
2579 controlled by `_mpfr_prec', namely
2580 ceil(`_mpfr_prec'/`mp_bits_per_limb'). Non-singular (i.e.,
2581 different from NaN, Infinity or zero) values always have the most
2582 significant bit of the most significant limb set to 1. When the
2583 precision does not correspond to a whole number of limbs, the
2584 excess bits at the low end of the data are zeros.
2588 File: mpfr.info, Node: API Compatibility, Next: Contributors, Prev: MPFR Interface, Up: Top
2593 The goal of this section is to describe some API changes that occurred
2594 from one version of MPFR to another, and how to write code that can be
2595 compiled and run with older MPFR versions. The minimum MPFR version
2596 that is considered here is 2.2.0 (released on 20 September 2005).
2598 API changes can only occur between major or minor versions. Thus the
2599 patchlevel (the third number in the MPFR version) will be ignored in
2600 the following. If a program does not use MPFR internals, changes in
2601 the behavior between two versions differing only by the patchlevel
2602 should only result from what was regarded as a bug or unspecified
2605 As a general rule, a program written for some MPFR version should
2606 work with later versions, possibly except at a new major version, where
2607 some features (described as obsolete for some time) can be removed. In
2608 such a case, a failure should occur during compilation or linking. If
2609 a result becomes incorrect because of such a change, please look at the
2610 various changes below (they are minimal, and most software should be
2611 unaffected), at the FAQ and at the MPFR web page for your version (a
2612 bug could have been introduced and be already fixed); and if the
2613 problem is not mentioned, please send us a bug report (*note Reporting
2616 However, a program written for the current MPFR version (as
2617 documented by this manual) may not necessarily work with previous
2618 versions of MPFR. This section should help developers to write
2621 Note: Information given here may be incomplete. API changes are
2622 also described in the NEWS file (for each version, instead of being
2623 classified like here), together with other changes.
2627 * Type and Macro Changes::
2629 * Changed Functions::
2630 * Removed Functions::
2634 File: mpfr.info, Node: Type and Macro Changes, Next: Added Functions, Prev: API Compatibility, Up: API Compatibility
2636 6.1 Type and Macro Changes
2637 ==========================
2639 The official type for exponent values changed from `mp_exp_t' to
2640 `mpfr_exp_t' in MPFR 3.0. The type `mp_exp_t' will remain available as
2641 it comes from GMP (with a different meaning). These types are
2642 currently the same (`mpfr_exp_t' is defined as `mp_exp_t' with
2643 `typedef'), so that programs can still use `mp_exp_t'; but this may
2644 change in the future. Alternatively, using the following code after
2645 including `mpfr.h' will work with official MPFR versions, as
2646 `mpfr_exp_t' was never defined in MPFR 2.x:
2647 #if MPFR_VERSION_MAJOR < 3
2648 typedef mp_exp_t mpfr_exp_t;
2651 The official types for precision values and for rounding modes
2652 respectively changed from `mp_prec_t' and `mp_rnd_t' to `mpfr_prec_t'
2653 and `mpfr_rnd_t' in MPFR 3.0. This change was actually done a long
2654 time ago in MPFR, at least since MPFR 2.2.0, with the following code in
2657 # define mp_rnd_t mpfr_rnd_t
2660 # define mp_prec_t mpfr_prec_t
2662 This means that it is safe to use the new official types
2663 `mpfr_prec_t' and `mpfr_rnd_t' in your programs. The types `mp_prec_t'
2664 and `mp_rnd_t' (defined in MPFR only) may be removed in the future, as
2665 the prefix `mp_' is reserved by GMP.
2667 The precision type `mpfr_prec_t' (`mp_prec_t') was unsigned before
2668 MPFR 3.0; it is now signed. `MPFR_PREC_MAX' has not changed, though.
2669 Indeed the MPFR code requires that `MPFR_PREC_MAX' be representable in
2670 the exponent type, which may have the same size as `mpfr_prec_t' but
2671 has always been signed. The consequence is that valid code that does
2672 not assume anything about the signedness of `mpfr_prec_t' should work
2673 with past and new MPFR versions. This change was useful as the use of
2674 unsigned types tends to convert signed values to unsigned ones in
2675 expressions due to the usual arithmetic conversions, which can yield
2676 incorrect results if a negative value is converted in such a way.
2677 Warning! A program assuming (intentionally or not) that `mpfr_prec_t'
2678 is signed may be affected by this problem when it is built and run
2681 The rounding modes `GMP_RNDx' were renamed to `MPFR_RNDx' in MPFR
2682 3.0. However the old names `GMP_RNDx' have been kept for compatibility
2683 (this might change in future versions), using:
2684 #define GMP_RNDN MPFR_RNDN
2685 #define GMP_RNDZ MPFR_RNDZ
2686 #define GMP_RNDU MPFR_RNDU
2687 #define GMP_RNDD MPFR_RNDD
2688 The rounding mode "round away from zero" (`MPFR_RNDA') was added in
2689 MPFR 3.0 (however no rounding mode `GMP_RNDA' exists).
2692 File: mpfr.info, Node: Added Functions, Next: Changed Functions, Prev: Type and Macro Changes, Up: API Compatibility
2697 We give here in alphabetical order the functions that were added after
2698 MPFR 2.2, and in which MPFR version.
2700 * `mpfr_add_d' in MPFR 2.4.
2702 * `mpfr_ai' in MPFR 3.0 (incomplete, experimental).
2704 * `mpfr_asprintf' in MPFR 2.4.
2706 * `mpfr_buildopt_decimal_p' and `mpfr_buildopt_tls_p' in MPFR 3.0.
2708 * `mpfr_copysign' in MPFR 2.3. Note: MPFR 2.2 had a `mpfr_copysign'
2709 function that was available, but not documented, and with a slight
2710 difference in the semantics (when the second input operand is a
2713 * `mpfr_custom_get_significand' in MPFR 3.0. This function was
2714 named `mpfr_custom_get_mantissa' in previous versions;
2715 `mpfr_custom_get_mantissa' is still available via a macro in
2717 #define mpfr_custom_get_mantissa mpfr_custom_get_significand
2718 Thus code that needs to work with both MPFR 2.x and MPFR 3.x should
2719 use `mpfr_custom_get_mantissa'.
2721 * `mpfr_d_div' and `mpfr_d_sub' in MPFR 2.4.
2723 * `mpfr_digamma' in MPFR 3.0.
2725 * `mpfr_div_d' in MPFR 2.4.
2727 * `mpfr_fmod' in MPFR 2.4.
2729 * `mpfr_fms' in MPFR 2.3.
2731 * `mpfr_fprintf' in MPFR 2.4.
2733 * `mpfr_get_flt' in MPFR 3.0.
2735 * `mpfr_get_patches' in MPFR 2.3.
2737 * `mpfr_get_z_2exp' in MPFR 3.0. This function was named
2738 `mpfr_get_z_exp' in previous versions; `mpfr_get_z_exp' is still
2739 available via a macro in `mpfr.h':
2740 #define mpfr_get_z_exp mpfr_get_z_2exp
2741 Thus code that needs to work with both MPFR 2.x and MPFR 3.x should
2742 use `mpfr_get_z_exp'.
2744 * `mpfr_j0', `mpfr_j1' and `mpfr_jn' in MPFR 2.3.
2746 * `mpfr_lgamma' in MPFR 2.3.
2748 * `mpfr_li2' in MPFR 2.4.
2750 * `mpfr_modf' in MPFR 2.4.
2752 * `mpfr_mul_d' in MPFR 2.4.
2754 * `mpfr_printf' in MPFR 2.4.
2756 * `mpfr_rec_sqrt' in MPFR 2.4.
2758 * `mpfr_regular_p' in MPFR 3.0.
2760 * `mpfr_remainder' and `mpfr_remquo' in MPFR 2.3.
2762 * `mpfr_set_flt' in MPFR 3.0.
2764 * `mpfr_set_z_2exp' in MPFR 3.0.
2766 * `mpfr_set_zero' in MPFR 3.0.
2768 * `mpfr_setsign' in MPFR 2.3.
2770 * `mpfr_signbit' in MPFR 2.3.
2772 * `mpfr_sinh_cosh' in MPFR 2.4.
2774 * `mpfr_snprintf' and `mpfr_sprintf' in MPFR 2.4.
2776 * `mpfr_sub_d' in MPFR 2.4.
2778 * `mpfr_urandom' in MPFR 3.0.
2780 * `mpfr_vasprintf', `mpfr_vfprintf', `mpfr_vprintf',
2781 `mpfr_vsprintf' and `mpfr_vsnprintf' in MPFR 2.4.
2783 * `mpfr_y0', `mpfr_y1' and `mpfr_yn' in MPFR 2.3.
2787 File: mpfr.info, Node: Changed Functions, Next: Removed Functions, Prev: Added Functions, Up: API Compatibility
2789 6.3 Changed Functions
2790 =====================
2792 The following functions have changed after MPFR 2.2. Changes can affect
2793 the behavior of code written for some MPFR version when built and run
2794 against another MPFR version (older or newer), as described below.
2796 * `mpfr_check_range' changed in MPFR 2.3.2 and MPFR 2.4. If the
2797 value is an inexact infinity, the overflow flag is now set (in
2798 case it was lost), while it was previously left unchanged. This
2799 is really what is expected in practice (and what the MPFR code was
2800 expecting), so that the previous behavior was regarded as a bug.
2801 Hence the change in MPFR 2.3.2.
2803 * `mpfr_get_f' changed in MPFR 3.0. This function was returning
2804 zero, except for NaN and Inf, which do not exist in MPF. The
2805 _erange_ flag is now set in these cases, and `mpfr_get_f' now
2806 returns the usual ternary value.
2808 * `mpfr_get_si', `mpfr_get_sj', `mpfr_get_ui' and `mpfr_get_uj'
2809 changed in MPFR 3.0. In previous MPFR versions, the cases where
2810 the _erange_ flag is set were unspecified.
2812 * `mpfr_get_z' changed in MPFR 3.0. The return type was `void'; it
2813 is now `int', and the usual ternary value is returned. Thus
2814 programs that need to work with both MPFR 2.x and 3.x must not use
2815 the return value. Even in this case, C code using `mpfr_get_z' as
2816 the second or third term of a conditional operator may also be
2817 affected. For instance, the following is correct with MPFR 3.0,
2818 but not with MPFR 2.x:
2819 bool ? mpfr_get_z(...) : mpfr_add(...);
2820 On the other hand, the following is correct with MPFR 2.x, but not
2822 bool ? mpfr_get_z(...) : (void) mpfr_add(...);
2823 Portable code should cast `mpfr_get_z(...)' to `void' to use the
2824 type `void' for both terms of the conditional operator, as in:
2825 bool ? (void) mpfr_get_z(...) : (void) mpfr_add(...);
2826 Alternatively, `if ... else' can be used instead of the
2827 conditional operator.
2829 Moreover the cases where the _erange_ flag is set were unspecified
2832 * `mpfr_get_z_exp' changed in MPFR 3.0. In previous MPFR versions,
2833 the cases where the _erange_ flag is set were unspecified. Note:
2834 this function has been renamed to `mpfr_get_z_2exp' in MPFR 3.0,
2835 but `mpfr_get_z_exp' is still available for compatibility reasons.
2837 * `mpfr_strtofr' changed in MPFR 2.3.1 and MPFR 2.4. This was
2838 actually a bug fix since the code and the documentation did not
2839 match. But both were changed in order to have a more consistent
2840 and useful behavior. The main changes in the code are as follows.
2841 The binary exponent is now accepted even without the `0b' or `0x'
2842 prefix. Data corresponding to NaN can now have an optional sign
2843 (such data were previously invalid).
2845 * `mpfr_strtofr' changed in MPFR 3.0. This function now accepts
2846 bases from 37 to 62 (no changes for the other bases). Note: if an
2847 unsupported base is provided to this function, the behavior is
2848 undefined; more precisely, in MPFR 2.3.1 and later, providing an
2849 unsupported base yields an assertion failure (this behavior may
2850 change in the future).
2852 * `mpfr_subnormalize' changed in MPFR 3.0.1. This was actually
2853 regarded as a bug fix. The `mpfr_subnormalize' implementation up
2854 to MPFR 3.0.0 did not change the flags. In particular, it did not
2855 follow the generic rule concerning the inexact flag (and no
2856 special behavior was specified). The case of the underflow flag
2857 was more a lack of specification.
2861 File: mpfr.info, Node: Removed Functions, Next: Other Changes, Prev: Changed Functions, Up: API Compatibility
2863 6.4 Removed Functions
2864 =====================
2866 Functions `mpfr_random' and `mpfr_random2' have been removed in MPFR
2867 3.0 (this only affects old code built against MPFR 3.0 or later). (The
2868 function `mpfr_random' had been deprecated since at least MPFR 2.2.0,
2869 and `mpfr_random2' since MPFR 2.4.0.)
2872 File: mpfr.info, Node: Other Changes, Prev: Removed Functions, Up: API Compatibility
2877 For users of a C++ compiler, the way how the availability of `intmax_t'
2878 is detected has changed in MPFR 3.0. In MPFR 2.x, if a macro
2879 `INTMAX_C' or `UINTMAX_C' was defined (e.g. when the
2880 `__STDC_CONSTANT_MACROS' macro had been defined before `<stdint.h>' or
2881 `<inttypes.h>' has been included), `intmax_t' was assumed to be defined.
2882 However this was not always the case (more precisely, `intmax_t' can be
2883 defined only in the namespace `std', as with Boost), so that
2884 compilations could fail. Thus the check for `INTMAX_C' or `UINTMAX_C'
2885 is now disabled for C++ compilers, with the following consequences:
2887 * Programs written for MPFR 2.x that need `intmax_t' may no longer
2888 be compiled against MPFR 3.0: a `#define MPFR_USE_INTMAX_T' may be
2889 necessary before `mpfr.h' is included.
2891 * The compilation of programs that work with MPFR 3.0 may fail with
2892 MPFR 2.x due to the problem described above. Workarounds are
2893 possible, such as defining `intmax_t' and `uintmax_t' in the global
2894 namespace, though this is not clean.
2898 File: mpfr.info, Node: Contributors, Next: References, Prev: API Compatibility, Up: Top
2903 The main developers of MPFR are Guillaume Hanrot, Vincent Lefèvre,
2904 Patrick Pélissier, Philippe Théveny and Paul Zimmermann.
2906 Sylvie Boldo from ENS-Lyon, France, contributed the functions
2907 `mpfr_agm' and `mpfr_log'. Emmanuel Jeandel, from ENS-Lyon too,
2908 contributed the generic hypergeometric code, as well as the internal
2909 function `mpfr_exp3', a first implementation of the sine and cosine,
2910 and improved versions of `mpfr_const_log2' and `mpfr_const_pi'.
2911 Mathieu Dutour contributed the functions `mpfr_atan' and `mpfr_asin',
2912 and a previous version of `mpfr_gamma'; David Daney contributed the
2913 hyperbolic and inverse hyperbolic functions, the base-2 exponential,
2914 and the factorial function. Fabrice Rouillier contributed the
2915 `mpfr_xxx_z' and `mpfr_xxx_q' functions, and helped to the Microsoft
2916 Windows porting. Jean-Luc Rémy contributed the `mpfr_zeta' code.
2917 Ludovic Meunier helped in the design of the `mpfr_erf' code. Damien
2918 Stehlé contributed the `mpfr_get_ld_2exp' function. Sylvain Chevillard
2919 contributed the `mpfr_ai' function.
2921 We would like to thank Jean-Michel Muller and Joris van der Hoeven
2922 for very fruitful discussions at the beginning of that project,
2923 Torbjörn Granlund and Kevin Ryde for their help about design issues,
2924 and Nathalie Revol for her careful reading of a previous version of
2925 this documentation. In particular Kevin Ryde did a tremendous job for
2926 the portability of MPFR in 2002-2004.
2928 The development of the MPFR library would not have been possible
2929 without the continuous support of INRIA, and of the LORIA (Nancy,
2930 France) and LIP (Lyon, France) laboratories. In particular the main
2931 authors were or are members of the PolKA, Spaces, Cacao and Caramel
2932 project-teams at LORIA and of the Arénaire project-team at LIP. This
2933 project was started during the Fiable (reliable in French) action
2934 supported by INRIA, and continued during the AOC action. The
2935 development of MPFR was also supported by a grant (202F0659 00 MPN 121)
2936 from the Conseil Régional de Lorraine in 2002, from INRIA by an
2937 "associate engineer" grant (2003-2005), an "opération de développement
2938 logiciel" grant (2007-2009), and the post-doctoral grant of Sylvain
2939 Chevillard in 2009-2010.
2942 File: mpfr.info, Node: References, Next: GNU Free Documentation License, Prev: Contributors, Up: Top
2947 * Richard Brent and Paul Zimmermann, "Modern Computer Arithmetic",
2948 Cambridge University Press (to appear), also available from the
2951 * Laurent Fousse, Guillaume Hanrot, Vincent Lefèvre, Patrick
2952 Pélissier and Paul Zimmermann, "MPFR: A Multiple-Precision Binary
2953 Floating-Point Library With Correct Rounding", ACM Transactions on
2954 Mathematical Software, volume 33, issue 2, article 13, 15 pages,
2955 2007, `http://doi.acm.org/10.1145/1236463.1236468'.
2957 * Torbjörn Granlund, "GNU MP: The GNU Multiple Precision Arithmetic
2958 Library", version 5.0.1, 2010, `http://gmplib.org'.
2960 * IEEE standard for binary floating-point arithmetic, Technical
2961 Report ANSI-IEEE Standard 754-1985, New York, 1985. Approved
2962 March 21, 1985: IEEE Standards Board; approved July 26, 1985:
2963 American National Standards Institute, 18 pages.
2965 * IEEE Standard for Floating-Point Arithmetic, ANSI-IEEE Standard
2966 754-2008, 2008. Revision of ANSI-IEEE Standard 754-1985, approved
2967 June 12, 2008: IEEE Standards Board, 70 pages.
2969 * Donald E. Knuth, "The Art of Computer Programming", vol 2,
2970 "Seminumerical Algorithms", 2nd edition, Addison-Wesley, 1981.
2972 * Jean-Michel Muller, "Elementary Functions, Algorithms and
2973 Implementation", Birkhäuser, Boston, 2nd edition, 2006.
2975 * Jean-Michel Muller, Nicolas Brisebarre, Florent de Dinechin,
2976 Claude-Pierre Jeannerod, Vincent Lefèvre, Guillaume Melquiond,
2977 Nathalie Revol, Damien Stehlé and Serge Torrès, "Handbook of
2978 Floating-Point Arithmetic", Birkhäuser, Boston, 2009.
2982 File: mpfr.info, Node: GNU Free Documentation License, Next: Concept Index, Prev: References, Up: Top
2984 Appendix A GNU Free Documentation License
2985 *****************************************
2987 Version 1.2, November 2002
2989 Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
2990 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
2992 Everyone is permitted to copy and distribute verbatim copies
2993 of this license document, but changing it is not allowed.
2997 The purpose of this License is to make a manual, textbook, or other
2998 functional and useful document "free" in the sense of freedom: to
2999 assure everyone the effective freedom to copy and redistribute it,
3000 with or without modifying it, either commercially or
3001 noncommercially. Secondarily, this License preserves for the
3002 author and publisher a way to get credit for their work, while not
3003 being considered responsible for modifications made by others.
3005 This License is a kind of "copyleft", which means that derivative
3006 works of the document must themselves be free in the same sense.
3007 It complements the GNU General Public License, which is a copyleft
3008 license designed for free software.
3010 We have designed this License in order to use it for manuals for
3011 free software, because free software needs free documentation: a
3012 free program should come with manuals providing the same freedoms
3013 that the software does. But this License is not limited to
3014 software manuals; it can be used for any textual work, regardless
3015 of subject matter or whether it is published as a printed book.
3016 We recommend this License principally for works whose purpose is
3017 instruction or reference.
3019 1. APPLICABILITY AND DEFINITIONS
3021 This License applies to any manual or other work, in any medium,
3022 that contains a notice placed by the copyright holder saying it
3023 can be distributed under the terms of this License. Such a notice
3024 grants a world-wide, royalty-free license, unlimited in duration,
3025 to use that work under the conditions stated herein. The
3026 "Document", below, refers to any such manual or work. Any member
3027 of the public is a licensee, and is addressed as "you". You
3028 accept the license if you copy, modify or distribute the work in a
3029 way requiring permission under copyright law.
3031 A "Modified Version" of the Document means any work containing the
3032 Document or a portion of it, either copied verbatim, or with
3033 modifications and/or translated into another language.
3035 A "Secondary Section" is a named appendix or a front-matter section
3036 of the Document that deals exclusively with the relationship of the
3037 publishers or authors of the Document to the Document's overall
3038 subject (or to related matters) and contains nothing that could
3039 fall directly within that overall subject. (Thus, if the Document
3040 is in part a textbook of mathematics, a Secondary Section may not
3041 explain any mathematics.) The relationship could be a matter of
3042 historical connection with the subject or with related matters, or
3043 of legal, commercial, philosophical, ethical or political position
3046 The "Invariant Sections" are certain Secondary Sections whose
3047 titles are designated, as being those of Invariant Sections, in
3048 the notice that says that the Document is released under this
3049 License. If a section does not fit the above definition of
3050 Secondary then it is not allowed to be designated as Invariant.
3051 The Document may contain zero Invariant Sections. If the Document
3052 does not identify any Invariant Sections then there are none.
3054 The "Cover Texts" are certain short passages of text that are
3055 listed, as Front-Cover Texts or Back-Cover Texts, in the notice
3056 that says that the Document is released under this License. A
3057 Front-Cover Text may be at most 5 words, and a Back-Cover Text may
3058 be at most 25 words.
3060 A "Transparent" copy of the Document means a machine-readable copy,
3061 represented in a format whose specification is available to the
3062 general public, that is suitable for revising the document
3063 straightforwardly with generic text editors or (for images
3064 composed of pixels) generic paint programs or (for drawings) some
3065 widely available drawing editor, and that is suitable for input to
3066 text formatters or for automatic translation to a variety of
3067 formats suitable for input to text formatters. A copy made in an
3068 otherwise Transparent file format whose markup, or absence of
3069 markup, has been arranged to thwart or discourage subsequent
3070 modification by readers is not Transparent. An image format is
3071 not Transparent if used for any substantial amount of text. A
3072 copy that is not "Transparent" is called "Opaque".
3074 Examples of suitable formats for Transparent copies include plain
3075 ASCII without markup, Texinfo input format, LaTeX input format,
3076 SGML or XML using a publicly available DTD, and
3077 standard-conforming simple HTML, PostScript or PDF designed for
3078 human modification. Examples of transparent image formats include
3079 PNG, XCF and JPG. Opaque formats include proprietary formats that
3080 can be read and edited only by proprietary word processors, SGML or
3081 XML for which the DTD and/or processing tools are not generally
3082 available, and the machine-generated HTML, PostScript or PDF
3083 produced by some word processors for output purposes only.
3085 The "Title Page" means, for a printed book, the title page itself,
3086 plus such following pages as are needed to hold, legibly, the
3087 material this License requires to appear in the title page. For
3088 works in formats which do not have any title page as such, "Title
3089 Page" means the text near the most prominent appearance of the
3090 work's title, preceding the beginning of the body of the text.
3092 A section "Entitled XYZ" means a named subunit of the Document
3093 whose title either is precisely XYZ or contains XYZ in parentheses
3094 following text that translates XYZ in another language. (Here XYZ
3095 stands for a specific section name mentioned below, such as
3096 "Acknowledgements", "Dedications", "Endorsements", or "History".)
3097 To "Preserve the Title" of such a section when you modify the
3098 Document means that it remains a section "Entitled XYZ" according
3101 The Document may include Warranty Disclaimers next to the notice
3102 which states that this License applies to the Document. These
3103 Warranty Disclaimers are considered to be included by reference in
3104 this License, but only as regards disclaiming warranties: any other
3105 implication that these Warranty Disclaimers may have is void and
3106 has no effect on the meaning of this License.
3110 You may copy and distribute the Document in any medium, either
3111 commercially or noncommercially, provided that this License, the
3112 copyright notices, and the license notice saying this License
3113 applies to the Document are reproduced in all copies, and that you
3114 add no other conditions whatsoever to those of this License. You
3115 may not use technical measures to obstruct or control the reading
3116 or further copying of the copies you make or distribute. However,
3117 you may accept compensation in exchange for copies. If you
3118 distribute a large enough number of copies you must also follow
3119 the conditions in section 3.
3121 You may also lend copies, under the same conditions stated above,
3122 and you may publicly display copies.
3124 3. COPYING IN QUANTITY
3126 If you publish printed copies (or copies in media that commonly
3127 have printed covers) of the Document, numbering more than 100, and
3128 the Document's license notice requires Cover Texts, you must
3129 enclose the copies in covers that carry, clearly and legibly, all
3130 these Cover Texts: Front-Cover Texts on the front cover, and
3131 Back-Cover Texts on the back cover. Both covers must also clearly
3132 and legibly identify you as the publisher of these copies. The
3133 front cover must present the full title with all words of the
3134 title equally prominent and visible. You may add other material
3135 on the covers in addition. Copying with changes limited to the
3136 covers, as long as they preserve the title of the Document and
3137 satisfy these conditions, can be treated as verbatim copying in
3140 If the required texts for either cover are too voluminous to fit
3141 legibly, you should put the first ones listed (as many as fit
3142 reasonably) on the actual cover, and continue the rest onto
3145 If you publish or distribute Opaque copies of the Document
3146 numbering more than 100, you must either include a
3147 machine-readable Transparent copy along with each Opaque copy, or
3148 state in or with each Opaque copy a computer-network location from
3149 which the general network-using public has access to download
3150 using public-standard network protocols a complete Transparent
3151 copy of the Document, free of added material. If you use the
3152 latter option, you must take reasonably prudent steps, when you
3153 begin distribution of Opaque copies in quantity, to ensure that
3154 this Transparent copy will remain thus accessible at the stated
3155 location until at least one year after the last time you
3156 distribute an Opaque copy (directly or through your agents or
3157 retailers) of that edition to the public.
3159 It is requested, but not required, that you contact the authors of
3160 the Document well before redistributing any large number of
3161 copies, to give them a chance to provide you with an updated
3162 version of the Document.
3166 You may copy and distribute a Modified Version of the Document
3167 under the conditions of sections 2 and 3 above, provided that you
3168 release the Modified Version under precisely this License, with
3169 the Modified Version filling the role of the Document, thus
3170 licensing distribution and modification of the Modified Version to
3171 whoever possesses a copy of it. In addition, you must do these
3172 things in the Modified Version:
3174 A. Use in the Title Page (and on the covers, if any) a title
3175 distinct from that of the Document, and from those of
3176 previous versions (which should, if there were any, be listed
3177 in the History section of the Document). You may use the
3178 same title as a previous version if the original publisher of
3179 that version gives permission.
3181 B. List on the Title Page, as authors, one or more persons or
3182 entities responsible for authorship of the modifications in
3183 the Modified Version, together with at least five of the
3184 principal authors of the Document (all of its principal
3185 authors, if it has fewer than five), unless they release you
3186 from this requirement.
3188 C. State on the Title page the name of the publisher of the
3189 Modified Version, as the publisher.
3191 D. Preserve all the copyright notices of the Document.
3193 E. Add an appropriate copyright notice for your modifications
3194 adjacent to the other copyright notices.
3196 F. Include, immediately after the copyright notices, a license
3197 notice giving the public permission to use the Modified
3198 Version under the terms of this License, in the form shown in
3201 G. Preserve in that license notice the full lists of Invariant
3202 Sections and required Cover Texts given in the Document's
3205 H. Include an unaltered copy of this License.
3207 I. Preserve the section Entitled "History", Preserve its Title,
3208 and add to it an item stating at least the title, year, new
3209 authors, and publisher of the Modified Version as given on
3210 the Title Page. If there is no section Entitled "History" in
3211 the Document, create one stating the title, year, authors,
3212 and publisher of the Document as given on its Title Page,
3213 then add an item describing the Modified Version as stated in
3214 the previous sentence.
3216 J. Preserve the network location, if any, given in the Document
3217 for public access to a Transparent copy of the Document, and
3218 likewise the network locations given in the Document for
3219 previous versions it was based on. These may be placed in
3220 the "History" section. You may omit a network location for a
3221 work that was published at least four years before the
3222 Document itself, or if the original publisher of the version
3223 it refers to gives permission.
3225 K. For any section Entitled "Acknowledgements" or "Dedications",
3226 Preserve the Title of the section, and preserve in the
3227 section all the substance and tone of each of the contributor
3228 acknowledgements and/or dedications given therein.
3230 L. Preserve all the Invariant Sections of the Document,
3231 unaltered in their text and in their titles. Section numbers
3232 or the equivalent are not considered part of the section
3235 M. Delete any section Entitled "Endorsements". Such a section
3236 may not be included in the Modified Version.
3238 N. Do not retitle any existing section to be Entitled
3239 "Endorsements" or to conflict in title with any Invariant
3242 O. Preserve any Warranty Disclaimers.
3244 If the Modified Version includes new front-matter sections or
3245 appendices that qualify as Secondary Sections and contain no
3246 material copied from the Document, you may at your option
3247 designate some or all of these sections as invariant. To do this,
3248 add their titles to the list of Invariant Sections in the Modified
3249 Version's license notice. These titles must be distinct from any
3250 other section titles.
3252 You may add a section Entitled "Endorsements", provided it contains
3253 nothing but endorsements of your Modified Version by various
3254 parties--for example, statements of peer review or that the text
3255 has been approved by an organization as the authoritative
3256 definition of a standard.
3258 You may add a passage of up to five words as a Front-Cover Text,
3259 and a passage of up to 25 words as a Back-Cover Text, to the end
3260 of the list of Cover Texts in the Modified Version. Only one
3261 passage of Front-Cover Text and one of Back-Cover Text may be
3262 added by (or through arrangements made by) any one entity. If the
3263 Document already includes a cover text for the same cover,
3264 previously added by you or by arrangement made by the same entity
3265 you are acting on behalf of, you may not add another; but you may
3266 replace the old one, on explicit permission from the previous
3267 publisher that added the old one.
3269 The author(s) and publisher(s) of the Document do not by this
3270 License give permission to use their names for publicity for or to
3271 assert or imply endorsement of any Modified Version.
3273 5. COMBINING DOCUMENTS
3275 You may combine the Document with other documents released under
3276 this License, under the terms defined in section 4 above for
3277 modified versions, provided that you include in the combination
3278 all of the Invariant Sections of all of the original documents,
3279 unmodified, and list them all as Invariant Sections of your
3280 combined work in its license notice, and that you preserve all
3281 their Warranty Disclaimers.
3283 The combined work need only contain one copy of this License, and
3284 multiple identical Invariant Sections may be replaced with a single
3285 copy. If there are multiple Invariant Sections with the same name
3286 but different contents, make the title of each such section unique
3287 by adding at the end of it, in parentheses, the name of the
3288 original author or publisher of that section if known, or else a
3289 unique number. Make the same adjustment to the section titles in
3290 the list of Invariant Sections in the license notice of the
3293 In the combination, you must combine any sections Entitled
3294 "History" in the various original documents, forming one section
3295 Entitled "History"; likewise combine any sections Entitled
3296 "Acknowledgements", and any sections Entitled "Dedications". You
3297 must delete all sections Entitled "Endorsements."
3299 6. COLLECTIONS OF DOCUMENTS
3301 You may make a collection consisting of the Document and other
3302 documents released under this License, and replace the individual
3303 copies of this License in the various documents with a single copy
3304 that is included in the collection, provided that you follow the
3305 rules of this License for verbatim copying of each of the
3306 documents in all other respects.
3308 You may extract a single document from such a collection, and
3309 distribute it individually under this License, provided you insert
3310 a copy of this License into the extracted document, and follow
3311 this License in all other respects regarding verbatim copying of
3314 7. AGGREGATION WITH INDEPENDENT WORKS
3316 A compilation of the Document or its derivatives with other
3317 separate and independent documents or works, in or on a volume of
3318 a storage or distribution medium, is called an "aggregate" if the
3319 copyright resulting from the compilation is not used to limit the
3320 legal rights of the compilation's users beyond what the individual
3321 works permit. When the Document is included in an aggregate, this
3322 License does not apply to the other works in the aggregate which
3323 are not themselves derivative works of the Document.
3325 If the Cover Text requirement of section 3 is applicable to these
3326 copies of the Document, then if the Document is less than one half
3327 of the entire aggregate, the Document's Cover Texts may be placed
3328 on covers that bracket the Document within the aggregate, or the
3329 electronic equivalent of covers if the Document is in electronic
3330 form. Otherwise they must appear on printed covers that bracket
3331 the whole aggregate.
3335 Translation is considered a kind of modification, so you may
3336 distribute translations of the Document under the terms of section
3337 4. Replacing Invariant Sections with translations requires special
3338 permission from their copyright holders, but you may include
3339 translations of some or all Invariant Sections in addition to the
3340 original versions of these Invariant Sections. You may include a
3341 translation of this License, and all the license notices in the
3342 Document, and any Warranty Disclaimers, provided that you also
3343 include the original English version of this License and the
3344 original versions of those notices and disclaimers. In case of a
3345 disagreement between the translation and the original version of
3346 this License or a notice or disclaimer, the original version will
3349 If a section in the Document is Entitled "Acknowledgements",
3350 "Dedications", or "History", the requirement (section 4) to
3351 Preserve its Title (section 1) will typically require changing the
3356 You may not copy, modify, sublicense, or distribute the Document
3357 except as expressly provided for under this License. Any other
3358 attempt to copy, modify, sublicense or distribute the Document is
3359 void, and will automatically terminate your rights under this
3360 License. However, parties who have received copies, or rights,
3361 from you under this License will not have their licenses
3362 terminated so long as such parties remain in full compliance.
3364 10. FUTURE REVISIONS OF THIS LICENSE
3366 The Free Software Foundation may publish new, revised versions of
3367 the GNU Free Documentation License from time to time. Such new
3368 versions will be similar in spirit to the present version, but may
3369 differ in detail to address new problems or concerns. See
3370 `http://www.gnu.org/copyleft/'.
3372 Each version of the License is given a distinguishing version
3373 number. If the Document specifies that a particular numbered
3374 version of this License "or any later version" applies to it, you
3375 have the option of following the terms and conditions either of
3376 that specified version or of any later version that has been
3377 published (not as a draft) by the Free Software Foundation. If
3378 the Document does not specify a version number of this License,
3379 you may choose any version ever published (not as a draft) by the
3380 Free Software Foundation.
3382 A.1 ADDENDUM: How to Use This License For Your Documents
3383 ========================================================
3385 To use this License in a document you have written, include a copy of
3386 the License in the document and put the following copyright and license
3387 notices just after the title page:
3389 Copyright (C) YEAR YOUR NAME.
3390 Permission is granted to copy, distribute and/or modify this document
3391 under the terms of the GNU Free Documentation License, Version 1.2
3392 or any later version published by the Free Software Foundation;
3393 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
3394 Texts. A copy of the license is included in the section entitled ``GNU
3395 Free Documentation License''.
3397 If you have Invariant Sections, Front-Cover Texts and Back-Cover
3398 Texts, replace the "with...Texts." line with this:
3400 with the Invariant Sections being LIST THEIR TITLES, with
3401 the Front-Cover Texts being LIST, and with the Back-Cover Texts
3404 If you have Invariant Sections without Cover Texts, or some other
3405 combination of the three, merge those two alternatives to suit the
3408 If your document contains nontrivial examples of program code, we
3409 recommend releasing these examples in parallel under your choice of
3410 free software license, such as the GNU General Public License, to
3411 permit their use in free software.
3414 File: mpfr.info, Node: Concept Index, Next: Function Index, Prev: GNU Free Documentation License, Up: Top
3422 * Accuracy: MPFR Interface. (line 25)
3423 * Arithmetic functions: Basic Arithmetic Functions.
3425 * Assignment functions: Assignment Functions. (line 3)
3426 * Basic arithmetic functions: Basic Arithmetic Functions.
3428 * Combined initialization and assignment functions: Combined Initialization and Assignment Functions.
3430 * Comparison functions: Comparison Functions. (line 3)
3431 * Compatibility with MPF: Compatibility with MPF.
3433 * Conditions for copying MPFR: Copying. (line 6)
3434 * Conversion functions: Conversion Functions. (line 3)
3435 * Copying conditions: Copying. (line 6)
3436 * Custom interface: Custom Interface. (line 3)
3437 * Exception related functions: Exception Related Functions.
3439 * Float arithmetic functions: Basic Arithmetic Functions.
3441 * Float comparisons functions: Comparison Functions. (line 3)
3442 * Float functions: MPFR Interface. (line 6)
3443 * Float input and output functions: Input and Output Functions.
3445 * Float output functions: Formatted Output Functions.
3447 * Floating-point functions: MPFR Interface. (line 6)
3448 * Floating-point number: MPFR Basics. (line 70)
3449 * GNU Free Documentation License: GNU Free Documentation License.
3451 * I/O functions <1>: Formatted Output Functions.
3453 * I/O functions: Input and Output Functions.
3455 * Initialization functions: Initialization Functions.
3457 * Input functions: Input and Output Functions.
3459 * Installation: Installing MPFR. (line 6)
3460 * Integer related functions: Integer Related Functions.
3462 * Internals: Internals. (line 3)
3463 * intmax_t: MPFR Basics. (line 25)
3464 * inttypes.h: MPFR Basics. (line 25)
3465 * libmpfr: MPFR Basics. (line 50)
3466 * Libraries: MPFR Basics. (line 50)
3467 * Libtool: MPFR Basics. (line 56)
3468 * Limb: Internals. (line 6)
3469 * Linking: MPFR Basics. (line 50)
3470 * Miscellaneous float functions: Miscellaneous Functions.
3472 * mpfr.h: MPFR Basics. (line 9)
3473 * Output functions <1>: Formatted Output Functions.
3475 * Output functions: Input and Output Functions.
3477 * Precision <1>: MPFR Interface. (line 17)
3478 * Precision: MPFR Basics. (line 84)
3479 * Reporting bugs: Reporting Bugs. (line 6)
3480 * Rounding mode related functions: Rounding Related Functions.
3482 * Rounding Modes: MPFR Basics. (line 98)
3483 * Special functions: Special Functions. (line 3)
3484 * stdarg.h: MPFR Basics. (line 22)
3485 * stdint.h: MPFR Basics. (line 25)
3486 * stdio.h: MPFR Basics. (line 15)
3487 * uintmax_t: MPFR Basics. (line 25)
3490 File: mpfr.info, Node: Function Index, Prev: Concept Index, Up: Top
3492 Function and Type Index
3493 ***********************
3498 * mpfr_abs: Basic Arithmetic Functions.
3500 * mpfr_acos: Special Functions. (line 53)
3501 * mpfr_acosh: Special Functions. (line 137)
3502 * mpfr_add: Basic Arithmetic Functions.
3504 * mpfr_add_d: Basic Arithmetic Functions.
3506 * mpfr_add_q: Basic Arithmetic Functions.
3508 * mpfr_add_si: Basic Arithmetic Functions.
3510 * mpfr_add_ui: Basic Arithmetic Functions.
3512 * mpfr_add_z: Basic Arithmetic Functions.
3514 * mpfr_agm: Special Functions. (line 230)
3515 * mpfr_ai: Special Functions. (line 246)
3516 * mpfr_asin: Special Functions. (line 54)
3517 * mpfr_asinh: Special Functions. (line 138)
3518 * mpfr_asprintf: Formatted Output Functions.
3520 * mpfr_atan: Special Functions. (line 55)
3521 * mpfr_atan2: Special Functions. (line 66)
3522 * mpfr_atanh: Special Functions. (line 139)
3523 * mpfr_buildopt_decimal_p: Miscellaneous Functions.
3525 * mpfr_buildopt_tls_p: Miscellaneous Functions.
3527 * mpfr_can_round: Rounding Related Functions.
3529 * mpfr_cbrt: Basic Arithmetic Functions.
3531 * mpfr_ceil: Integer Related Functions.
3533 * mpfr_check_range: Exception Related Functions.
3535 * mpfr_clear: Initialization Functions.
3537 * mpfr_clear_erangeflag: Exception Related Functions.
3539 * mpfr_clear_flags: Exception Related Functions.
3541 * mpfr_clear_inexflag: Exception Related Functions.
3543 * mpfr_clear_nanflag: Exception Related Functions.
3545 * mpfr_clear_overflow: Exception Related Functions.
3547 * mpfr_clear_underflow: Exception Related Functions.
3549 * mpfr_clears: Initialization Functions.
3551 * mpfr_cmp: Comparison Functions.
3553 * mpfr_cmp_d: Comparison Functions.
3555 * mpfr_cmp_f: Comparison Functions.
3557 * mpfr_cmp_ld: Comparison Functions.
3559 * mpfr_cmp_q: Comparison Functions.
3561 * mpfr_cmp_si: Comparison Functions.
3563 * mpfr_cmp_si_2exp: Comparison Functions.
3565 * mpfr_cmp_ui: Comparison Functions.
3567 * mpfr_cmp_ui_2exp: Comparison Functions.
3569 * mpfr_cmp_z: Comparison Functions.
3571 * mpfr_cmpabs: Comparison Functions.
3573 * mpfr_const_catalan: Special Functions. (line 257)
3574 * mpfr_const_euler: Special Functions. (line 256)
3575 * mpfr_const_log2: Special Functions. (line 254)
3576 * mpfr_const_pi: Special Functions. (line 255)
3577 * mpfr_copysign: Miscellaneous Functions.
3579 * mpfr_cos: Special Functions. (line 31)
3580 * mpfr_cosh: Special Functions. (line 116)
3581 * mpfr_cot: Special Functions. (line 49)
3582 * mpfr_coth: Special Functions. (line 133)
3583 * mpfr_csc: Special Functions. (line 48)
3584 * mpfr_csch: Special Functions. (line 132)
3585 * mpfr_custom_get_exp: Custom Interface. (line 78)
3586 * mpfr_custom_get_kind: Custom Interface. (line 67)
3587 * mpfr_custom_get_significand: Custom Interface. (line 72)
3588 * mpfr_custom_get_size: Custom Interface. (line 36)
3589 * mpfr_custom_init: Custom Interface. (line 41)
3590 * mpfr_custom_init_set: Custom Interface. (line 48)
3591 * mpfr_custom_move: Custom Interface. (line 85)
3592 * mpfr_d_div: Basic Arithmetic Functions.
3594 * mpfr_d_sub: Basic Arithmetic Functions.
3596 * MPFR_DECL_INIT: Initialization Functions.
3598 * mpfr_digamma: Special Functions. (line 185)
3599 * mpfr_dim: Basic Arithmetic Functions.
3601 * mpfr_div: Basic Arithmetic Functions.
3603 * mpfr_div_2exp: Compatibility with MPF.
3605 * mpfr_div_2si: Basic Arithmetic Functions.
3607 * mpfr_div_2ui: Basic Arithmetic Functions.
3609 * mpfr_div_d: Basic Arithmetic Functions.
3611 * mpfr_div_q: Basic Arithmetic Functions.
3613 * mpfr_div_si: Basic Arithmetic Functions.
3615 * mpfr_div_ui: Basic Arithmetic Functions.
3617 * mpfr_div_z: Basic Arithmetic Functions.
3619 * mpfr_eint: Special Functions. (line 155)
3620 * mpfr_eq: Compatibility with MPF.
3622 * mpfr_equal_p: Comparison Functions.
3624 * mpfr_erangeflag_p: Exception Related Functions.
3626 * mpfr_erf: Special Functions. (line 196)
3627 * mpfr_erfc: Special Functions. (line 197)
3628 * mpfr_exp: Special Functions. (line 25)
3629 * mpfr_exp10: Special Functions. (line 27)
3630 * mpfr_exp2: Special Functions. (line 26)
3631 * mpfr_expm1: Special Functions. (line 151)
3632 * mpfr_fac_ui: Special Functions. (line 144)
3633 * mpfr_fits_intmax_p: Conversion Functions.
3635 * mpfr_fits_sint_p: Conversion Functions.
3637 * mpfr_fits_slong_p: Conversion Functions.
3639 * mpfr_fits_sshort_p: Conversion Functions.
3641 * mpfr_fits_uint_p: Conversion Functions.
3643 * mpfr_fits_uintmax_p: Conversion Functions.
3645 * mpfr_fits_ulong_p: Conversion Functions.
3647 * mpfr_fits_ushort_p: Conversion Functions.
3649 * mpfr_floor: Integer Related Functions.
3651 * mpfr_fma: Special Functions. (line 223)
3652 * mpfr_fmod: Integer Related Functions.
3654 * mpfr_fms: Special Functions. (line 225)
3655 * mpfr_fprintf: Formatted Output Functions.
3657 * mpfr_frac: Integer Related Functions.
3659 * mpfr_free_cache: Special Functions. (line 264)
3660 * mpfr_free_str: Conversion Functions.
3662 * mpfr_gamma: Special Functions. (line 167)
3663 * mpfr_get_d: Conversion Functions.
3665 * mpfr_get_d_2exp: Conversion Functions.
3667 * mpfr_get_decimal64: Conversion Functions.
3669 * mpfr_get_default_prec: Initialization Functions.
3671 * mpfr_get_default_rounding_mode: Rounding Related Functions.
3673 * mpfr_get_emax: Exception Related Functions.
3675 * mpfr_get_emax_max: Exception Related Functions.
3677 * mpfr_get_emax_min: Exception Related Functions.
3679 * mpfr_get_emin: Exception Related Functions.
3681 * mpfr_get_emin_max: Exception Related Functions.
3683 * mpfr_get_emin_min: Exception Related Functions.
3685 * mpfr_get_exp: Miscellaneous Functions.
3687 * mpfr_get_f: Conversion Functions.
3689 * mpfr_get_flt: Conversion Functions.
3691 * mpfr_get_ld: Conversion Functions.
3693 * mpfr_get_ld_2exp: Conversion Functions.
3695 * mpfr_get_patches: Miscellaneous Functions.
3697 * mpfr_get_prec: Initialization Functions.
3699 * mpfr_get_si: Conversion Functions.
3701 * mpfr_get_sj: Conversion Functions.
3703 * mpfr_get_str: Conversion Functions.
3705 * mpfr_get_ui: Conversion Functions.
3707 * mpfr_get_uj: Conversion Functions.
3709 * mpfr_get_version: Miscellaneous Functions.
3711 * mpfr_get_z: Conversion Functions.
3713 * mpfr_get_z_2exp: Conversion Functions.
3715 * mpfr_greater_p: Comparison Functions.
3717 * mpfr_greaterequal_p: Comparison Functions.
3719 * mpfr_hypot: Special Functions. (line 239)
3720 * mpfr_inexflag_p: Exception Related Functions.
3722 * mpfr_inf_p: Comparison Functions.
3724 * mpfr_init: Initialization Functions.
3726 * mpfr_init2: Initialization Functions.
3728 * mpfr_init_set: Combined Initialization and Assignment Functions.
3730 * mpfr_init_set_d: Combined Initialization and Assignment Functions.
3732 * mpfr_init_set_f: Combined Initialization and Assignment Functions.
3734 * mpfr_init_set_ld: Combined Initialization and Assignment Functions.
3736 * mpfr_init_set_q: Combined Initialization and Assignment Functions.
3738 * mpfr_init_set_si: Combined Initialization and Assignment Functions.
3740 * mpfr_init_set_str: Combined Initialization and Assignment Functions.
3742 * mpfr_init_set_ui: Combined Initialization and Assignment Functions.
3744 * mpfr_init_set_z: Combined Initialization and Assignment Functions.
3746 * mpfr_inits: Initialization Functions.
3748 * mpfr_inits2: Initialization Functions.
3750 * mpfr_inp_str: Input and Output Functions.
3752 * mpfr_integer_p: Integer Related Functions.
3754 * mpfr_j0: Special Functions. (line 201)
3755 * mpfr_j1: Special Functions. (line 202)
3756 * mpfr_jn: Special Functions. (line 204)
3757 * mpfr_less_p: Comparison Functions.
3759 * mpfr_lessequal_p: Comparison Functions.
3761 * mpfr_lessgreater_p: Comparison Functions.
3763 * mpfr_lgamma: Special Functions. (line 177)
3764 * mpfr_li2: Special Functions. (line 162)
3765 * mpfr_lngamma: Special Functions. (line 171)
3766 * mpfr_log: Special Functions. (line 18)
3767 * mpfr_log10: Special Functions. (line 20)
3768 * mpfr_log1p: Special Functions. (line 147)
3769 * mpfr_log2: Special Functions. (line 19)
3770 * mpfr_max: Miscellaneous Functions.
3772 * mpfr_min: Miscellaneous Functions.
3774 * mpfr_min_prec: Rounding Related Functions.
3776 * mpfr_modf: Integer Related Functions.
3778 * mpfr_mul: Basic Arithmetic Functions.
3780 * mpfr_mul_2exp: Compatibility with MPF.
3782 * mpfr_mul_2si: Basic Arithmetic Functions.
3784 * mpfr_mul_2ui: Basic Arithmetic Functions.
3786 * mpfr_mul_d: Basic Arithmetic Functions.
3788 * mpfr_mul_q: Basic Arithmetic Functions.
3790 * mpfr_mul_si: Basic Arithmetic Functions.
3792 * mpfr_mul_ui: Basic Arithmetic Functions.
3794 * mpfr_mul_z: Basic Arithmetic Functions.
3796 * mpfr_nan_p: Comparison Functions.
3798 * mpfr_nanflag_p: Exception Related Functions.
3800 * mpfr_neg: Basic Arithmetic Functions.
3802 * mpfr_nextabove: Miscellaneous Functions.
3804 * mpfr_nextbelow: Miscellaneous Functions.
3806 * mpfr_nexttoward: Miscellaneous Functions.
3808 * mpfr_number_p: Comparison Functions.
3810 * mpfr_out_str: Input and Output Functions.
3812 * mpfr_overflow_p: Exception Related Functions.
3814 * mpfr_pow: Basic Arithmetic Functions.
3816 * mpfr_pow_si: Basic Arithmetic Functions.
3818 * mpfr_pow_ui: Basic Arithmetic Functions.
3820 * mpfr_pow_z: Basic Arithmetic Functions.
3822 * mpfr_prec_round: Rounding Related Functions.
3824 * mpfr_prec_t: MPFR Basics. (line 84)
3825 * mpfr_print_rnd_mode: Rounding Related Functions.
3827 * mpfr_printf: Formatted Output Functions.
3829 * mpfr_rec_sqrt: Basic Arithmetic Functions.
3831 * mpfr_regular_p: Comparison Functions.
3833 * mpfr_reldiff: Compatibility with MPF.
3835 * mpfr_remainder: Integer Related Functions.
3837 * mpfr_remquo: Integer Related Functions.
3839 * mpfr_rint: Integer Related Functions.
3841 * mpfr_rint_ceil: Integer Related Functions.
3843 * mpfr_rint_floor: Integer Related Functions.
3845 * mpfr_rint_round: Integer Related Functions.
3847 * mpfr_rint_trunc: Integer Related Functions.
3849 * mpfr_rnd_t: MPFR Basics. (line 98)
3850 * mpfr_root: Basic Arithmetic Functions.
3852 * mpfr_round: Integer Related Functions.
3854 * mpfr_sec: Special Functions. (line 47)
3855 * mpfr_sech: Special Functions. (line 131)
3856 * mpfr_set: Assignment Functions.
3858 * mpfr_set_d: Assignment Functions.
3860 * mpfr_set_decimal64: Assignment Functions.
3862 * mpfr_set_default_prec: Initialization Functions.
3864 * mpfr_set_default_rounding_mode: Rounding Related Functions.
3866 * mpfr_set_emax: Exception Related Functions.
3868 * mpfr_set_emin: Exception Related Functions.
3870 * mpfr_set_erangeflag: Exception Related Functions.
3872 * mpfr_set_exp: Miscellaneous Functions.
3874 * mpfr_set_f: Assignment Functions.
3876 * mpfr_set_flt: Assignment Functions.
3878 * mpfr_set_inexflag: Exception Related Functions.
3880 * mpfr_set_inf: Assignment Functions.
3882 * mpfr_set_ld: Assignment Functions.
3884 * mpfr_set_nan: Assignment Functions.
3886 * mpfr_set_nanflag: Exception Related Functions.
3888 * mpfr_set_overflow: Exception Related Functions.
3890 * mpfr_set_prec: Initialization Functions.
3892 * mpfr_set_prec_raw: Compatibility with MPF.
3894 * mpfr_set_q: Assignment Functions.
3896 * mpfr_set_si: Assignment Functions.
3898 * mpfr_set_si_2exp: Assignment Functions.
3900 * mpfr_set_sj: Assignment Functions.
3902 * mpfr_set_sj_2exp: Assignment Functions.
3904 * mpfr_set_str: Assignment Functions.
3906 * mpfr_set_ui: Assignment Functions.
3908 * mpfr_set_ui_2exp: Assignment Functions.
3910 * mpfr_set_uj: Assignment Functions.
3912 * mpfr_set_uj_2exp: Assignment Functions.
3914 * mpfr_set_underflow: Exception Related Functions.
3916 * mpfr_set_z: Assignment Functions.
3918 * mpfr_set_z_2exp: Assignment Functions.
3920 * mpfr_set_zero: Assignment Functions.
3922 * mpfr_setsign: Miscellaneous Functions.
3924 * mpfr_sgn: Comparison Functions.
3926 * mpfr_si_div: Basic Arithmetic Functions.
3928 * mpfr_si_sub: Basic Arithmetic Functions.
3930 * mpfr_signbit: Miscellaneous Functions.
3932 * mpfr_sin: Special Functions. (line 32)
3933 * mpfr_sin_cos: Special Functions. (line 38)
3934 * mpfr_sinh: Special Functions. (line 117)
3935 * mpfr_sinh_cosh: Special Functions. (line 123)
3936 * mpfr_snprintf: Formatted Output Functions.
3938 * mpfr_sprintf: Formatted Output Functions.
3940 * mpfr_sqr: Basic Arithmetic Functions.
3942 * mpfr_sqrt: Basic Arithmetic Functions.
3944 * mpfr_sqrt_ui: Basic Arithmetic Functions.
3946 * mpfr_strtofr: Assignment Functions.
3948 * mpfr_sub: Basic Arithmetic Functions.
3950 * mpfr_sub_d: Basic Arithmetic Functions.
3952 * mpfr_sub_q: Basic Arithmetic Functions.
3954 * mpfr_sub_si: Basic Arithmetic Functions.
3956 * mpfr_sub_ui: Basic Arithmetic Functions.
3958 * mpfr_sub_z: Basic Arithmetic Functions.
3960 * mpfr_subnormalize: Exception Related Functions.
3962 * mpfr_sum: Special Functions. (line 273)
3963 * mpfr_swap: Assignment Functions.
3965 * mpfr_t: MPFR Basics. (line 70)
3966 * mpfr_tan: Special Functions. (line 33)
3967 * mpfr_tanh: Special Functions. (line 118)
3968 * mpfr_trunc: Integer Related Functions.
3970 * mpfr_ui_div: Basic Arithmetic Functions.
3972 * mpfr_ui_pow: Basic Arithmetic Functions.
3974 * mpfr_ui_pow_ui: Basic Arithmetic Functions.
3976 * mpfr_ui_sub: Basic Arithmetic Functions.
3978 * mpfr_underflow_p: Exception Related Functions.
3980 * mpfr_unordered_p: Comparison Functions.
3982 * mpfr_urandom: Miscellaneous Functions.
3984 * mpfr_urandomb: Miscellaneous Functions.
3986 * mpfr_vasprintf: Formatted Output Functions.
3988 * MPFR_VERSION: Miscellaneous Functions.
3990 * MPFR_VERSION_MAJOR: Miscellaneous Functions.
3992 * MPFR_VERSION_MINOR: Miscellaneous Functions.
3994 * MPFR_VERSION_NUM: Miscellaneous Functions.
3996 * MPFR_VERSION_PATCHLEVEL: Miscellaneous Functions.
3998 * MPFR_VERSION_STRING: Miscellaneous Functions.
4000 * mpfr_vfprintf: Formatted Output Functions.
4002 * mpfr_vprintf: Formatted Output Functions.
4004 * mpfr_vsnprintf: Formatted Output Functions.
4006 * mpfr_vsprintf: Formatted Output Functions.
4008 * mpfr_y0: Special Functions. (line 212)
4009 * mpfr_y1: Special Functions. (line 213)
4010 * mpfr_yn: Special Functions. (line 215)
4011 * mpfr_zero_p: Comparison Functions.
4013 * mpfr_zeta: Special Functions. (line 190)
4014 * mpfr_zeta_ui: Special Functions. (line 192)
4020 Node: Copying
\x7f2210
4021 Node: Introduction to MPFR
\x7f3970
4022 Node: Installing MPFR
\x7f6059
4023 Node: Reporting Bugs
\x7f10798
4024 Node: MPFR Basics
\x7f12593
4025 Node: MPFR Interface
\x7f28132
4026 Node: Initialization Functions
\x7f30228
4027 Node: Assignment Functions
\x7f36901
4028 Node: Combined Initialization and Assignment Functions
\x7f45248
4029 Node: Conversion Functions
\x7f46541
4030 Node: Basic Arithmetic Functions
\x7f54013
4031 Node: Comparison Functions
\x7f62930
4032 Node: Special Functions
\x7f66412
4033 Node: Input and Output Functions
\x7f80001
4034 Node: Formatted Output Functions
\x7f81924
4035 Node: Integer Related Functions
\x7f91023
4036 Node: Rounding Related Functions
\x7f96785
4037 Node: Miscellaneous Functions
\x7f100391
4038 Node: Exception Related Functions
\x7f106952
4039 Node: Compatibility with MPF
\x7f113486
4040 Node: Custom Interface
\x7f116174
4041 Node: Internals
\x7f120419
4042 Node: API Compatibility
\x7f121903
4043 Node: Type and Macro Changes
\x7f123833
4044 Node: Added Functions
\x7f126554
4045 Node: Changed Functions
\x7f129075
4046 Node: Removed Functions
\x7f132799
4047 Node: Other Changes
\x7f133211
4048 Node: Contributors
\x7f134385
4049 Node: References
\x7f136705
4050 Node: GNU Free Documentation License
\x7f138446
4051 Node: Concept Index
\x7f160889
4052 Node: Function Index
\x7f165827