14a238c70SJohn MarinoThis is mpfr.info, produced by makeinfo version 4.13 from mpfr.texi. 24a238c70SJohn Marino 34a238c70SJohn MarinoThis manual documents how to install and use the Multiple Precision 4*ab6d115fSJohn MarinoFloating-Point Reliable Library, version 3.1.2. 54a238c70SJohn Marino 64a238c70SJohn Marino Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 7*ab6d115fSJohn Marino2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 8*ab6d115fSJohn Marino2013 Free Software Foundation, Inc. 94a238c70SJohn Marino 104a238c70SJohn Marino Permission is granted to copy, distribute and/or modify this 114a238c70SJohn Marinodocument under the terms of the GNU Free Documentation License, Version 124a238c70SJohn Marino1.2 or any later version published by the Free Software Foundation; 134a238c70SJohn Marinowith no Invariant Sections, with no Front-Cover Texts, and with no 144a238c70SJohn MarinoBack-Cover Texts. A copy of the license is included in *note GNU Free 154a238c70SJohn MarinoDocumentation License::. 164a238c70SJohn Marino 174a238c70SJohn MarinoINFO-DIR-SECTION Software libraries 184a238c70SJohn MarinoSTART-INFO-DIR-ENTRY 194a238c70SJohn Marino* mpfr: (mpfr). Multiple Precision Floating-Point Reliable Library. 204a238c70SJohn MarinoEND-INFO-DIR-ENTRY 214a238c70SJohn Marino 224a238c70SJohn Marino 234a238c70SJohn MarinoFile: mpfr.info, Node: Top, Next: Copying, Prev: (dir), Up: (dir) 244a238c70SJohn Marino 254a238c70SJohn MarinoGNU MPFR 264a238c70SJohn Marino******** 274a238c70SJohn Marino 284a238c70SJohn Marino This manual documents how to install and use the Multiple Precision 29*ab6d115fSJohn MarinoFloating-Point Reliable Library, version 3.1.2. 304a238c70SJohn Marino 314a238c70SJohn Marino Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 32*ab6d115fSJohn Marino2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 33*ab6d115fSJohn Marino2013 Free Software Foundation, Inc. 344a238c70SJohn Marino 354a238c70SJohn Marino Permission is granted to copy, distribute and/or modify this 364a238c70SJohn Marinodocument under the terms of the GNU Free Documentation License, Version 374a238c70SJohn Marino1.2 or any later version published by the Free Software Foundation; 384a238c70SJohn Marinowith no Invariant Sections, with no Front-Cover Texts, and with no 394a238c70SJohn MarinoBack-Cover Texts. A copy of the license is included in *note GNU Free 404a238c70SJohn MarinoDocumentation License::. 414a238c70SJohn Marino 424a238c70SJohn Marino 434a238c70SJohn Marino* Menu: 444a238c70SJohn Marino 454a238c70SJohn Marino* Copying:: MPFR Copying Conditions (LGPL). 464a238c70SJohn Marino* Introduction to MPFR:: Brief introduction to GNU MPFR. 474a238c70SJohn Marino* Installing MPFR:: How to configure and compile the MPFR library. 484a238c70SJohn Marino* Reporting Bugs:: How to usefully report bugs. 494a238c70SJohn Marino* MPFR Basics:: What every MPFR user should now. 504a238c70SJohn Marino* MPFR Interface:: MPFR functions and macros. 514a238c70SJohn Marino* API Compatibility:: API compatibility with previous MPFR versions. 524a238c70SJohn Marino* Contributors:: 534a238c70SJohn Marino* References:: 544a238c70SJohn Marino* GNU Free Documentation License:: 554a238c70SJohn Marino* Concept Index:: 564a238c70SJohn Marino* Function and Type Index:: 574a238c70SJohn Marino 584a238c70SJohn Marino 594a238c70SJohn MarinoFile: mpfr.info, Node: Copying, Next: Introduction to MPFR, Prev: Top, Up: Top 604a238c70SJohn Marino 614a238c70SJohn MarinoMPFR Copying Conditions 624a238c70SJohn Marino*********************** 634a238c70SJohn Marino 644a238c70SJohn MarinoThe GNU MPFR library (or MPFR for short) is "free"; this means that 654a238c70SJohn Marinoeveryone is free to use it and free to redistribute it on a free basis. 664a238c70SJohn MarinoThe library is not in the public domain; it is copyrighted and there 674a238c70SJohn Marinoare restrictions on its distribution, but these restrictions are 684a238c70SJohn Marinodesigned to permit everything that a good cooperating citizen would 694a238c70SJohn Marinowant to do. What is not allowed is to try to prevent others from 704a238c70SJohn Marinofurther sharing any version of this library that they might get from 714a238c70SJohn Marinoyou. 724a238c70SJohn Marino 734a238c70SJohn Marino Specifically, we want to make sure that you have the right to give 744a238c70SJohn Marinoaway copies of the library, that you receive source code or else can 754a238c70SJohn Marinoget it if you want it, that you can change this library or use pieces 764a238c70SJohn Marinoof it in new free programs, and that you know you can do these things. 774a238c70SJohn Marino 784a238c70SJohn Marino To make sure that everyone has such rights, we have to forbid you to 794a238c70SJohn Marinodeprive anyone else of these rights. For example, if you distribute 804a238c70SJohn Marinocopies of the GNU MPFR library, you must give the recipients all the 814a238c70SJohn Marinorights that you have. You must make sure that they, too, receive or 824a238c70SJohn Marinocan get the source code. And you must tell them their rights. 834a238c70SJohn Marino 844a238c70SJohn Marino Also, for our own protection, we must make certain that everyone 854a238c70SJohn Marinofinds out that there is no warranty for the GNU MPFR library. If it is 864a238c70SJohn Marinomodified by someone else and passed on, we want their recipients to 874a238c70SJohn Marinoknow that what they have is not what we distributed, so that any 884a238c70SJohn Marinoproblems introduced by others will not reflect on our reputation. 894a238c70SJohn Marino 904a238c70SJohn Marino The precise conditions of the license for the GNU MPFR library are 914a238c70SJohn Marinofound in the Lesser General Public License that accompanies the source 924a238c70SJohn Marinocode. See the file COPYING.LESSER. 934a238c70SJohn Marino 944a238c70SJohn Marino 954a238c70SJohn MarinoFile: mpfr.info, Node: Introduction to MPFR, Next: Installing MPFR, Prev: Copying, Up: Top 964a238c70SJohn Marino 974a238c70SJohn Marino1 Introduction to MPFR 984a238c70SJohn Marino********************** 994a238c70SJohn Marino 1004a238c70SJohn MarinoMPFR is a portable library written in C for arbitrary precision 1014a238c70SJohn Marinoarithmetic on floating-point numbers. It is based on the GNU MP library. 1024a238c70SJohn MarinoIt aims to provide a class of floating-point numbers with precise 1034a238c70SJohn Marinosemantics. The main characteristics of MPFR, which make it differ from 1044a238c70SJohn Marinomost arbitrary precision floating-point software tools, are: 1054a238c70SJohn Marino 1064a238c70SJohn Marino * the MPFR code is portable, i.e., the result of any operation does 1074a238c70SJohn Marino not depend on the machine word size `mp_bits_per_limb' (64 on most 1084a238c70SJohn Marino current processors); 1094a238c70SJohn Marino 1104a238c70SJohn Marino * the precision in bits can be set _exactly_ to any valid value for 1114a238c70SJohn Marino each variable (including very small precision); 1124a238c70SJohn Marino 1134a238c70SJohn Marino * MPFR provides the four rounding modes from the IEEE 754-1985 1144a238c70SJohn Marino standard, plus away-from-zero, as well as for basic operations as 1154a238c70SJohn Marino for other mathematical functions. 1164a238c70SJohn Marino 1174a238c70SJohn Marino In particular, with a precision of 53 bits, MPFR is able to exactly 1184a238c70SJohn Marinoreproduce all computations with double-precision machine floating-point 1194a238c70SJohn Marinonumbers (e.g., `double' type in C, with a C implementation that 1204a238c70SJohn Marinorigorously follows Annex F of the ISO C99 standard and `FP_CONTRACT' 1214a238c70SJohn Marinopragma set to `OFF') on the four arithmetic operations and the square 1224a238c70SJohn Marinoroot, except the default exponent range is much wider and subnormal 1234a238c70SJohn Marinonumbers are not implemented (but can be emulated). 1244a238c70SJohn Marino 1254a238c70SJohn Marino This version of MPFR is released under the GNU Lesser General Public 1264a238c70SJohn MarinoLicense, version 3 or any later version. It is permitted to link MPFR 1274a238c70SJohn Marinoto most non-free programs, as long as when distributing them the MPFR 1284a238c70SJohn Marinosource code and a means to re-link with a modified MPFR library is 1294a238c70SJohn Marinoprovided. 1304a238c70SJohn Marino 1314a238c70SJohn Marino1.1 How to Use This Manual 1324a238c70SJohn Marino========================== 1334a238c70SJohn Marino 1344a238c70SJohn MarinoEveryone should read *note MPFR Basics::. If you need to install the 1354a238c70SJohn Marinolibrary yourself, you need to read *note Installing MPFR::, too. To 1364a238c70SJohn Marinouse the library you will need to refer to *note MPFR Interface::. 1374a238c70SJohn Marino 1384a238c70SJohn Marino The rest of the manual can be used for later reference, although it 1394a238c70SJohn Marinois probably a good idea to glance through it. 1404a238c70SJohn Marino 1414a238c70SJohn Marino 1424a238c70SJohn MarinoFile: mpfr.info, Node: Installing MPFR, Next: Reporting Bugs, Prev: Introduction to MPFR, Up: Top 1434a238c70SJohn Marino 1444a238c70SJohn Marino2 Installing MPFR 1454a238c70SJohn Marino***************** 1464a238c70SJohn Marino 1474a238c70SJohn MarinoThe MPFR library is already installed on some GNU/Linux distributions, 1484a238c70SJohn Marinobut the development files necessary to the compilation such as `mpfr.h' 1494a238c70SJohn Marinoare not always present. To check that MPFR is fully installed on your 1504a238c70SJohn Marinocomputer, you can check the presence of the file `mpfr.h' in 1514a238c70SJohn Marino`/usr/include', or try to compile a small program having `#include 1524a238c70SJohn Marino<mpfr.h>' (since `mpfr.h' may be installed somewhere else). For 1534a238c70SJohn Marinoinstance, you can try to compile: 1544a238c70SJohn Marino 1554a238c70SJohn Marino #include <stdio.h> 1564a238c70SJohn Marino #include <mpfr.h> 1574a238c70SJohn Marino int main (void) 1584a238c70SJohn Marino { 1594a238c70SJohn Marino printf ("MPFR library: %-12s\nMPFR header: %s (based on %d.%d.%d)\n", 1604a238c70SJohn Marino mpfr_get_version (), MPFR_VERSION_STRING, MPFR_VERSION_MAJOR, 1614a238c70SJohn Marino MPFR_VERSION_MINOR, MPFR_VERSION_PATCHLEVEL); 1624a238c70SJohn Marino return 0; 1634a238c70SJohn Marino } 1644a238c70SJohn Marino 1654a238c70SJohn Marinowith 1664a238c70SJohn Marino 1674a238c70SJohn Marino cc -o version version.c -lmpfr -lgmp 1684a238c70SJohn Marino 1694a238c70SJohn Marinoand if you get errors whose first line looks like 1704a238c70SJohn Marino 1714a238c70SJohn Marino version.c:2:19: error: mpfr.h: No such file or directory 1724a238c70SJohn Marino 1734a238c70SJohn Marinothen MPFR is probably not installed. Running this program will give you 1744a238c70SJohn Marinothe MPFR version. 1754a238c70SJohn Marino 1764a238c70SJohn Marino If MPFR is not installed on your computer, or if you want to install 1774a238c70SJohn Marinoa different version, please follow the steps below. 1784a238c70SJohn Marino 1794a238c70SJohn Marino2.1 How to Install 1804a238c70SJohn Marino================== 1814a238c70SJohn Marino 1824a238c70SJohn MarinoHere are the steps needed to install the library on Unix systems (more 1834a238c70SJohn Marinodetails are provided in the `INSTALL' file): 1844a238c70SJohn Marino 1854a238c70SJohn Marino 1. To build MPFR, you first have to install GNU MP (version 4.1 or 1864a238c70SJohn Marino higher) on your computer. You need a C compiler, preferably GCC, 1874a238c70SJohn Marino but any reasonable compiler should work. And you need the 1884a238c70SJohn Marino standard Unix `make' command, plus some other standard Unix 1894a238c70SJohn Marino utility commands. 1904a238c70SJohn Marino 1914a238c70SJohn Marino Then, in the MPFR build directory, type the following commands. 1924a238c70SJohn Marino 1934a238c70SJohn Marino 2. `./configure' 1944a238c70SJohn Marino 1954a238c70SJohn Marino This will prepare the build and setup the options according to 1964a238c70SJohn Marino your system. You can give options to specify the install 1974a238c70SJohn Marino directories (instead of the default `/usr/local'), threading 1984a238c70SJohn Marino support, and so on. See the `INSTALL' file and/or the output of 1994a238c70SJohn Marino `./configure --help' for more information, in particular if you 2004a238c70SJohn Marino get error messages. 2014a238c70SJohn Marino 2024a238c70SJohn Marino 3. `make' 2034a238c70SJohn Marino 2044a238c70SJohn Marino This will compile MPFR, and create a library archive file 2054a238c70SJohn Marino `libmpfr.a'. On most platforms, a dynamic library will be 2064a238c70SJohn Marino produced too. 2074a238c70SJohn Marino 2084a238c70SJohn Marino 4. `make check' 2094a238c70SJohn Marino 2104a238c70SJohn Marino This will make sure MPFR was built correctly. If you get error 2114a238c70SJohn Marino messages, please report this to the MPFR mailing-list 212*ab6d115fSJohn Marino `mpfr@inria.fr'. (*Note Reporting Bugs::, for information on what 2134a238c70SJohn Marino to include in useful bug reports.) 2144a238c70SJohn Marino 2154a238c70SJohn Marino 5. `make install' 2164a238c70SJohn Marino 2174a238c70SJohn Marino This will copy the files `mpfr.h' and `mpf2mpfr.h' to the directory 2184a238c70SJohn Marino `/usr/local/include', the library files (`libmpfr.a' and possibly 2194a238c70SJohn Marino others) to the directory `/usr/local/lib', the file `mpfr.info' to 2204a238c70SJohn Marino the directory `/usr/local/share/info', and some other documentation 2214a238c70SJohn Marino files to the directory `/usr/local/share/doc/mpfr' (or if you 2224a238c70SJohn Marino passed the `--prefix' option to `configure', using the prefix 2234a238c70SJohn Marino directory given as argument to `--prefix' instead of `/usr/local'). 2244a238c70SJohn Marino 2254a238c70SJohn Marino2.2 Other `make' Targets 2264a238c70SJohn Marino======================== 2274a238c70SJohn Marino 2284a238c70SJohn MarinoThere are some other useful make targets: 2294a238c70SJohn Marino 2304a238c70SJohn Marino * `mpfr.info' or `info' 2314a238c70SJohn Marino 2324a238c70SJohn Marino Create or update an info version of the manual, in `mpfr.info'. 2334a238c70SJohn Marino 2344a238c70SJohn Marino This file is already provided in the MPFR archives. 2354a238c70SJohn Marino 2364a238c70SJohn Marino * `mpfr.pdf' or `pdf' 2374a238c70SJohn Marino 2384a238c70SJohn Marino Create a PDF version of the manual, in `mpfr.pdf'. 2394a238c70SJohn Marino 2404a238c70SJohn Marino * `mpfr.dvi' or `dvi' 2414a238c70SJohn Marino 2424a238c70SJohn Marino Create a DVI version of the manual, in `mpfr.dvi'. 2434a238c70SJohn Marino 2444a238c70SJohn Marino * `mpfr.ps' or `ps' 2454a238c70SJohn Marino 2464a238c70SJohn Marino Create a Postscript version of the manual, in `mpfr.ps'. 2474a238c70SJohn Marino 2484a238c70SJohn Marino * `mpfr.html' or `html' 2494a238c70SJohn Marino 2504a238c70SJohn Marino Create a HTML version of the manual, in several pages in the 2514a238c70SJohn Marino directory `doc/mpfr.html'; if you want only one output HTML file, 2524a238c70SJohn Marino then type `makeinfo --html --no-split mpfr.texi' from the `doc' 2534a238c70SJohn Marino directory instead. 2544a238c70SJohn Marino 2554a238c70SJohn Marino * `clean' 2564a238c70SJohn Marino 2574a238c70SJohn Marino Delete all object files and archive files, but not the 2584a238c70SJohn Marino configuration files. 2594a238c70SJohn Marino 2604a238c70SJohn Marino * `distclean' 2614a238c70SJohn Marino 2624a238c70SJohn Marino Delete all generated files not included in the distribution. 2634a238c70SJohn Marino 2644a238c70SJohn Marino * `uninstall' 2654a238c70SJohn Marino 2664a238c70SJohn Marino Delete all files copied by `make install'. 2674a238c70SJohn Marino 2684a238c70SJohn Marino2.3 Build Problems 2694a238c70SJohn Marino================== 2704a238c70SJohn Marino 2714a238c70SJohn MarinoIn case of problem, please read the `INSTALL' file carefully before 2724a238c70SJohn Marinoreporting a bug, in particular section "In case of problem". Some 2734a238c70SJohn Marinoproblems are due to bad configuration on the user side (not specific to 2744a238c70SJohn MarinoMPFR). Problems are also mentioned in the FAQ 2754a238c70SJohn Marino`http://www.mpfr.org/faq.html'. 2764a238c70SJohn Marino 277*ab6d115fSJohn Marino Please report problems to the MPFR mailing-list `mpfr@inria.fr'. 278*ab6d115fSJohn Marino*Note Reporting Bugs::. Some bug fixes are available on the MPFR 3.1.2 279*ab6d115fSJohn Marinoweb page `http://www.mpfr.org/mpfr-3.1.2/'. 2804a238c70SJohn Marino 2814a238c70SJohn Marino2.4 Getting the Latest Version of MPFR 2824a238c70SJohn Marino====================================== 2834a238c70SJohn Marino 2844a238c70SJohn MarinoThe latest version of MPFR is available from 2854a238c70SJohn Marino`ftp://ftp.gnu.org/gnu/mpfr/' or `http://www.mpfr.org/'. 2864a238c70SJohn Marino 2874a238c70SJohn Marino 2884a238c70SJohn MarinoFile: mpfr.info, Node: Reporting Bugs, Next: MPFR Basics, Prev: Installing MPFR, Up: Top 2894a238c70SJohn Marino 2904a238c70SJohn Marino3 Reporting Bugs 2914a238c70SJohn Marino**************** 2924a238c70SJohn Marino 2934a238c70SJohn MarinoIf you think you have found a bug in the MPFR library, first have a look 294*ab6d115fSJohn Marinoon the MPFR 3.1.2 web page `http://www.mpfr.org/mpfr-3.1.2/' and the 2954a238c70SJohn MarinoFAQ `http://www.mpfr.org/faq.html': perhaps this bug is already known, 2964a238c70SJohn Marinoin which case you may find there a workaround for it. You might also 2974a238c70SJohn Marinolook in the archives of the MPFR mailing-list: 298*ab6d115fSJohn Marino`https://sympa.inria.fr/sympa/arc/mpfr'. Otherwise, please investigate 299*ab6d115fSJohn Marinoand report it. We have made this library available to you, and it is 300*ab6d115fSJohn Marinonot to ask too much from you, to ask you to report the bugs that you 301*ab6d115fSJohn Marinofind. 3024a238c70SJohn Marino 3034a238c70SJohn Marino There are a few things you should think about when you put your bug 3044a238c70SJohn Marinoreport together. 3054a238c70SJohn Marino 3064a238c70SJohn Marino You have to send us a test case that makes it possible for us to 3074a238c70SJohn Marinoreproduce the bug, i.e., a small self-content program, using no other 3084a238c70SJohn Marinolibrary than MPFR. Include instructions on how to run the test case. 3094a238c70SJohn Marino 3104a238c70SJohn Marino You also have to explain what is wrong; if you get a crash, or if 3114a238c70SJohn Marinothe results you get are incorrect and in that case, in what way. 3124a238c70SJohn Marino 3134a238c70SJohn Marino Please include compiler version information in your bug report. This 3144a238c70SJohn Marinocan be extracted using `cc -V' on some machines, or, if you're using 3154a238c70SJohn MarinoGCC, `gcc -v'. Also, include the output from `uname -a' and the MPFR 3164a238c70SJohn Marinoversion (the GMP version may be useful too). If you get a failure 3174a238c70SJohn Marinowhile running `make' or `make check', please include the `config.log' 3184a238c70SJohn Marinofile in your bug report. 3194a238c70SJohn Marino 3204a238c70SJohn Marino If your bug report is good, we will do our best to help you to get a 3214a238c70SJohn Marinocorrected version of the library; if the bug report is poor, we will 3224a238c70SJohn Marinonot do anything about it (aside of chiding you to send better bug 3234a238c70SJohn Marinoreports). 3244a238c70SJohn Marino 325*ab6d115fSJohn Marino Send your bug report to the MPFR mailing-list `mpfr@inria.fr'. 3264a238c70SJohn Marino 3274a238c70SJohn Marino If you think something in this manual is unclear, or downright 3284a238c70SJohn Marinoincorrect, or if the language needs to be improved, please send a note 3294a238c70SJohn Marinoto the same address. 3304a238c70SJohn Marino 3314a238c70SJohn Marino 3324a238c70SJohn MarinoFile: mpfr.info, Node: MPFR Basics, Next: MPFR Interface, Prev: Reporting Bugs, Up: Top 3334a238c70SJohn Marino 3344a238c70SJohn Marino4 MPFR Basics 3354a238c70SJohn Marino************* 3364a238c70SJohn Marino 3374a238c70SJohn Marino* Menu: 3384a238c70SJohn Marino 3394a238c70SJohn Marino* Headers and Libraries:: 3404a238c70SJohn Marino* Nomenclature and Types:: 3414a238c70SJohn Marino* MPFR Variable Conventions:: 3424a238c70SJohn Marino* Rounding Modes:: 3434a238c70SJohn Marino* Floating-Point Values on Special Numbers:: 3444a238c70SJohn Marino* Exceptions:: 3454a238c70SJohn Marino* Memory Handling:: 3464a238c70SJohn Marino 3474a238c70SJohn Marino 3484a238c70SJohn MarinoFile: mpfr.info, Node: Headers and Libraries, Next: Nomenclature and Types, Prev: MPFR Basics, Up: MPFR Basics 3494a238c70SJohn Marino 3504a238c70SJohn Marino4.1 Headers and Libraries 3514a238c70SJohn Marino========================= 3524a238c70SJohn Marino 3534a238c70SJohn MarinoAll declarations needed to use MPFR are collected in the include file 3544a238c70SJohn Marino`mpfr.h'. It is designed to work with both C and C++ compilers. You 3554a238c70SJohn Marinoshould include that file in any program using the MPFR library: 3564a238c70SJohn Marino 3574a238c70SJohn Marino #include <mpfr.h> 3584a238c70SJohn Marino 3594a238c70SJohn Marino Note however that prototypes for MPFR functions with `FILE *' 3604a238c70SJohn Marinoparameters are provided only if `<stdio.h>' is included too (before 3614a238c70SJohn Marino`mpfr.h'): 3624a238c70SJohn Marino 3634a238c70SJohn Marino #include <stdio.h> 3644a238c70SJohn Marino #include <mpfr.h> 3654a238c70SJohn Marino 3664a238c70SJohn Marino Likewise `<stdarg.h>' (or `<varargs.h>') is required for prototypes 3674a238c70SJohn Marinowith `va_list' parameters, such as `mpfr_vprintf'. 3684a238c70SJohn Marino 3694a238c70SJohn Marino And for any functions using `intmax_t', you must include 3704a238c70SJohn Marino`<stdint.h>' or `<inttypes.h>' before `mpfr.h', to allow `mpfr.h' to 3714a238c70SJohn Marinodefine prototypes for these functions. Moreover, users of C++ compilers 3724a238c70SJohn Marinounder some platforms may need to define `MPFR_USE_INTMAX_T' (and should 3734a238c70SJohn Marinodo it for portability) before `mpfr.h' has been included; of course, it 3744a238c70SJohn Marinois possible to do that on the command line, e.g., with 3754a238c70SJohn Marino`-DMPFR_USE_INTMAX_T'. 3764a238c70SJohn Marino 3774a238c70SJohn Marino Note: If `mpfr.h' and/or `gmp.h' (used by `mpfr.h') are included 3784a238c70SJohn Marinoseveral times (possibly from another header file), `<stdio.h>' and/or 3794a238c70SJohn Marino`<stdarg.h>' (or `<varargs.h>') should be included *before the first 3804a238c70SJohn Marinoinclusion* of `mpfr.h' or `gmp.h'. Alternatively, you can define 3814a238c70SJohn Marino`MPFR_USE_FILE' (for MPFR I/O functions) and/or `MPFR_USE_VA_LIST' (for 3824a238c70SJohn MarinoMPFR functions with `va_list' parameters) anywhere before the last 3834a238c70SJohn Marinoinclusion of `mpfr.h'. As a consequence, if your file is a public 3844a238c70SJohn Marinoheader that includes `mpfr.h', you need to use the latter method. 3854a238c70SJohn Marino 3864a238c70SJohn Marino When calling a MPFR macro, it is not allowed to have previously 3874a238c70SJohn Marinodefined a macro with the same name as some keywords (currently `do', 3884a238c70SJohn Marino`while' and `sizeof'). 3894a238c70SJohn Marino 3904a238c70SJohn Marino You can avoid the use of MPFR macros encapsulating functions by 3914a238c70SJohn Marinodefining the `MPFR_USE_NO_MACRO' macro before `mpfr.h' is included. In 3924a238c70SJohn Marinogeneral this should not be necessary, but this can be useful when 3934a238c70SJohn Marinodebugging user code: with some macros, the compiler may emit spurious 3944a238c70SJohn Marinowarnings with some warning options, and macros can prevent some 3954a238c70SJohn Marinoprototype checking. 3964a238c70SJohn Marino 3974a238c70SJohn Marino All programs using MPFR must link against both `libmpfr' and 3984a238c70SJohn Marino`libgmp' libraries. On a typical Unix-like system this can be done 3994a238c70SJohn Marinowith `-lmpfr -lgmp' (in that order), for example: 4004a238c70SJohn Marino 4014a238c70SJohn Marino gcc myprogram.c -lmpfr -lgmp 4024a238c70SJohn Marino 4034a238c70SJohn Marino MPFR is built using Libtool and an application can use that to link 4044a238c70SJohn Marinoif desired, *note GNU Libtool: (libtool.info)Top. 4054a238c70SJohn Marino 4064a238c70SJohn Marino If MPFR has been installed to a non-standard location, then it may be 4074a238c70SJohn Marinonecessary to set up environment variables such as `C_INCLUDE_PATH' and 4084a238c70SJohn Marino`LIBRARY_PATH', or use `-I' and `-L' compiler options, in order to 4094a238c70SJohn Marinopoint to the right directories. For a shared library, it may also be 4104a238c70SJohn Marinonecessary to set up some sort of run-time library path (e.g., 4114a238c70SJohn Marino`LD_LIBRARY_PATH') on some systems. Please read the `INSTALL' file for 4124a238c70SJohn Marinoadditional information. 4134a238c70SJohn Marino 4144a238c70SJohn Marino 4154a238c70SJohn MarinoFile: mpfr.info, Node: Nomenclature and Types, Next: MPFR Variable Conventions, Prev: Headers and Libraries, Up: MPFR Basics 4164a238c70SJohn Marino 4174a238c70SJohn Marino4.2 Nomenclature and Types 4184a238c70SJohn Marino========================== 4194a238c70SJohn Marino 4204a238c70SJohn MarinoA "floating-point number", or "float" for short, is an arbitrary 4214a238c70SJohn Marinoprecision significand (also called mantissa) with a limited precision 4224a238c70SJohn Marinoexponent. The C data type for such objects is `mpfr_t' (internally 4234a238c70SJohn Marinodefined as a one-element array of a structure, and `mpfr_ptr' is the C 4244a238c70SJohn Marinodata type representing a pointer to this structure). A floating-point 4254a238c70SJohn Marinonumber can have three special values: Not-a-Number (NaN) or plus or 4264a238c70SJohn Marinominus Infinity. NaN represents an uninitialized object, the result of 4274a238c70SJohn Marinoan invalid operation (like 0 divided by 0), or a value that cannot be 4284a238c70SJohn Marinodetermined (like +Infinity minus +Infinity). Moreover, like in the IEEE 4294a238c70SJohn Marino754 standard, zero is signed, i.e., there are both +0 and -0; the 4304a238c70SJohn Marinobehavior is the same as in the IEEE 754 standard and it is generalized 4314a238c70SJohn Marinoto the other functions supported by MPFR. Unless documented otherwise, 4324a238c70SJohn Marinothe sign bit of a NaN is unspecified. 4334a238c70SJohn Marino 4344a238c70SJohn MarinoThe "precision" is the number of bits used to represent the significand 4354a238c70SJohn Marinoof a floating-point number; the corresponding C data type is 4364a238c70SJohn Marino`mpfr_prec_t'. The precision can be any integer between 4374a238c70SJohn Marino`MPFR_PREC_MIN' and `MPFR_PREC_MAX'. In the current implementation, 4384a238c70SJohn Marino`MPFR_PREC_MIN' is equal to 2. 4394a238c70SJohn Marino 4404a238c70SJohn Marino Warning! MPFR needs to increase the precision internally, in order to 4414a238c70SJohn Marinoprovide accurate results (and in particular, correct rounding). Do not 4424a238c70SJohn Marinoattempt to set the precision to any value near `MPFR_PREC_MAX', 4434a238c70SJohn Marinootherwise MPFR will abort due to an assertion failure. Moreover, you 4444a238c70SJohn Marinomay reach some memory limit on your platform, in which case the program 4454a238c70SJohn Marinomay abort, crash or have undefined behavior (depending on your C 4464a238c70SJohn Marinoimplementation). 4474a238c70SJohn Marino 4484a238c70SJohn MarinoThe "rounding mode" specifies the way to round the result of a 4494a238c70SJohn Marinofloating-point operation, in case the exact result can not be 4504a238c70SJohn Marinorepresented exactly in the destination significand; the corresponding C 4514a238c70SJohn Marinodata type is `mpfr_rnd_t'. 4524a238c70SJohn Marino 4534a238c70SJohn Marino 4544a238c70SJohn MarinoFile: mpfr.info, Node: MPFR Variable Conventions, Next: Rounding Modes, Prev: Nomenclature and Types, Up: MPFR Basics 4554a238c70SJohn Marino 4564a238c70SJohn Marino4.3 MPFR Variable Conventions 4574a238c70SJohn Marino============================= 4584a238c70SJohn Marino 4594a238c70SJohn MarinoBefore you can assign to an MPFR variable, you need to initialize it by 4604a238c70SJohn Marinocalling one of the special initialization functions. When you're done 4614a238c70SJohn Marinowith a variable, you need to clear it out, using one of the functions 4624a238c70SJohn Marinofor that purpose. A variable should only be initialized once, or at 4634a238c70SJohn Marinoleast cleared out between each initialization. After a variable has 4644a238c70SJohn Marinobeen initialized, it may be assigned to any number of times. For 4654a238c70SJohn Marinoefficiency reasons, avoid to initialize and clear out a variable in 4664a238c70SJohn Marinoloops. Instead, initialize it before entering the loop, and clear it 4674a238c70SJohn Marinoout after the loop has exited. You do not need to be concerned about 4684a238c70SJohn Marinoallocating additional space for MPFR variables, since any variable has 4694a238c70SJohn Marinoa significand of fixed size. Hence unless you change its precision, or 4704a238c70SJohn Marinoclear and reinitialize it, a floating-point variable will have the same 4714a238c70SJohn Marinoallocated space during all its life. 4724a238c70SJohn Marino 4734a238c70SJohn Marino As a general rule, all MPFR functions expect output arguments before 4744a238c70SJohn Marinoinput arguments. This notation is based on an analogy with the 4754a238c70SJohn Marinoassignment operator. MPFR allows you to use the same variable for both 4764a238c70SJohn Marinoinput and output in the same expression. For example, the main 4774a238c70SJohn Marinofunction for floating-point multiplication, `mpfr_mul', can be used 4784a238c70SJohn Marinolike this: `mpfr_mul (x, x, x, rnd)'. This computes the square of X 4794a238c70SJohn Marinowith rounding mode `rnd' and puts the result back in X. 4804a238c70SJohn Marino 4814a238c70SJohn Marino 4824a238c70SJohn MarinoFile: mpfr.info, Node: Rounding Modes, Next: Floating-Point Values on Special Numbers, Prev: MPFR Variable Conventions, Up: MPFR Basics 4834a238c70SJohn Marino 4844a238c70SJohn Marino4.4 Rounding Modes 4854a238c70SJohn Marino================== 4864a238c70SJohn Marino 4874a238c70SJohn MarinoThe following five rounding modes are supported: 4884a238c70SJohn Marino 4894a238c70SJohn Marino * `MPFR_RNDN': round to nearest (roundTiesToEven in IEEE 754-2008), 4904a238c70SJohn Marino 4914a238c70SJohn Marino * `MPFR_RNDZ': round toward zero (roundTowardZero in IEEE 754-2008), 4924a238c70SJohn Marino 4934a238c70SJohn Marino * `MPFR_RNDU': round toward plus infinity (roundTowardPositive in 4944a238c70SJohn Marino IEEE 754-2008), 4954a238c70SJohn Marino 4964a238c70SJohn Marino * `MPFR_RNDD': round toward minus infinity (roundTowardNegative in 4974a238c70SJohn Marino IEEE 754-2008), 4984a238c70SJohn Marino 4994a238c70SJohn Marino * `MPFR_RNDA': round away from zero. 5004a238c70SJohn Marino 5014a238c70SJohn Marino The `round to nearest' mode works as in the IEEE 754 standard: in 5024a238c70SJohn Marinocase the number to be rounded lies exactly in the middle of two 5034a238c70SJohn Marinorepresentable numbers, it is rounded to the one with the least 5044a238c70SJohn Marinosignificant bit set to zero. For example, the number 2.5, which is 5054a238c70SJohn Marinorepresented by (10.1) in binary, is rounded to (10.0)=2 with a 5064a238c70SJohn Marinoprecision of two bits, and not to (11.0)=3. This rule avoids the 5074a238c70SJohn Marino"drift" phenomenon mentioned by Knuth in volume 2 of The Art of 5084a238c70SJohn MarinoComputer Programming (Section 4.2.2). 5094a238c70SJohn Marino 5104a238c70SJohn Marino Most MPFR functions take as first argument the destination variable, 5114a238c70SJohn Marinoas second and following arguments the input variables, as last argument 5124a238c70SJohn Marinoa rounding mode, and have a return value of type `int', called the 5134a238c70SJohn Marino"ternary value". The value stored in the destination variable is 5144a238c70SJohn Marinocorrectly rounded, i.e., MPFR behaves as if it computed the result with 5154a238c70SJohn Marinoan infinite precision, then rounded it to the precision of this 5164a238c70SJohn Marinovariable. The input variables are regarded as exact (in particular, 5174a238c70SJohn Marinotheir precision does not affect the result). 5184a238c70SJohn Marino 5194a238c70SJohn Marino As a consequence, in case of a non-zero real rounded result, the 5204a238c70SJohn Marinoerror on the result is less or equal to 1/2 ulp (unit in the last 5214a238c70SJohn Marinoplace) of that result in the rounding to nearest mode, and less than 1 5224a238c70SJohn Marinoulp of that result in the directed rounding modes (a ulp is the weight 5234a238c70SJohn Marinoof the least significant represented bit of the result after rounding). 5244a238c70SJohn Marino 5254a238c70SJohn Marino Unless documented otherwise, functions returning an `int' return a 5264a238c70SJohn Marinoternary value. If the ternary value is zero, it means that the value 5274a238c70SJohn Marinostored in the destination variable is the exact result of the 5284a238c70SJohn Marinocorresponding mathematical function. If the ternary value is positive 5294a238c70SJohn Marino(resp. negative), it means the value stored in the destination variable 5304a238c70SJohn Marinois greater (resp. lower) than the exact result. For example with the 5314a238c70SJohn Marino`MPFR_RNDU' rounding mode, the ternary value is usually positive, 5324a238c70SJohn Marinoexcept when the result is exact, in which case it is zero. In the case 5334a238c70SJohn Marinoof an infinite result, it is considered as inexact when it was obtained 5344a238c70SJohn Marinoby overflow, and exact otherwise. A NaN result (Not-a-Number) always 5354a238c70SJohn Marinocorresponds to an exact return value. The opposite of a returned 5364a238c70SJohn Marinoternary value is guaranteed to be representable in an `int'. 5374a238c70SJohn Marino 5384a238c70SJohn Marino Unless documented otherwise, functions returning as result the value 5394a238c70SJohn Marino`1' (or any other value specified in this manual) for special cases 5404a238c70SJohn Marino(like `acos(0)') yield an overflow or an underflow if that value is not 5414a238c70SJohn Marinorepresentable in the current exponent range. 5424a238c70SJohn Marino 5434a238c70SJohn Marino 5444a238c70SJohn MarinoFile: mpfr.info, Node: Floating-Point Values on Special Numbers, Next: Exceptions, Prev: Rounding Modes, Up: MPFR Basics 5454a238c70SJohn Marino 5464a238c70SJohn Marino4.5 Floating-Point Values on Special Numbers 5474a238c70SJohn Marino============================================ 5484a238c70SJohn Marino 5494a238c70SJohn MarinoThis section specifies the floating-point values (of type `mpfr_t') 5504a238c70SJohn Marinoreturned by MPFR functions (where by "returned" we mean here the 5514a238c70SJohn Marinomodified value of the destination object, which should not be mixed 5524a238c70SJohn Marinowith the ternary return value of type `int' of those functions). For 5534a238c70SJohn Marinofunctions returning several values (like `mpfr_sin_cos'), the rules 5544a238c70SJohn Marinoapply to each result separately. 5554a238c70SJohn Marino 5564a238c70SJohn Marino Functions can have one or several input arguments. An input point is 5574a238c70SJohn Marinoa mapping from these input arguments to the set of the MPFR numbers. 5584a238c70SJohn MarinoWhen none of its components are NaN, an input point can also be seen as 5594a238c70SJohn Marinoa tuple in the extended real numbers (the set of the real numbers with 5604a238c70SJohn Marinoboth infinities). 5614a238c70SJohn Marino 5624a238c70SJohn Marino When the input point is in the domain of the mathematical function, 5634a238c70SJohn Marinothe result is rounded as described in Section "Rounding Modes" (but see 5644a238c70SJohn Marinobelow for the specification of the sign of an exact zero). Otherwise 5654a238c70SJohn Marinothe general rules from this section apply unless stated otherwise in 5664a238c70SJohn Marinothe description of the MPFR function (*note MPFR Interface::). 5674a238c70SJohn Marino 5684a238c70SJohn Marino When the input point is not in the domain of the mathematical 5694a238c70SJohn Marinofunction but is in its closure in the extended real numbers and the 5704a238c70SJohn Marinofunction can be extended by continuity, the result is the obtained 5714a238c70SJohn Marinolimit. Examples: `mpfr_hypot' on (+Inf,0) gives +Inf. But `mpfr_pow' 5724a238c70SJohn Marinocannot be defined on (1,+Inf) using this rule, as one can find 5734a238c70SJohn Marinosequences (X_N,Y_N) such that X_N goes to 1, Y_N goes to +Inf and X_N 5744a238c70SJohn Marinoto the Y_N goes to any positive value when N goes to the infinity. 5754a238c70SJohn Marino 5764a238c70SJohn Marino When the input point is in the closure of the domain of the 5774a238c70SJohn Marinomathematical function and an input argument is +0 (resp. -0), one 5784a238c70SJohn Marinoconsiders the limit when the corresponding argument approaches 0 from 5794a238c70SJohn Marinoabove (resp. below). If the limit is not defined (e.g., `mpfr_log' on 5804a238c70SJohn Marino-0), the behavior is specified in the description of the MPFR function. 5814a238c70SJohn Marino 5824a238c70SJohn Marino When the result is equal to 0, its sign is determined by considering 5834a238c70SJohn Marinothe limit as if the input point were not in the domain: If one 5844a238c70SJohn Marinoapproaches 0 from above (resp. below), the result is +0 (resp. -0); for 5854a238c70SJohn Marinoexample, `mpfr_sin' on +0 gives +0. In the other cases, the sign is 5864a238c70SJohn Marinospecified in the description of the MPFR function; for example 5874a238c70SJohn Marino`mpfr_max' on -0 and +0 gives +0. 5884a238c70SJohn Marino 5894a238c70SJohn Marino When the input point is not in the closure of the domain of the 5904a238c70SJohn Marinofunction, the result is NaN. Example: `mpfr_sqrt' on -17 gives NaN. 5914a238c70SJohn Marino 5924a238c70SJohn Marino When an input argument is NaN, the result is NaN, possibly except 5934a238c70SJohn Marinowhen a partial function is constant on the finite floating-point 5944a238c70SJohn Marinonumbers; such a case is always explicitly specified in *note MPFR 5954a238c70SJohn MarinoInterface::. Example: `mpfr_hypot' on (NaN,0) gives NaN, but 5964a238c70SJohn Marino`mpfr_hypot' on (NaN,+Inf) gives +Inf (as specified in *note Special 5974a238c70SJohn MarinoFunctions::), since for any finite input X, `mpfr_hypot' on (X,+Inf) 5984a238c70SJohn Marinogives +Inf. 5994a238c70SJohn Marino 6004a238c70SJohn Marino 6014a238c70SJohn MarinoFile: mpfr.info, Node: Exceptions, Next: Memory Handling, Prev: Floating-Point Values on Special Numbers, Up: MPFR Basics 6024a238c70SJohn Marino 6034a238c70SJohn Marino4.6 Exceptions 6044a238c70SJohn Marino============== 6054a238c70SJohn Marino 6064a238c70SJohn MarinoMPFR supports 6 exception types: 6074a238c70SJohn Marino 6084a238c70SJohn Marino * Underflow: An underflow occurs when the exact result of a function 6094a238c70SJohn Marino is a non-zero real number and the result obtained after the 6104a238c70SJohn Marino rounding, assuming an unbounded exponent range (for the rounding), 6114a238c70SJohn Marino has an exponent smaller than the minimum value of the current 6124a238c70SJohn Marino exponent range. (In the round-to-nearest mode, the halfway case is 6134a238c70SJohn Marino rounded toward zero.) 6144a238c70SJohn Marino 6154a238c70SJohn Marino Note: This is not the single possible definition of the underflow. 6164a238c70SJohn Marino MPFR chooses to consider the underflow _after_ rounding. The 6174a238c70SJohn Marino underflow before rounding can also be defined. For instance, 6184a238c70SJohn Marino consider a function that has the exact result 7 multiplied by two 6194a238c70SJohn Marino to the power E-4, where E is the smallest exponent (for a 6204a238c70SJohn Marino significand between 1/2 and 1), with a 2-bit target precision and 6214a238c70SJohn Marino rounding toward plus infinity. The exact result has the exponent 6224a238c70SJohn Marino E-1. With the underflow before rounding, such a function call 6234a238c70SJohn Marino would yield an underflow, as E-1 is outside the current exponent 6244a238c70SJohn Marino range. However, MPFR first considers the rounded result assuming 6254a238c70SJohn Marino an unbounded exponent range. The exact result cannot be 6264a238c70SJohn Marino represented exactly in precision 2, and here, it is rounded to 0.5 6274a238c70SJohn Marino times 2 to E, which is representable in the current exponent 6284a238c70SJohn Marino range. As a consequence, this will not yield an underflow in MPFR. 6294a238c70SJohn Marino 6304a238c70SJohn Marino * Overflow: An overflow occurs when the exact result of a function 6314a238c70SJohn Marino is a non-zero real number and the result obtained after the 6324a238c70SJohn Marino rounding, assuming an unbounded exponent range (for the rounding), 6334a238c70SJohn Marino has an exponent larger than the maximum value of the current 6344a238c70SJohn Marino exponent range. In the round-to-nearest mode, the result is 6354a238c70SJohn Marino infinite. Note: unlike the underflow case, there is only one 6364a238c70SJohn Marino possible definition of overflow here. 6374a238c70SJohn Marino 6384a238c70SJohn Marino * Divide-by-zero: An exact infinite result is obtained from finite 6394a238c70SJohn Marino inputs. 6404a238c70SJohn Marino 6414a238c70SJohn Marino * NaN: A NaN exception occurs when the result of a function is NaN. 6424a238c70SJohn Marino 6434a238c70SJohn Marino * Inexact: An inexact exception occurs when the result of a function 6444a238c70SJohn Marino cannot be represented exactly and must be rounded. 6454a238c70SJohn Marino 6464a238c70SJohn Marino * Range error: A range exception occurs when a function that does 6474a238c70SJohn Marino not return a MPFR number (such as comparisons and conversions to 6484a238c70SJohn Marino an integer) has an invalid result (e.g., an argument is NaN in 6494a238c70SJohn Marino `mpfr_cmp', or a conversion to an integer cannot be represented in 6504a238c70SJohn Marino the target type). 6514a238c70SJohn Marino 6524a238c70SJohn Marino 6534a238c70SJohn Marino MPFR has a global flag for each exception, which can be cleared, set 6544a238c70SJohn Marinoor tested by functions described in *note Exception Related Functions::. 6554a238c70SJohn Marino 6564a238c70SJohn Marino Differences with the ISO C99 standard: 6574a238c70SJohn Marino 6584a238c70SJohn Marino * In C, only quiet NaNs are specified, and a NaN propagation does not 6594a238c70SJohn Marino raise an invalid exception. Unless explicitly stated otherwise, 6604a238c70SJohn Marino MPFR sets the NaN flag whenever a NaN is generated, even when a 6614a238c70SJohn Marino NaN is propagated (e.g., in NaN + NaN), as if all NaNs were 6624a238c70SJohn Marino signaling. 6634a238c70SJohn Marino 6644a238c70SJohn Marino * An invalid exception in C corresponds to either a NaN exception or 6654a238c70SJohn Marino a range error in MPFR. 6664a238c70SJohn Marino 6674a238c70SJohn Marino 6684a238c70SJohn Marino 6694a238c70SJohn MarinoFile: mpfr.info, Node: Memory Handling, Prev: Exceptions, Up: MPFR Basics 6704a238c70SJohn Marino 6714a238c70SJohn Marino4.7 Memory Handling 6724a238c70SJohn Marino=================== 6734a238c70SJohn Marino 6744a238c70SJohn MarinoMPFR functions may create caches, e.g., when computing constants such 6754a238c70SJohn Marinoas Pi, either because the user has called a function like 6764a238c70SJohn Marino`mpfr_const_pi' directly or because such a function was called 6774a238c70SJohn Marinointernally by the MPFR library itself to compute some other function. 6784a238c70SJohn Marino 6794a238c70SJohn Marino At any time, the user can free the various caches with 6804a238c70SJohn Marino`mpfr_free_cache'. It is strongly advised to do that before terminating 6814a238c70SJohn Marinoa thread, or before exiting when using tools like `valgrind' (to avoid 6824a238c70SJohn Marinomemory leaks being reported). 6834a238c70SJohn Marino 6844a238c70SJohn Marino MPFR internal data such as flags, the exponent range, the default 6854a238c70SJohn Marinoprecision and rounding mode, and caches (i.e., data that are not 6864a238c70SJohn Marinoaccessed via parameters) are either global (if MPFR has not been 6874a238c70SJohn Marinocompiled as thread safe) or per-thread (thread local storage, TLS). 6884a238c70SJohn MarinoThe initial values of TLS data after a thread is created entirely 6894a238c70SJohn Marinodepend on the compiler and thread implementation (MPFR simply does a 6904a238c70SJohn Marinoconventional variable initialization, the variables being declared with 6914a238c70SJohn Marinoan implementation-defined TLS specifier). 6924a238c70SJohn Marino 6934a238c70SJohn Marino 6944a238c70SJohn MarinoFile: mpfr.info, Node: MPFR Interface, Next: API Compatibility, Prev: MPFR Basics, Up: Top 6954a238c70SJohn Marino 6964a238c70SJohn Marino5 MPFR Interface 6974a238c70SJohn Marino**************** 6984a238c70SJohn Marino 6994a238c70SJohn MarinoThe floating-point functions expect arguments of type `mpfr_t'. 7004a238c70SJohn Marino 7014a238c70SJohn Marino The MPFR floating-point functions have an interface that is similar 7024a238c70SJohn Marinoto the GNU MP functions. The function prefix for floating-point 7034a238c70SJohn Marinooperations is `mpfr_'. 7044a238c70SJohn Marino 7054a238c70SJohn Marino The user has to specify the precision of each variable. A 7064a238c70SJohn Marinocomputation that assigns a variable will take place with the precision 7074a238c70SJohn Marinoof the assigned variable; the cost of that computation should not 7084a238c70SJohn Marinodepend on the precision of variables used as input (on average). 7094a238c70SJohn Marino 7104a238c70SJohn Marino The semantics of a calculation in MPFR is specified as follows: 7114a238c70SJohn MarinoCompute the requested operation exactly (with "infinite accuracy"), and 7124a238c70SJohn Marinoround the result to the precision of the destination variable, with the 7134a238c70SJohn Marinogiven rounding mode. The MPFR floating-point functions are intended to 7144a238c70SJohn Marinobe a smooth extension of the IEEE 754 arithmetic. The results obtained 7154a238c70SJohn Marinoon a given computer are identical to those obtained on a computer with 7164a238c70SJohn Marinoa different word size, or with a different compiler or operating system. 7174a238c70SJohn Marino 7184a238c70SJohn Marino MPFR _does not keep track_ of the accuracy of a computation. This is 7194a238c70SJohn Marinoleft to the user or to a higher layer (for example the MPFI library for 7204a238c70SJohn Marinointerval arithmetic). As a consequence, if two variables are used to 7214a238c70SJohn Marinostore only a few significant bits, and their product is stored in a 7224a238c70SJohn Marinovariable with large precision, then MPFR will still compute the result 7234a238c70SJohn Marinowith full precision. 7244a238c70SJohn Marino 7254a238c70SJohn Marino The value of the standard C macro `errno' may be set to non-zero by 7264a238c70SJohn Marinoany MPFR function or macro, whether or not there is an error. 7274a238c70SJohn Marino 7284a238c70SJohn Marino* Menu: 7294a238c70SJohn Marino 7304a238c70SJohn Marino* Initialization Functions:: 7314a238c70SJohn Marino* Assignment Functions:: 7324a238c70SJohn Marino* Combined Initialization and Assignment Functions:: 7334a238c70SJohn Marino* Conversion Functions:: 7344a238c70SJohn Marino* Basic Arithmetic Functions:: 7354a238c70SJohn Marino* Comparison Functions:: 7364a238c70SJohn Marino* Special Functions:: 7374a238c70SJohn Marino* Input and Output Functions:: 7384a238c70SJohn Marino* Formatted Output Functions:: 7394a238c70SJohn Marino* Integer Related Functions:: 7404a238c70SJohn Marino* Rounding Related Functions:: 7414a238c70SJohn Marino* Miscellaneous Functions:: 7424a238c70SJohn Marino* Exception Related Functions:: 7434a238c70SJohn Marino* Compatibility with MPF:: 7444a238c70SJohn Marino* Custom Interface:: 7454a238c70SJohn Marino* Internals:: 7464a238c70SJohn Marino 7474a238c70SJohn Marino 7484a238c70SJohn MarinoFile: mpfr.info, Node: Initialization Functions, Next: Assignment Functions, Prev: MPFR Interface, Up: MPFR Interface 7494a238c70SJohn Marino 7504a238c70SJohn Marino5.1 Initialization Functions 7514a238c70SJohn Marino============================ 7524a238c70SJohn Marino 7534a238c70SJohn MarinoAn `mpfr_t' object must be initialized before storing the first value in 7544a238c70SJohn Marinoit. The functions `mpfr_init' and `mpfr_init2' are used for that 7554a238c70SJohn Marinopurpose. 7564a238c70SJohn Marino 7574a238c70SJohn Marino -- Function: void mpfr_init2 (mpfr_t X, mpfr_prec_t PREC) 7584a238c70SJohn Marino Initialize X, set its precision to be *exactly* PREC bits and its 7594a238c70SJohn Marino value to NaN. (Warning: the corresponding MPF function initializes 7604a238c70SJohn Marino to zero instead.) 7614a238c70SJohn Marino 7624a238c70SJohn Marino Normally, a variable should be initialized once only or at least 7634a238c70SJohn Marino be cleared, using `mpfr_clear', between initializations. To 7644a238c70SJohn Marino change the precision of a variable which has already been 7654a238c70SJohn Marino initialized, use `mpfr_set_prec'. The precision PREC must be an 7664a238c70SJohn Marino integer between `MPFR_PREC_MIN' and `MPFR_PREC_MAX' (otherwise the 7674a238c70SJohn Marino behavior is undefined). 7684a238c70SJohn Marino 7694a238c70SJohn Marino -- Function: void mpfr_inits2 (mpfr_prec_t PREC, mpfr_t X, ...) 7704a238c70SJohn Marino Initialize all the `mpfr_t' variables of the given variable 7714a238c70SJohn Marino argument `va_list', set their precision to be *exactly* PREC bits 7724a238c70SJohn Marino and their value to NaN. See `mpfr_init2' for more details. The 7734a238c70SJohn Marino `va_list' is assumed to be composed only of type `mpfr_t' (or 7744a238c70SJohn Marino equivalently `mpfr_ptr'). It begins from X, and ends when it 7754a238c70SJohn Marino encounters a null pointer (whose type must also be `mpfr_ptr'). 7764a238c70SJohn Marino 7774a238c70SJohn Marino -- Function: void mpfr_clear (mpfr_t X) 7784a238c70SJohn Marino Free the space occupied by the significand of X. Make sure to 7794a238c70SJohn Marino call this function for all `mpfr_t' variables when you are done 7804a238c70SJohn Marino with them. 7814a238c70SJohn Marino 7824a238c70SJohn Marino -- Function: void mpfr_clears (mpfr_t X, ...) 7834a238c70SJohn Marino Free the space occupied by all the `mpfr_t' variables of the given 7844a238c70SJohn Marino `va_list'. See `mpfr_clear' for more details. The `va_list' is 7854a238c70SJohn Marino assumed to be composed only of type `mpfr_t' (or equivalently 7864a238c70SJohn Marino `mpfr_ptr'). It begins from X, and ends when it encounters a null 7874a238c70SJohn Marino pointer (whose type must also be `mpfr_ptr'). 7884a238c70SJohn Marino 7894a238c70SJohn Marino Here is an example of how to use multiple initialization functions 7904a238c70SJohn Marino(since `NULL' is not necessarily defined in this context, we use 7914a238c70SJohn Marino`(mpfr_ptr) 0' instead, but `(mpfr_ptr) NULL' is also correct). 7924a238c70SJohn Marino 7934a238c70SJohn Marino { 7944a238c70SJohn Marino mpfr_t x, y, z, t; 7954a238c70SJohn Marino mpfr_inits2 (256, x, y, z, t, (mpfr_ptr) 0); 7964a238c70SJohn Marino ... 7974a238c70SJohn Marino mpfr_clears (x, y, z, t, (mpfr_ptr) 0); 7984a238c70SJohn Marino } 7994a238c70SJohn Marino 8004a238c70SJohn Marino -- Function: void mpfr_init (mpfr_t X) 8014a238c70SJohn Marino Initialize X, set its precision to the default precision, and set 8024a238c70SJohn Marino its value to NaN. The default precision can be changed by a call 8034a238c70SJohn Marino to `mpfr_set_default_prec'. 8044a238c70SJohn Marino 8054a238c70SJohn Marino Warning! In a given program, some other libraries might change the 8064a238c70SJohn Marino default precision and not restore it. Thus it is safer to use 8074a238c70SJohn Marino `mpfr_init2'. 8084a238c70SJohn Marino 8094a238c70SJohn Marino -- Function: void mpfr_inits (mpfr_t X, ...) 8104a238c70SJohn Marino Initialize all the `mpfr_t' variables of the given `va_list', set 8114a238c70SJohn Marino their precision to the default precision and their value to NaN. 8124a238c70SJohn Marino See `mpfr_init' for more details. The `va_list' is assumed to be 8134a238c70SJohn Marino composed only of type `mpfr_t' (or equivalently `mpfr_ptr'). It 8144a238c70SJohn Marino begins from X, and ends when it encounters a null pointer (whose 8154a238c70SJohn Marino type must also be `mpfr_ptr'). 8164a238c70SJohn Marino 8174a238c70SJohn Marino Warning! In a given program, some other libraries might change the 8184a238c70SJohn Marino default precision and not restore it. Thus it is safer to use 8194a238c70SJohn Marino `mpfr_inits2'. 8204a238c70SJohn Marino 8214a238c70SJohn Marino -- Macro: MPFR_DECL_INIT (NAME, PREC) 8224a238c70SJohn Marino This macro declares NAME as an automatic variable of type `mpfr_t', 8234a238c70SJohn Marino initializes it and sets its precision to be *exactly* PREC bits 8244a238c70SJohn Marino and its value to NaN. NAME must be a valid identifier. You must 8254a238c70SJohn Marino use this macro in the declaration section. This macro is much 8264a238c70SJohn Marino faster than using `mpfr_init2' but has some drawbacks: 8274a238c70SJohn Marino 8284a238c70SJohn Marino * You *must not* call `mpfr_clear' with variables created with 8294a238c70SJohn Marino this macro (the storage is allocated at the point of 8304a238c70SJohn Marino declaration and deallocated when the brace-level is exited). 8314a238c70SJohn Marino 8324a238c70SJohn Marino * You *cannot* change their precision. 8334a238c70SJohn Marino 8344a238c70SJohn Marino * You *should not* create variables with huge precision with 8354a238c70SJohn Marino this macro. 8364a238c70SJohn Marino 8374a238c70SJohn Marino * Your compiler must support `Non-Constant Initializers' 8384a238c70SJohn Marino (standard in C++ and ISO C99) and `Token Pasting' (standard 8394a238c70SJohn Marino in ISO C89). If PREC is not a constant expression, your 8404a238c70SJohn Marino compiler must support `variable-length automatic arrays' 8414a238c70SJohn Marino (standard in ISO C99). GCC 2.95.3 and above supports all 8424a238c70SJohn Marino these features. If you compile your program with GCC in C89 8434a238c70SJohn Marino mode and with `-pedantic', you may want to define the 8444a238c70SJohn Marino `MPFR_USE_EXTENSION' macro to avoid warnings due to the 8454a238c70SJohn Marino `MPFR_DECL_INIT' implementation. 8464a238c70SJohn Marino 8474a238c70SJohn Marino -- Function: void mpfr_set_default_prec (mpfr_prec_t PREC) 8484a238c70SJohn Marino Set the default precision to be *exactly* PREC bits, where PREC 8494a238c70SJohn Marino can be any integer between `MPFR_PREC_MIN' and `MPFR_PREC_MAX'. 8504a238c70SJohn Marino The precision of a variable means the number of bits used to store 8514a238c70SJohn Marino its significand. All subsequent calls to `mpfr_init' or 8524a238c70SJohn Marino `mpfr_inits' will use this precision, but previously initialized 8534a238c70SJohn Marino variables are unaffected. The default precision is set to 53 bits 8544a238c70SJohn Marino initially. 8554a238c70SJohn Marino 8564a238c70SJohn Marino Note: when MPFR is built with the `--enable-thread-safe' configure 8574a238c70SJohn Marino option, the default precision is local to each thread. *Note 8584a238c70SJohn Marino Memory Handling::, for more information. 8594a238c70SJohn Marino 8604a238c70SJohn Marino -- Function: mpfr_prec_t mpfr_get_default_prec (void) 8614a238c70SJohn Marino Return the current default MPFR precision in bits. See the 8624a238c70SJohn Marino documentation of `mpfr_set_default_prec'. 8634a238c70SJohn Marino 8644a238c70SJohn Marino Here is an example on how to initialize floating-point variables: 8654a238c70SJohn Marino 8664a238c70SJohn Marino { 8674a238c70SJohn Marino mpfr_t x, y; 8684a238c70SJohn Marino mpfr_init (x); /* use default precision */ 8694a238c70SJohn Marino mpfr_init2 (y, 256); /* precision _exactly_ 256 bits */ 8704a238c70SJohn Marino ... 8714a238c70SJohn Marino /* When the program is about to exit, do ... */ 8724a238c70SJohn Marino mpfr_clear (x); 8734a238c70SJohn Marino mpfr_clear (y); 8744a238c70SJohn Marino mpfr_free_cache (); /* free the cache for constants like pi */ 8754a238c70SJohn Marino } 8764a238c70SJohn Marino 8774a238c70SJohn Marino The following functions are useful for changing the precision during 8784a238c70SJohn Marinoa calculation. A typical use would be for adjusting the precision 8794a238c70SJohn Marinogradually in iterative algorithms like Newton-Raphson, making the 8804a238c70SJohn Marinocomputation precision closely match the actual accurate part of the 8814a238c70SJohn Marinonumbers. 8824a238c70SJohn Marino 8834a238c70SJohn Marino -- Function: void mpfr_set_prec (mpfr_t X, mpfr_prec_t PREC) 8844a238c70SJohn Marino Reset the precision of X to be *exactly* PREC bits, and set its 8854a238c70SJohn Marino value to NaN. The previous value stored in X is lost. It is 8864a238c70SJohn Marino equivalent to a call to `mpfr_clear(x)' followed by a call to 8874a238c70SJohn Marino `mpfr_init2(x, prec)', but more efficient as no allocation is done 8884a238c70SJohn Marino in case the current allocated space for the significand of X is 8894a238c70SJohn Marino enough. The precision PREC can be any integer between 8904a238c70SJohn Marino `MPFR_PREC_MIN' and `MPFR_PREC_MAX'. In case you want to keep the 8914a238c70SJohn Marino previous value stored in X, use `mpfr_prec_round' instead. 8924a238c70SJohn Marino 8934a238c70SJohn Marino -- Function: mpfr_prec_t mpfr_get_prec (mpfr_t X) 8944a238c70SJohn Marino Return the precision of X, i.e., the number of bits used to store 8954a238c70SJohn Marino its significand. 8964a238c70SJohn Marino 8974a238c70SJohn Marino 8984a238c70SJohn MarinoFile: mpfr.info, Node: Assignment Functions, Next: Combined Initialization and Assignment Functions, Prev: Initialization Functions, Up: MPFR Interface 8994a238c70SJohn Marino 9004a238c70SJohn Marino5.2 Assignment Functions 9014a238c70SJohn Marino======================== 9024a238c70SJohn Marino 9034a238c70SJohn MarinoThese functions assign new values to already initialized floats (*note 9044a238c70SJohn MarinoInitialization Functions::). 9054a238c70SJohn Marino 9064a238c70SJohn Marino -- Function: int mpfr_set (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 9074a238c70SJohn Marino -- Function: int mpfr_set_ui (mpfr_t ROP, unsigned long int OP, 9084a238c70SJohn Marino mpfr_rnd_t RND) 9094a238c70SJohn Marino -- Function: int mpfr_set_si (mpfr_t ROP, long int OP, mpfr_rnd_t RND) 9104a238c70SJohn Marino -- Function: int mpfr_set_uj (mpfr_t ROP, uintmax_t OP, mpfr_rnd_t RND) 9114a238c70SJohn Marino -- Function: int mpfr_set_sj (mpfr_t ROP, intmax_t OP, mpfr_rnd_t RND) 9124a238c70SJohn Marino -- Function: int mpfr_set_flt (mpfr_t ROP, float OP, mpfr_rnd_t RND) 9134a238c70SJohn Marino -- Function: int mpfr_set_d (mpfr_t ROP, double OP, mpfr_rnd_t RND) 9144a238c70SJohn Marino -- Function: int mpfr_set_ld (mpfr_t ROP, long double OP, mpfr_rnd_t 9154a238c70SJohn Marino RND) 9164a238c70SJohn Marino -- Function: int mpfr_set_decimal64 (mpfr_t ROP, _Decimal64 OP, 9174a238c70SJohn Marino mpfr_rnd_t RND) 9184a238c70SJohn Marino -- Function: int mpfr_set_z (mpfr_t ROP, mpz_t OP, mpfr_rnd_t RND) 9194a238c70SJohn Marino -- Function: int mpfr_set_q (mpfr_t ROP, mpq_t OP, mpfr_rnd_t RND) 9204a238c70SJohn Marino -- Function: int mpfr_set_f (mpfr_t ROP, mpf_t OP, mpfr_rnd_t RND) 9214a238c70SJohn Marino Set the value of ROP from OP, rounded toward the given direction 9224a238c70SJohn Marino RND. Note that the input 0 is converted to +0 by `mpfr_set_ui', 9234a238c70SJohn Marino `mpfr_set_si', `mpfr_set_uj', `mpfr_set_sj', `mpfr_set_z', 9244a238c70SJohn Marino `mpfr_set_q' and `mpfr_set_f', regardless of the rounding mode. 9254a238c70SJohn Marino If the system does not support the IEEE 754 standard, 9264a238c70SJohn Marino `mpfr_set_flt', `mpfr_set_d', `mpfr_set_ld' and 9274a238c70SJohn Marino `mpfr_set_decimal64' might not preserve the signed zeros. The 9284a238c70SJohn Marino `mpfr_set_decimal64' function is built only with the configure 9294a238c70SJohn Marino option `--enable-decimal-float', which also requires 9304a238c70SJohn Marino `--with-gmp-build', and when the compiler or system provides the 9314a238c70SJohn Marino `_Decimal64' data type (recent versions of GCC support this data 932*ab6d115fSJohn Marino type); to use `mpfr_set_decimal64', one should define the macro 933*ab6d115fSJohn Marino `MPFR_WANT_DECIMAL_FLOATS' before including `mpfr.h'. 934*ab6d115fSJohn Marino `mpfr_set_q' might fail if the numerator (or the denominator) can 935*ab6d115fSJohn Marino not be represented as a `mpfr_t'. 9364a238c70SJohn Marino 9374a238c70SJohn Marino Note: If you want to store a floating-point constant to a `mpfr_t', 9384a238c70SJohn Marino you should use `mpfr_set_str' (or one of the MPFR constant 9394a238c70SJohn Marino functions, such as `mpfr_const_pi' for Pi) instead of 9404a238c70SJohn Marino `mpfr_set_flt', `mpfr_set_d', `mpfr_set_ld' or 9414a238c70SJohn Marino `mpfr_set_decimal64'. Otherwise the floating-point constant will 9424a238c70SJohn Marino be first converted into a reduced-precision (e.g., 53-bit) binary 9434a238c70SJohn Marino (or decimal, for `mpfr_set_decimal64') number before MPFR can work 9444a238c70SJohn Marino with it. 9454a238c70SJohn Marino 9464a238c70SJohn Marino -- Function: int mpfr_set_ui_2exp (mpfr_t ROP, unsigned long int OP, 9474a238c70SJohn Marino mpfr_exp_t E, mpfr_rnd_t RND) 9484a238c70SJohn Marino -- Function: int mpfr_set_si_2exp (mpfr_t ROP, long int OP, mpfr_exp_t 9494a238c70SJohn Marino E, mpfr_rnd_t RND) 9504a238c70SJohn Marino -- Function: int mpfr_set_uj_2exp (mpfr_t ROP, uintmax_t OP, intmax_t 9514a238c70SJohn Marino E, mpfr_rnd_t RND) 9524a238c70SJohn Marino -- Function: int mpfr_set_sj_2exp (mpfr_t ROP, intmax_t OP, intmax_t 9534a238c70SJohn Marino E, mpfr_rnd_t RND) 9544a238c70SJohn Marino -- Function: int mpfr_set_z_2exp (mpfr_t ROP, mpz_t OP, mpfr_exp_t E, 9554a238c70SJohn Marino mpfr_rnd_t RND) 9564a238c70SJohn Marino Set the value of ROP from OP multiplied by two to the power E, 9574a238c70SJohn Marino rounded toward the given direction RND. Note that the input 0 is 9584a238c70SJohn Marino converted to +0. 9594a238c70SJohn Marino 9604a238c70SJohn Marino -- Function: int mpfr_set_str (mpfr_t ROP, const char *S, int BASE, 9614a238c70SJohn Marino mpfr_rnd_t RND) 9624a238c70SJohn Marino Set ROP to the value of the string S in base BASE, rounded in the 9634a238c70SJohn Marino direction RND. See the documentation of `mpfr_strtofr' for a 9644a238c70SJohn Marino detailed description of the valid string formats. Contrary to 9654a238c70SJohn Marino `mpfr_strtofr', `mpfr_set_str' requires the _whole_ string to 9664a238c70SJohn Marino represent a valid floating-point number. 9674a238c70SJohn Marino 9684a238c70SJohn Marino The meaning of the return value differs from other MPFR functions: 9694a238c70SJohn Marino it is 0 if the entire string up to the final null character is a 9704a238c70SJohn Marino valid number in base BASE; otherwise it is -1, and ROP may have 9714a238c70SJohn Marino changed (users interested in the *note ternary value:: should use 9724a238c70SJohn Marino `mpfr_strtofr' instead). 9734a238c70SJohn Marino 9744a238c70SJohn Marino Note: it is preferable to use `mpfr_set_str' if one wants to 9754a238c70SJohn Marino distinguish between an infinite ROP value coming from an infinite 9764a238c70SJohn Marino S or from an overflow. 9774a238c70SJohn Marino 9784a238c70SJohn Marino -- Function: int mpfr_strtofr (mpfr_t ROP, const char *NPTR, char 9794a238c70SJohn Marino **ENDPTR, int BASE, mpfr_rnd_t RND) 9804a238c70SJohn Marino Read a floating-point number from a string NPTR in base BASE, 9814a238c70SJohn Marino rounded in the direction RND; BASE must be either 0 (to detect the 9824a238c70SJohn Marino base, as described below) or a number from 2 to 62 (otherwise the 9834a238c70SJohn Marino behavior is undefined). If NPTR starts with valid data, the result 9844a238c70SJohn Marino is stored in ROP and `*ENDPTR' points to the character just after 9854a238c70SJohn Marino the valid data (if ENDPTR is not a null pointer); otherwise ROP is 9864a238c70SJohn Marino set to zero (for consistency with `strtod') and the value of NPTR 9874a238c70SJohn Marino is stored in the location referenced by ENDPTR (if ENDPTR is not a 9884a238c70SJohn Marino null pointer). The usual ternary value is returned. 9894a238c70SJohn Marino 9904a238c70SJohn Marino Parsing follows the standard C `strtod' function with some 9914a238c70SJohn Marino extensions. After optional leading whitespace, one has a subject 9924a238c70SJohn Marino sequence consisting of an optional sign (`+' or `-'), and either 9934a238c70SJohn Marino numeric data or special data. The subject sequence is defined as 9944a238c70SJohn Marino the longest initial subsequence of the input string, starting with 9954a238c70SJohn Marino the first non-whitespace character, that is of the expected form. 9964a238c70SJohn Marino 9974a238c70SJohn Marino The form of numeric data is a non-empty sequence of significand 9984a238c70SJohn Marino digits with an optional decimal point, and an optional exponent 9994a238c70SJohn Marino consisting of an exponent prefix followed by an optional sign and 10004a238c70SJohn Marino a non-empty sequence of decimal digits. A significand digit is 10014a238c70SJohn Marino either a decimal digit or a Latin letter (62 possible characters), 10024a238c70SJohn Marino with `A' = 10, `B' = 11, ..., `Z' = 35; case is ignored in bases 10034a238c70SJohn Marino less or equal to 36, in bases larger than 36, `a' = 36, `b' = 37, 10044a238c70SJohn Marino ..., `z' = 61. The value of a significand digit must be strictly 10054a238c70SJohn Marino less than the base. The decimal point can be either the one 10064a238c70SJohn Marino defined by the current locale or the period (the first one is 10074a238c70SJohn Marino accepted for consistency with the C standard and the practice, the 10084a238c70SJohn Marino second one is accepted to allow the programmer to provide MPFR 10094a238c70SJohn Marino numbers from strings in a way that does not depend on the current 10104a238c70SJohn Marino locale). The exponent prefix can be `e' or `E' for bases up to 10114a238c70SJohn Marino 10, or `@' in any base; it indicates a multiplication by a power 10124a238c70SJohn Marino of the base. In bases 2 and 16, the exponent prefix can also be 10134a238c70SJohn Marino `p' or `P', in which case the exponent, called _binary exponent_, 10144a238c70SJohn Marino indicates a multiplication by a power of 2 instead of the base 10154a238c70SJohn Marino (there is a difference only for base 16); in base 16 for example 10164a238c70SJohn Marino `1p2' represents 4 whereas `1@2' represents 256. The value of an 10174a238c70SJohn Marino exponent is always written in base 10. 10184a238c70SJohn Marino 10194a238c70SJohn Marino If the argument BASE is 0, then the base is automatically detected 10204a238c70SJohn Marino as follows. If the significand starts with `0b' or `0B', base 2 is 10214a238c70SJohn Marino assumed. If the significand starts with `0x' or `0X', base 16 is 10224a238c70SJohn Marino assumed. Otherwise base 10 is assumed. 10234a238c70SJohn Marino 10244a238c70SJohn Marino Note: The exponent (if present) must contain at least a digit. 10254a238c70SJohn Marino Otherwise the possible exponent prefix and sign are not part of 10264a238c70SJohn Marino the number (which ends with the significand). Similarly, if `0b', 10274a238c70SJohn Marino `0B', `0x' or `0X' is not followed by a binary/hexadecimal digit, 10284a238c70SJohn Marino then the subject sequence stops at the character `0', thus 0 is 10294a238c70SJohn Marino read. 10304a238c70SJohn Marino 10314a238c70SJohn Marino Special data (for infinities and NaN) can be `@inf@' or 10324a238c70SJohn Marino `@nan@(n-char-sequence-opt)', and if BASE <= 16, it can also be 10334a238c70SJohn Marino `infinity', `inf', `nan' or `nan(n-char-sequence-opt)', all case 10344a238c70SJohn Marino insensitive. A `n-char-sequence-opt' is a possibly empty string 10354a238c70SJohn Marino containing only digits, Latin letters and the underscore (0, 1, 2, 10364a238c70SJohn Marino ..., 9, a, b, ..., z, A, B, ..., Z, _). Note: one has an optional 10374a238c70SJohn Marino sign for all data, even NaN. For example, 10384a238c70SJohn Marino `-@nAn@(This_Is_Not_17)' is a valid representation for NaN in base 10394a238c70SJohn Marino 17. 10404a238c70SJohn Marino 10414a238c70SJohn Marino 10424a238c70SJohn Marino -- Function: void mpfr_set_nan (mpfr_t X) 10434a238c70SJohn Marino -- Function: void mpfr_set_inf (mpfr_t X, int SIGN) 10444a238c70SJohn Marino -- Function: void mpfr_set_zero (mpfr_t X, int SIGN) 10454a238c70SJohn Marino Set the variable X to NaN (Not-a-Number), infinity or zero 10464a238c70SJohn Marino respectively. In `mpfr_set_inf' or `mpfr_set_zero', X is set to 10474a238c70SJohn Marino plus infinity or plus zero iff SIGN is nonnegative; in 10484a238c70SJohn Marino `mpfr_set_nan', the sign bit of the result is unspecified. 10494a238c70SJohn Marino 10504a238c70SJohn Marino -- Function: void mpfr_swap (mpfr_t X, mpfr_t Y) 10514a238c70SJohn Marino Swap the values X and Y efficiently. Warning: the precisions are 10524a238c70SJohn Marino exchanged too; in case the precisions are different, `mpfr_swap' 10534a238c70SJohn Marino is thus not equivalent to three `mpfr_set' calls using a third 10544a238c70SJohn Marino auxiliary variable. 10554a238c70SJohn Marino 10564a238c70SJohn Marino 10574a238c70SJohn MarinoFile: mpfr.info, Node: Combined Initialization and Assignment Functions, Next: Conversion Functions, Prev: Assignment Functions, Up: MPFR Interface 10584a238c70SJohn Marino 10594a238c70SJohn Marino5.3 Combined Initialization and Assignment Functions 10604a238c70SJohn Marino==================================================== 10614a238c70SJohn Marino 10624a238c70SJohn Marino -- Macro: int mpfr_init_set (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 10634a238c70SJohn Marino -- Macro: int mpfr_init_set_ui (mpfr_t ROP, unsigned long int OP, 10644a238c70SJohn Marino mpfr_rnd_t RND) 10654a238c70SJohn Marino -- Macro: int mpfr_init_set_si (mpfr_t ROP, long int OP, mpfr_rnd_t 10664a238c70SJohn Marino RND) 10674a238c70SJohn Marino -- Macro: int mpfr_init_set_d (mpfr_t ROP, double OP, mpfr_rnd_t RND) 10684a238c70SJohn Marino -- Macro: int mpfr_init_set_ld (mpfr_t ROP, long double OP, mpfr_rnd_t 10694a238c70SJohn Marino RND) 10704a238c70SJohn Marino -- Macro: int mpfr_init_set_z (mpfr_t ROP, mpz_t OP, mpfr_rnd_t RND) 10714a238c70SJohn Marino -- Macro: int mpfr_init_set_q (mpfr_t ROP, mpq_t OP, mpfr_rnd_t RND) 10724a238c70SJohn Marino -- Macro: int mpfr_init_set_f (mpfr_t ROP, mpf_t OP, mpfr_rnd_t RND) 10734a238c70SJohn Marino Initialize ROP and set its value from OP, rounded in the direction 10744a238c70SJohn Marino RND. The precision of ROP will be taken from the active default 10754a238c70SJohn Marino precision, as set by `mpfr_set_default_prec'. 10764a238c70SJohn Marino 10774a238c70SJohn Marino -- Function: int mpfr_init_set_str (mpfr_t X, const char *S, int BASE, 10784a238c70SJohn Marino mpfr_rnd_t RND) 10794a238c70SJohn Marino Initialize X and set its value from the string S in base BASE, 10804a238c70SJohn Marino rounded in the direction RND. See `mpfr_set_str'. 10814a238c70SJohn Marino 10824a238c70SJohn Marino 10834a238c70SJohn MarinoFile: mpfr.info, Node: Conversion Functions, Next: Basic Arithmetic Functions, Prev: Combined Initialization and Assignment Functions, Up: MPFR Interface 10844a238c70SJohn Marino 10854a238c70SJohn Marino5.4 Conversion Functions 10864a238c70SJohn Marino======================== 10874a238c70SJohn Marino 10884a238c70SJohn Marino -- Function: float mpfr_get_flt (mpfr_t OP, mpfr_rnd_t RND) 10894a238c70SJohn Marino -- Function: double mpfr_get_d (mpfr_t OP, mpfr_rnd_t RND) 10904a238c70SJohn Marino -- Function: long double mpfr_get_ld (mpfr_t OP, mpfr_rnd_t RND) 10914a238c70SJohn Marino -- Function: _Decimal64 mpfr_get_decimal64 (mpfr_t OP, mpfr_rnd_t RND) 10924a238c70SJohn Marino Convert OP to a `float' (respectively `double', `long double' or 10934a238c70SJohn Marino `_Decimal64'), using the rounding mode RND. If OP is NaN, some 10944a238c70SJohn Marino fixed NaN (either quiet or signaling) or the result of 0.0/0.0 is 10954a238c70SJohn Marino returned. If OP is ±Inf, an infinity of the same sign or the 10964a238c70SJohn Marino result of ±1.0/0.0 is returned. If OP is zero, these functions 10974a238c70SJohn Marino return a zero, trying to preserve its sign, if possible. The 10984a238c70SJohn Marino `mpfr_get_decimal64' function is built only under some conditions: 10994a238c70SJohn Marino see the documentation of `mpfr_set_decimal64'. 11004a238c70SJohn Marino 11014a238c70SJohn Marino -- Function: long mpfr_get_si (mpfr_t OP, mpfr_rnd_t RND) 11024a238c70SJohn Marino -- Function: unsigned long mpfr_get_ui (mpfr_t OP, mpfr_rnd_t RND) 11034a238c70SJohn Marino -- Function: intmax_t mpfr_get_sj (mpfr_t OP, mpfr_rnd_t RND) 11044a238c70SJohn Marino -- Function: uintmax_t mpfr_get_uj (mpfr_t OP, mpfr_rnd_t RND) 11054a238c70SJohn Marino Convert OP to a `long', an `unsigned long', an `intmax_t' or an 11064a238c70SJohn Marino `uintmax_t' (respectively) after rounding it with respect to RND. 11074a238c70SJohn Marino If OP is NaN, 0 is returned and the _erange_ flag is set. If OP 11084a238c70SJohn Marino is too big for the return type, the function returns the maximum 11094a238c70SJohn Marino or the minimum of the corresponding C type, depending on the 11104a238c70SJohn Marino direction of the overflow; the _erange_ flag is set too. See also 11114a238c70SJohn Marino `mpfr_fits_slong_p', `mpfr_fits_ulong_p', `mpfr_fits_intmax_p' and 11124a238c70SJohn Marino `mpfr_fits_uintmax_p'. 11134a238c70SJohn Marino 11144a238c70SJohn Marino -- Function: double mpfr_get_d_2exp (long *EXP, mpfr_t OP, mpfr_rnd_t 11154a238c70SJohn Marino RND) 11164a238c70SJohn Marino -- Function: long double mpfr_get_ld_2exp (long *EXP, mpfr_t OP, 11174a238c70SJohn Marino mpfr_rnd_t RND) 11184a238c70SJohn Marino Return D and set EXP (formally, the value pointed to by EXP) such 11194a238c70SJohn Marino that 0.5<=abs(D)<1 and D times 2 raised to EXP equals OP rounded 11204a238c70SJohn Marino to double (resp. long double) precision, using the given rounding 11214a238c70SJohn Marino mode. If OP is zero, then a zero of the same sign (or an unsigned 11224a238c70SJohn Marino zero, if the implementation does not have signed zeros) is 11234a238c70SJohn Marino returned, and EXP is set to 0. If OP is NaN or an infinity, then 11244a238c70SJohn Marino the corresponding double precision (resp. long-double precision) 11254a238c70SJohn Marino value is returned, and EXP is undefined. 11264a238c70SJohn Marino 11274a238c70SJohn Marino -- Function: int mpfr_frexp (mpfr_exp_t *EXP, mpfr_t Y, mpfr_t X, 11284a238c70SJohn Marino mpfr_rnd_t RND) 11294a238c70SJohn Marino Set EXP (formally, the value pointed to by EXP) and Y such that 11304a238c70SJohn Marino 0.5<=abs(Y)<1 and Y times 2 raised to EXP equals X rounded to the 11314a238c70SJohn Marino precision of Y, using the given rounding mode. If X is zero, then 11324a238c70SJohn Marino Y is set to a zero of the same sign and EXP is set to 0. If X is 11334a238c70SJohn Marino NaN or an infinity, then Y is set to the same value and EXP is 11344a238c70SJohn Marino undefined. 11354a238c70SJohn Marino 11364a238c70SJohn Marino -- Function: mpfr_exp_t mpfr_get_z_2exp (mpz_t ROP, mpfr_t OP) 11374a238c70SJohn Marino Put the scaled significand of OP (regarded as an integer, with the 11384a238c70SJohn Marino precision of OP) into ROP, and return the exponent EXP (which may 11394a238c70SJohn Marino be outside the current exponent range) such that OP exactly equals 11404a238c70SJohn Marino ROP times 2 raised to the power EXP. If OP is zero, the minimal 11414a238c70SJohn Marino exponent `emin' is returned. If OP is NaN or an infinity, the 11424a238c70SJohn Marino _erange_ flag is set, ROP is set to 0, and the the minimal 11434a238c70SJohn Marino exponent `emin' is returned. The returned exponent may be less 11444a238c70SJohn Marino than the minimal exponent `emin' of MPFR numbers in the current 11454a238c70SJohn Marino exponent range; in case the exponent is not representable in the 11464a238c70SJohn Marino `mpfr_exp_t' type, the _erange_ flag is set and the minimal value 11474a238c70SJohn Marino of the `mpfr_exp_t' type is returned. 11484a238c70SJohn Marino 11494a238c70SJohn Marino -- Function: int mpfr_get_z (mpz_t ROP, mpfr_t OP, mpfr_rnd_t RND) 11504a238c70SJohn Marino Convert OP to a `mpz_t', after rounding it with respect to RND. If 11514a238c70SJohn Marino OP is NaN or an infinity, the _erange_ flag is set, ROP is set to 11524a238c70SJohn Marino 0, and 0 is returned. 11534a238c70SJohn Marino 11544a238c70SJohn Marino -- Function: int mpfr_get_f (mpf_t ROP, mpfr_t OP, mpfr_rnd_t RND) 11554a238c70SJohn Marino Convert OP to a `mpf_t', after rounding it with respect to RND. 11564a238c70SJohn Marino The _erange_ flag is set if OP is NaN or an infinity, which do not 11574a238c70SJohn Marino exist in MPF. If OP is NaN, then ROP is undefined. If OP is an 11584a238c70SJohn Marino +Inf (resp. -Inf), then ROP is set to the maximum (resp. minimum) 11594a238c70SJohn Marino value in the precision of the MPF number; if a future MPF version 11604a238c70SJohn Marino supports infinities, this behavior will be considered incorrect 11614a238c70SJohn Marino and will change (portable programs should assume that ROP is set 11624a238c70SJohn Marino either to this finite number or to an infinite number). Note that 11634a238c70SJohn Marino since MPFR currently has the same exponent type as MPF (but not 11644a238c70SJohn Marino with the same radix), the range of values is much larger in MPF 11654a238c70SJohn Marino than in MPFR, so that an overflow or underflow is not possible. 11664a238c70SJohn Marino 11674a238c70SJohn Marino -- Function: char * mpfr_get_str (char *STR, mpfr_exp_t *EXPPTR, int 11684a238c70SJohn Marino B, size_t N, mpfr_t OP, mpfr_rnd_t RND) 11694a238c70SJohn Marino Convert OP to a string of digits in base B, with rounding in the 11704a238c70SJohn Marino direction RND, where N is either zero (see below) or the number of 11714a238c70SJohn Marino significant digits output in the string; in the latter case, N 11724a238c70SJohn Marino must be greater or equal to 2. The base may vary from 2 to 62. If 11734a238c70SJohn Marino the input number is an ordinary number, the exponent is written 11744a238c70SJohn Marino through the pointer EXPPTR (for input 0, the current minimal 11754a238c70SJohn Marino exponent is written). 11764a238c70SJohn Marino 11774a238c70SJohn Marino The generated string is a fraction, with an implicit radix point 11784a238c70SJohn Marino immediately to the left of the first digit. For example, the 11794a238c70SJohn Marino number -3.1416 would be returned as "-31416" in the string and 1 11804a238c70SJohn Marino written at EXPPTR. If RND is to nearest, and OP is exactly in the 11814a238c70SJohn Marino middle of two consecutive possible outputs, the one with an even 11824a238c70SJohn Marino significand is chosen, where both significands are considered with 11834a238c70SJohn Marino the exponent of OP. Note that for an odd base, this may not 11844a238c70SJohn Marino correspond to an even last digit: for example with 2 digits in 11854a238c70SJohn Marino base 7, (14) and a half is rounded to (15) which is 12 in decimal, 11864a238c70SJohn Marino (16) and a half is rounded to (20) which is 14 in decimal, and 11874a238c70SJohn Marino (26) and a half is rounded to (26) which is 20 in decimal. 11884a238c70SJohn Marino 11894a238c70SJohn Marino If N is zero, the number of digits of the significand is chosen 11904a238c70SJohn Marino large enough so that re-reading the printed value with the same 11914a238c70SJohn Marino precision, assuming both output and input use rounding to nearest, 11924a238c70SJohn Marino will recover the original value of OP. More precisely, in most 11934a238c70SJohn Marino cases, the chosen precision of STR is the minimal precision m 11944a238c70SJohn Marino depending only on P = PREC(OP) and B that satisfies the above 11954a238c70SJohn Marino property, i.e., m = 1 + ceil(P*log(2)/log(B)), with P replaced by 11964a238c70SJohn Marino P-1 if B is a power of 2, but in some very rare cases, it might be 11974a238c70SJohn Marino m+1 (the smallest case for bases up to 62 is when P equals 11984a238c70SJohn Marino 186564318007 for bases 7 and 49). 11994a238c70SJohn Marino 12004a238c70SJohn Marino If STR is a null pointer, space for the significand is allocated 12014a238c70SJohn Marino using the current allocation function, and a pointer to the string 12024a238c70SJohn Marino is returned. To free the returned string, you must use 12034a238c70SJohn Marino `mpfr_free_str'. 12044a238c70SJohn Marino 12054a238c70SJohn Marino If STR is not a null pointer, it should point to a block of storage 12064a238c70SJohn Marino large enough for the significand, i.e., at least `max(N + 2, 7)'. 12074a238c70SJohn Marino The extra two bytes are for a possible minus sign, and for the 12084a238c70SJohn Marino terminating null character, and the value 7 accounts for `-@Inf@' 12094a238c70SJohn Marino plus the terminating null character. 12104a238c70SJohn Marino 12114a238c70SJohn Marino A pointer to the string is returned, unless there is an error, in 12124a238c70SJohn Marino which case a null pointer is returned. 12134a238c70SJohn Marino 12144a238c70SJohn Marino -- Function: void mpfr_free_str (char *STR) 12154a238c70SJohn Marino Free a string allocated by `mpfr_get_str' using the current 12164a238c70SJohn Marino unallocation function. The block is assumed to be `strlen(STR)+1' 12174a238c70SJohn Marino bytes. For more information about how it is done: *note Custom 12184a238c70SJohn Marino Allocation: (gmp.info)Custom Allocation. 12194a238c70SJohn Marino 12204a238c70SJohn Marino -- Function: int mpfr_fits_ulong_p (mpfr_t OP, mpfr_rnd_t RND) 12214a238c70SJohn Marino -- Function: int mpfr_fits_slong_p (mpfr_t OP, mpfr_rnd_t RND) 12224a238c70SJohn Marino -- Function: int mpfr_fits_uint_p (mpfr_t OP, mpfr_rnd_t RND) 12234a238c70SJohn Marino -- Function: int mpfr_fits_sint_p (mpfr_t OP, mpfr_rnd_t RND) 12244a238c70SJohn Marino -- Function: int mpfr_fits_ushort_p (mpfr_t OP, mpfr_rnd_t RND) 12254a238c70SJohn Marino -- Function: int mpfr_fits_sshort_p (mpfr_t OP, mpfr_rnd_t RND) 12264a238c70SJohn Marino -- Function: int mpfr_fits_uintmax_p (mpfr_t OP, mpfr_rnd_t RND) 12274a238c70SJohn Marino -- Function: int mpfr_fits_intmax_p (mpfr_t OP, mpfr_rnd_t RND) 12284a238c70SJohn Marino Return non-zero if OP would fit in the respective C data type, 12294a238c70SJohn Marino respectively `unsigned long', `long', `unsigned int', `int', 12304a238c70SJohn Marino `unsigned short', `short', `uintmax_t', `intmax_t', when rounded 12314a238c70SJohn Marino to an integer in the direction RND. 12324a238c70SJohn Marino 12334a238c70SJohn Marino 12344a238c70SJohn MarinoFile: mpfr.info, Node: Basic Arithmetic Functions, Next: Comparison Functions, Prev: Conversion Functions, Up: MPFR Interface 12354a238c70SJohn Marino 12364a238c70SJohn Marino5.5 Basic Arithmetic Functions 12374a238c70SJohn Marino============================== 12384a238c70SJohn Marino 12394a238c70SJohn Marino -- Function: int mpfr_add (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, 12404a238c70SJohn Marino mpfr_rnd_t RND) 12414a238c70SJohn Marino -- Function: int mpfr_add_ui (mpfr_t ROP, mpfr_t OP1, unsigned long 12424a238c70SJohn Marino int OP2, mpfr_rnd_t RND) 12434a238c70SJohn Marino -- Function: int mpfr_add_si (mpfr_t ROP, mpfr_t OP1, long int OP2, 12444a238c70SJohn Marino mpfr_rnd_t RND) 12454a238c70SJohn Marino -- Function: int mpfr_add_d (mpfr_t ROP, mpfr_t OP1, double OP2, 12464a238c70SJohn Marino mpfr_rnd_t RND) 12474a238c70SJohn Marino -- Function: int mpfr_add_z (mpfr_t ROP, mpfr_t OP1, mpz_t OP2, 12484a238c70SJohn Marino mpfr_rnd_t RND) 12494a238c70SJohn Marino -- Function: int mpfr_add_q (mpfr_t ROP, mpfr_t OP1, mpq_t OP2, 12504a238c70SJohn Marino mpfr_rnd_t RND) 12514a238c70SJohn Marino Set ROP to OP1 + OP2 rounded in the direction RND. For types 12524a238c70SJohn Marino having no signed zero, it is considered unsigned (i.e., (+0) + 0 = 12534a238c70SJohn Marino (+0) and (-0) + 0 = (-0)). The `mpfr_add_d' function assumes that 12544a238c70SJohn Marino the radix of the `double' type is a power of 2, with a precision 12554a238c70SJohn Marino at most that declared by the C implementation (macro 12564a238c70SJohn Marino `IEEE_DBL_MANT_DIG', and if not defined 53 bits). 12574a238c70SJohn Marino 12584a238c70SJohn Marino -- Function: int mpfr_sub (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, 12594a238c70SJohn Marino mpfr_rnd_t RND) 12604a238c70SJohn Marino -- Function: int mpfr_ui_sub (mpfr_t ROP, unsigned long int OP1, 12614a238c70SJohn Marino mpfr_t OP2, mpfr_rnd_t RND) 12624a238c70SJohn Marino -- Function: int mpfr_sub_ui (mpfr_t ROP, mpfr_t OP1, unsigned long 12634a238c70SJohn Marino int OP2, mpfr_rnd_t RND) 12644a238c70SJohn Marino -- Function: int mpfr_si_sub (mpfr_t ROP, long int OP1, mpfr_t OP2, 12654a238c70SJohn Marino mpfr_rnd_t RND) 12664a238c70SJohn Marino -- Function: int mpfr_sub_si (mpfr_t ROP, mpfr_t OP1, long int OP2, 12674a238c70SJohn Marino mpfr_rnd_t RND) 12684a238c70SJohn Marino -- Function: int mpfr_d_sub (mpfr_t ROP, double OP1, mpfr_t OP2, 12694a238c70SJohn Marino mpfr_rnd_t RND) 12704a238c70SJohn Marino -- Function: int mpfr_sub_d (mpfr_t ROP, mpfr_t OP1, double OP2, 12714a238c70SJohn Marino mpfr_rnd_t RND) 12724a238c70SJohn Marino -- Function: int mpfr_z_sub (mpfr_t ROP, mpz_t OP1, mpfr_t OP2, 12734a238c70SJohn Marino mpfr_rnd_t RND) 12744a238c70SJohn Marino -- Function: int mpfr_sub_z (mpfr_t ROP, mpfr_t OP1, mpz_t OP2, 12754a238c70SJohn Marino mpfr_rnd_t RND) 12764a238c70SJohn Marino -- Function: int mpfr_sub_q (mpfr_t ROP, mpfr_t OP1, mpq_t OP2, 12774a238c70SJohn Marino mpfr_rnd_t RND) 12784a238c70SJohn Marino Set ROP to OP1 - OP2 rounded in the direction RND. For types 12794a238c70SJohn Marino having no signed zero, it is considered unsigned (i.e., (+0) - 0 = 12804a238c70SJohn Marino (+0), (-0) - 0 = (-0), 0 - (+0) = (-0) and 0 - (-0) = (+0)). The 12814a238c70SJohn Marino same restrictions than for `mpfr_add_d' apply to `mpfr_d_sub' and 12824a238c70SJohn Marino `mpfr_sub_d'. 12834a238c70SJohn Marino 12844a238c70SJohn Marino -- Function: int mpfr_mul (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, 12854a238c70SJohn Marino mpfr_rnd_t RND) 12864a238c70SJohn Marino -- Function: int mpfr_mul_ui (mpfr_t ROP, mpfr_t OP1, unsigned long 12874a238c70SJohn Marino int OP2, mpfr_rnd_t RND) 12884a238c70SJohn Marino -- Function: int mpfr_mul_si (mpfr_t ROP, mpfr_t OP1, long int OP2, 12894a238c70SJohn Marino mpfr_rnd_t RND) 12904a238c70SJohn Marino -- Function: int mpfr_mul_d (mpfr_t ROP, mpfr_t OP1, double OP2, 12914a238c70SJohn Marino mpfr_rnd_t RND) 12924a238c70SJohn Marino -- Function: int mpfr_mul_z (mpfr_t ROP, mpfr_t OP1, mpz_t OP2, 12934a238c70SJohn Marino mpfr_rnd_t RND) 12944a238c70SJohn Marino -- Function: int mpfr_mul_q (mpfr_t ROP, mpfr_t OP1, mpq_t OP2, 12954a238c70SJohn Marino mpfr_rnd_t RND) 12964a238c70SJohn Marino Set ROP to OP1 times OP2 rounded in the direction RND. When a 12974a238c70SJohn Marino result is zero, its sign is the product of the signs of the 12984a238c70SJohn Marino operands (for types having no signed zero, it is considered 12994a238c70SJohn Marino positive). The same restrictions than for `mpfr_add_d' apply to 13004a238c70SJohn Marino `mpfr_mul_d'. 13014a238c70SJohn Marino 13024a238c70SJohn Marino -- Function: int mpfr_sqr (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 13034a238c70SJohn Marino Set ROP to the square of OP rounded in the direction RND. 13044a238c70SJohn Marino 13054a238c70SJohn Marino -- Function: int mpfr_div (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, 13064a238c70SJohn Marino mpfr_rnd_t RND) 13074a238c70SJohn Marino -- Function: int mpfr_ui_div (mpfr_t ROP, unsigned long int OP1, 13084a238c70SJohn Marino mpfr_t OP2, mpfr_rnd_t RND) 13094a238c70SJohn Marino -- Function: int mpfr_div_ui (mpfr_t ROP, mpfr_t OP1, unsigned long 13104a238c70SJohn Marino int OP2, mpfr_rnd_t RND) 13114a238c70SJohn Marino -- Function: int mpfr_si_div (mpfr_t ROP, long int OP1, mpfr_t OP2, 13124a238c70SJohn Marino mpfr_rnd_t RND) 13134a238c70SJohn Marino -- Function: int mpfr_div_si (mpfr_t ROP, mpfr_t OP1, long int OP2, 13144a238c70SJohn Marino mpfr_rnd_t RND) 13154a238c70SJohn Marino -- Function: int mpfr_d_div (mpfr_t ROP, double OP1, mpfr_t OP2, 13164a238c70SJohn Marino mpfr_rnd_t RND) 13174a238c70SJohn Marino -- Function: int mpfr_div_d (mpfr_t ROP, mpfr_t OP1, double OP2, 13184a238c70SJohn Marino mpfr_rnd_t RND) 13194a238c70SJohn Marino -- Function: int mpfr_div_z (mpfr_t ROP, mpfr_t OP1, mpz_t OP2, 13204a238c70SJohn Marino mpfr_rnd_t RND) 13214a238c70SJohn Marino -- Function: int mpfr_div_q (mpfr_t ROP, mpfr_t OP1, mpq_t OP2, 13224a238c70SJohn Marino mpfr_rnd_t RND) 13234a238c70SJohn Marino Set ROP to OP1/OP2 rounded in the direction RND. When a result is 13244a238c70SJohn Marino zero, its sign is the product of the signs of the operands (for 13254a238c70SJohn Marino types having no signed zero, it is considered positive). The same 13264a238c70SJohn Marino restrictions than for `mpfr_add_d' apply to `mpfr_d_div' and 13274a238c70SJohn Marino `mpfr_div_d'. 13284a238c70SJohn Marino 13294a238c70SJohn Marino -- Function: int mpfr_sqrt (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 13304a238c70SJohn Marino -- Function: int mpfr_sqrt_ui (mpfr_t ROP, unsigned long int OP, 13314a238c70SJohn Marino mpfr_rnd_t RND) 13324a238c70SJohn Marino Set ROP to the square root of OP rounded in the direction RND (set 13334a238c70SJohn Marino ROP to -0 if OP is -0, to be consistent with the IEEE 754 13344a238c70SJohn Marino standard). Set ROP to NaN if OP is negative. 13354a238c70SJohn Marino 13364a238c70SJohn Marino -- Function: int mpfr_rec_sqrt (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 13374a238c70SJohn Marino Set ROP to the reciprocal square root of OP rounded in the 13384a238c70SJohn Marino direction RND. Set ROP to +Inf if OP is ±0, +0 if OP is +Inf, and 13394a238c70SJohn Marino NaN if OP is negative. 13404a238c70SJohn Marino 13414a238c70SJohn Marino -- Function: int mpfr_cbrt (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 13424a238c70SJohn Marino -- Function: int mpfr_root (mpfr_t ROP, mpfr_t OP, unsigned long int 13434a238c70SJohn Marino K, mpfr_rnd_t RND) 13444a238c70SJohn Marino Set ROP to the cubic root (resp. the Kth root) of OP rounded in 13454a238c70SJohn Marino the direction RND. For K odd (resp. even) and OP negative 13464a238c70SJohn Marino (including -Inf), set ROP to a negative number (resp. NaN). The 13474a238c70SJohn Marino Kth root of -0 is defined to be -0, whatever the parity of K. 13484a238c70SJohn Marino 13494a238c70SJohn Marino -- Function: int mpfr_pow (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, 13504a238c70SJohn Marino mpfr_rnd_t RND) 13514a238c70SJohn Marino -- Function: int mpfr_pow_ui (mpfr_t ROP, mpfr_t OP1, unsigned long 13524a238c70SJohn Marino int OP2, mpfr_rnd_t RND) 13534a238c70SJohn Marino -- Function: int mpfr_pow_si (mpfr_t ROP, mpfr_t OP1, long int OP2, 13544a238c70SJohn Marino mpfr_rnd_t RND) 13554a238c70SJohn Marino -- Function: int mpfr_pow_z (mpfr_t ROP, mpfr_t OP1, mpz_t OP2, 13564a238c70SJohn Marino mpfr_rnd_t RND) 13574a238c70SJohn Marino -- Function: int mpfr_ui_pow_ui (mpfr_t ROP, unsigned long int OP1, 13584a238c70SJohn Marino unsigned long int OP2, mpfr_rnd_t RND) 13594a238c70SJohn Marino -- Function: int mpfr_ui_pow (mpfr_t ROP, unsigned long int OP1, 13604a238c70SJohn Marino mpfr_t OP2, mpfr_rnd_t RND) 13614a238c70SJohn Marino Set ROP to OP1 raised to OP2, rounded in the direction RND. 13624a238c70SJohn Marino Special values are handled as described in the ISO C99 and IEEE 13634a238c70SJohn Marino 754-2008 standards for the `pow' function: 13644a238c70SJohn Marino * `pow(±0, Y)' returns plus or minus infinity for Y a negative 13654a238c70SJohn Marino odd integer. 13664a238c70SJohn Marino 13674a238c70SJohn Marino * `pow(±0, Y)' returns plus infinity for Y negative and not an 13684a238c70SJohn Marino odd integer. 13694a238c70SJohn Marino 13704a238c70SJohn Marino * `pow(±0, Y)' returns plus or minus zero for Y a positive odd 13714a238c70SJohn Marino integer. 13724a238c70SJohn Marino 13734a238c70SJohn Marino * `pow(±0, Y)' returns plus zero for Y positive and not an odd 13744a238c70SJohn Marino integer. 13754a238c70SJohn Marino 13764a238c70SJohn Marino * `pow(-1, ±Inf)' returns 1. 13774a238c70SJohn Marino 13784a238c70SJohn Marino * `pow(+1, Y)' returns 1 for any Y, even a NaN. 13794a238c70SJohn Marino 13804a238c70SJohn Marino * `pow(X, ±0)' returns 1 for any X, even a NaN. 13814a238c70SJohn Marino 13824a238c70SJohn Marino * `pow(X, Y)' returns NaN for finite negative X and finite 13834a238c70SJohn Marino non-integer Y. 13844a238c70SJohn Marino 13854a238c70SJohn Marino * `pow(X, -Inf)' returns plus infinity for 0 < abs(x) < 1, and 13864a238c70SJohn Marino plus zero for abs(x) > 1. 13874a238c70SJohn Marino 13884a238c70SJohn Marino * `pow(X, +Inf)' returns plus zero for 0 < abs(x) < 1, and plus 13894a238c70SJohn Marino infinity for abs(x) > 1. 13904a238c70SJohn Marino 13914a238c70SJohn Marino * `pow(-Inf, Y)' returns minus zero for Y a negative odd 13924a238c70SJohn Marino integer. 13934a238c70SJohn Marino 13944a238c70SJohn Marino * `pow(-Inf, Y)' returns plus zero for Y negative and not an 13954a238c70SJohn Marino odd integer. 13964a238c70SJohn Marino 13974a238c70SJohn Marino * `pow(-Inf, Y)' returns minus infinity for Y a positive odd 13984a238c70SJohn Marino integer. 13994a238c70SJohn Marino 14004a238c70SJohn Marino * `pow(-Inf, Y)' returns plus infinity for Y positive and not 14014a238c70SJohn Marino an odd integer. 14024a238c70SJohn Marino 14034a238c70SJohn Marino * `pow(+Inf, Y)' returns plus zero for Y negative, and plus 14044a238c70SJohn Marino infinity for Y positive. 14054a238c70SJohn Marino 14064a238c70SJohn Marino -- Function: int mpfr_neg (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 14074a238c70SJohn Marino -- Function: int mpfr_abs (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 14084a238c70SJohn Marino Set ROP to -OP and the absolute value of OP respectively, rounded 14094a238c70SJohn Marino in the direction RND. Just changes or adjusts the sign if ROP and 14104a238c70SJohn Marino OP are the same variable, otherwise a rounding might occur if the 14114a238c70SJohn Marino precision of ROP is less than that of OP. 14124a238c70SJohn Marino 14134a238c70SJohn Marino -- Function: int mpfr_dim (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, 14144a238c70SJohn Marino mpfr_rnd_t RND) 14154a238c70SJohn Marino Set ROP to the positive difference of OP1 and OP2, i.e., OP1 - OP2 14164a238c70SJohn Marino rounded in the direction RND if OP1 > OP2, +0 if OP1 <= OP2, and 14174a238c70SJohn Marino NaN if OP1 or OP2 is NaN. 14184a238c70SJohn Marino 14194a238c70SJohn Marino -- Function: int mpfr_mul_2ui (mpfr_t ROP, mpfr_t OP1, unsigned long 14204a238c70SJohn Marino int OP2, mpfr_rnd_t RND) 14214a238c70SJohn Marino -- Function: int mpfr_mul_2si (mpfr_t ROP, mpfr_t OP1, long int OP2, 14224a238c70SJohn Marino mpfr_rnd_t RND) 14234a238c70SJohn Marino Set ROP to OP1 times 2 raised to OP2 rounded in the direction RND. 14244a238c70SJohn Marino Just increases the exponent by OP2 when ROP and OP1 are identical. 14254a238c70SJohn Marino 14264a238c70SJohn Marino -- Function: int mpfr_div_2ui (mpfr_t ROP, mpfr_t OP1, unsigned long 14274a238c70SJohn Marino int OP2, mpfr_rnd_t RND) 14284a238c70SJohn Marino -- Function: int mpfr_div_2si (mpfr_t ROP, mpfr_t OP1, long int OP2, 14294a238c70SJohn Marino mpfr_rnd_t RND) 14304a238c70SJohn Marino Set ROP to OP1 divided by 2 raised to OP2 rounded in the direction 14314a238c70SJohn Marino RND. Just decreases the exponent by OP2 when ROP and OP1 are 14324a238c70SJohn Marino identical. 14334a238c70SJohn Marino 14344a238c70SJohn Marino 14354a238c70SJohn MarinoFile: mpfr.info, Node: Comparison Functions, Next: Special Functions, Prev: Basic Arithmetic Functions, Up: MPFR Interface 14364a238c70SJohn Marino 14374a238c70SJohn Marino5.6 Comparison Functions 14384a238c70SJohn Marino======================== 14394a238c70SJohn Marino 14404a238c70SJohn Marino -- Function: int mpfr_cmp (mpfr_t OP1, mpfr_t OP2) 14414a238c70SJohn Marino -- Function: int mpfr_cmp_ui (mpfr_t OP1, unsigned long int OP2) 14424a238c70SJohn Marino -- Function: int mpfr_cmp_si (mpfr_t OP1, long int OP2) 14434a238c70SJohn Marino -- Function: int mpfr_cmp_d (mpfr_t OP1, double OP2) 14444a238c70SJohn Marino -- Function: int mpfr_cmp_ld (mpfr_t OP1, long double OP2) 14454a238c70SJohn Marino -- Function: int mpfr_cmp_z (mpfr_t OP1, mpz_t OP2) 14464a238c70SJohn Marino -- Function: int mpfr_cmp_q (mpfr_t OP1, mpq_t OP2) 14474a238c70SJohn Marino -- Function: int mpfr_cmp_f (mpfr_t OP1, mpf_t OP2) 14484a238c70SJohn Marino Compare OP1 and OP2. Return a positive value if OP1 > OP2, zero 14494a238c70SJohn Marino if OP1 = OP2, and a negative value if OP1 < OP2. Both OP1 and OP2 14504a238c70SJohn Marino are considered to their full own precision, which may differ. If 14514a238c70SJohn Marino one of the operands is NaN, set the _erange_ flag and return zero. 14524a238c70SJohn Marino 14534a238c70SJohn Marino Note: These functions may be useful to distinguish the three 14544a238c70SJohn Marino possible cases. If you need to distinguish two cases only, it is 14554a238c70SJohn Marino recommended to use the predicate functions (e.g., `mpfr_equal_p' 14564a238c70SJohn Marino for the equality) described below; they behave like the IEEE 754 14574a238c70SJohn Marino comparisons, in particular when one or both arguments are NaN. But 14584a238c70SJohn Marino only floating-point numbers can be compared (you may need to do a 14594a238c70SJohn Marino conversion first). 14604a238c70SJohn Marino 14614a238c70SJohn Marino -- Function: int mpfr_cmp_ui_2exp (mpfr_t OP1, unsigned long int OP2, 14624a238c70SJohn Marino mpfr_exp_t E) 14634a238c70SJohn Marino -- Function: int mpfr_cmp_si_2exp (mpfr_t OP1, long int OP2, 14644a238c70SJohn Marino mpfr_exp_t E) 14654a238c70SJohn Marino Compare OP1 and OP2 multiplied by two to the power E. Similar as 14664a238c70SJohn Marino above. 14674a238c70SJohn Marino 14684a238c70SJohn Marino -- Function: int mpfr_cmpabs (mpfr_t OP1, mpfr_t OP2) 14694a238c70SJohn Marino Compare |OP1| and |OP2|. Return a positive value if |OP1| > 14704a238c70SJohn Marino |OP2|, zero if |OP1| = |OP2|, and a negative value if |OP1| < 14714a238c70SJohn Marino |OP2|. If one of the operands is NaN, set the _erange_ flag and 14724a238c70SJohn Marino return zero. 14734a238c70SJohn Marino 14744a238c70SJohn Marino -- Function: int mpfr_nan_p (mpfr_t OP) 14754a238c70SJohn Marino -- Function: int mpfr_inf_p (mpfr_t OP) 14764a238c70SJohn Marino -- Function: int mpfr_number_p (mpfr_t OP) 14774a238c70SJohn Marino -- Function: int mpfr_zero_p (mpfr_t OP) 14784a238c70SJohn Marino -- Function: int mpfr_regular_p (mpfr_t OP) 14794a238c70SJohn Marino Return non-zero if OP is respectively NaN, an infinity, an ordinary 14804a238c70SJohn Marino number (i.e., neither NaN nor an infinity), zero, or a regular 14814a238c70SJohn Marino number (i.e., neither NaN, nor an infinity nor zero). Return zero 14824a238c70SJohn Marino otherwise. 14834a238c70SJohn Marino 14844a238c70SJohn Marino -- Macro: int mpfr_sgn (mpfr_t OP) 14854a238c70SJohn Marino Return a positive value if OP > 0, zero if OP = 0, and a negative 14864a238c70SJohn Marino value if OP < 0. If the operand is NaN, set the _erange_ flag and 14874a238c70SJohn Marino return zero. This is equivalent to `mpfr_cmp_ui (op, 0)', but 14884a238c70SJohn Marino more efficient. 14894a238c70SJohn Marino 14904a238c70SJohn Marino -- Function: int mpfr_greater_p (mpfr_t OP1, mpfr_t OP2) 14914a238c70SJohn Marino -- Function: int mpfr_greaterequal_p (mpfr_t OP1, mpfr_t OP2) 14924a238c70SJohn Marino -- Function: int mpfr_less_p (mpfr_t OP1, mpfr_t OP2) 14934a238c70SJohn Marino -- Function: int mpfr_lessequal_p (mpfr_t OP1, mpfr_t OP2) 14944a238c70SJohn Marino -- Function: int mpfr_equal_p (mpfr_t OP1, mpfr_t OP2) 14954a238c70SJohn Marino Return non-zero if OP1 > OP2, OP1 >= OP2, OP1 < OP2, OP1 <= OP2, 14964a238c70SJohn Marino OP1 = OP2 respectively, and zero otherwise. Those functions 14974a238c70SJohn Marino return zero whenever OP1 and/or OP2 is NaN. 14984a238c70SJohn Marino 14994a238c70SJohn Marino -- Function: int mpfr_lessgreater_p (mpfr_t OP1, mpfr_t OP2) 15004a238c70SJohn Marino Return non-zero if OP1 < OP2 or OP1 > OP2 (i.e., neither OP1, nor 15014a238c70SJohn Marino OP2 is NaN, and OP1 <> OP2), zero otherwise (i.e., OP1 and/or OP2 15024a238c70SJohn Marino is NaN, or OP1 = OP2). 15034a238c70SJohn Marino 15044a238c70SJohn Marino -- Function: int mpfr_unordered_p (mpfr_t OP1, mpfr_t OP2) 15054a238c70SJohn Marino Return non-zero if OP1 or OP2 is a NaN (i.e., they cannot be 15064a238c70SJohn Marino compared), zero otherwise. 15074a238c70SJohn Marino 15084a238c70SJohn Marino 15094a238c70SJohn MarinoFile: mpfr.info, Node: Special Functions, Next: Input and Output Functions, Prev: Comparison Functions, Up: MPFR Interface 15104a238c70SJohn Marino 15114a238c70SJohn Marino5.7 Special Functions 15124a238c70SJohn Marino===================== 15134a238c70SJohn Marino 15144a238c70SJohn MarinoAll those functions, except explicitly stated (for example 15154a238c70SJohn Marino`mpfr_sin_cos'), return a *note ternary value::, i.e., zero for an 15164a238c70SJohn Marinoexact return value, a positive value for a return value larger than the 15174a238c70SJohn Marinoexact result, and a negative value otherwise. 15184a238c70SJohn Marino 15194a238c70SJohn Marino Important note: in some domains, computing special functions (either 15204a238c70SJohn Marinowith correct or incorrect rounding) is expensive, even for small 15214a238c70SJohn Marinoprecision, for example the trigonometric and Bessel functions for large 15224a238c70SJohn Marinoargument. 15234a238c70SJohn Marino 15244a238c70SJohn Marino -- Function: int mpfr_log (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 15254a238c70SJohn Marino -- Function: int mpfr_log2 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 15264a238c70SJohn Marino -- Function: int mpfr_log10 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 15274a238c70SJohn Marino Set ROP to the natural logarithm of OP, log2(OP) or log10(OP), 15284a238c70SJohn Marino respectively, rounded in the direction RND. Set ROP to -Inf if OP 15294a238c70SJohn Marino is -0 (i.e., the sign of the zero has no influence on the result). 15304a238c70SJohn Marino 15314a238c70SJohn Marino -- Function: int mpfr_exp (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 15324a238c70SJohn Marino -- Function: int mpfr_exp2 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 15334a238c70SJohn Marino -- Function: int mpfr_exp10 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 15344a238c70SJohn Marino Set ROP to the exponential of OP, to 2 power of OP or to 10 power 15354a238c70SJohn Marino of OP, respectively, rounded in the direction RND. 15364a238c70SJohn Marino 15374a238c70SJohn Marino -- Function: int mpfr_cos (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 15384a238c70SJohn Marino -- Function: int mpfr_sin (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 15394a238c70SJohn Marino -- Function: int mpfr_tan (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 15404a238c70SJohn Marino Set ROP to the cosine of OP, sine of OP, tangent of OP, rounded in 15414a238c70SJohn Marino the direction RND. 15424a238c70SJohn Marino 15434a238c70SJohn Marino -- Function: int mpfr_sin_cos (mpfr_t SOP, mpfr_t COP, mpfr_t OP, 15444a238c70SJohn Marino mpfr_rnd_t RND) 15454a238c70SJohn Marino Set simultaneously SOP to the sine of OP and COP to the cosine of 15464a238c70SJohn Marino OP, rounded in the direction RND with the corresponding precisions 15474a238c70SJohn Marino of SOP and COP, which must be different variables. Return 0 iff 15484a238c70SJohn Marino both results are exact, more precisely it returns s+4c where s=0 15494a238c70SJohn Marino if SOP is exact, s=1 if SOP is larger than the sine of OP, s=2 if 15504a238c70SJohn Marino SOP is smaller than the sine of OP, and similarly for c and the 15514a238c70SJohn Marino cosine of OP. 15524a238c70SJohn Marino 15534a238c70SJohn Marino -- Function: int mpfr_sec (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 15544a238c70SJohn Marino -- Function: int mpfr_csc (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 15554a238c70SJohn Marino -- Function: int mpfr_cot (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 15564a238c70SJohn Marino Set ROP to the secant of OP, cosecant of OP, cotangent of OP, 15574a238c70SJohn Marino rounded in the direction RND. 15584a238c70SJohn Marino 15594a238c70SJohn Marino -- Function: int mpfr_acos (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 15604a238c70SJohn Marino -- Function: int mpfr_asin (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 15614a238c70SJohn Marino -- Function: int mpfr_atan (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 15624a238c70SJohn Marino Set ROP to the arc-cosine, arc-sine or arc-tangent of OP, rounded 15634a238c70SJohn Marino in the direction RND. Note that since `acos(-1)' returns the 15644a238c70SJohn Marino floating-point number closest to Pi according to the given 15654a238c70SJohn Marino rounding mode, this number might not be in the output range 0 <= 15664a238c70SJohn Marino ROP < \pi of the arc-cosine function; still, the result lies in 15674a238c70SJohn Marino the image of the output range by the rounding function. The same 15684a238c70SJohn Marino holds for `asin(-1)', `asin(1)', `atan(-Inf)', `atan(+Inf)' or for 15694a238c70SJohn Marino `atan(op)' with large OP and small precision of ROP. 15704a238c70SJohn Marino 15714a238c70SJohn Marino -- Function: int mpfr_atan2 (mpfr_t ROP, mpfr_t Y, mpfr_t X, 15724a238c70SJohn Marino mpfr_rnd_t RND) 15734a238c70SJohn Marino Set ROP to the arc-tangent2 of Y and X, rounded in the direction 15744a238c70SJohn Marino RND: if `x > 0', `atan2(y, x) = atan (y/x)'; if `x < 0', `atan2(y, 15754a238c70SJohn Marino x) = sign(y)*(Pi - atan (abs(y/x)))', thus a number from -Pi to Pi. 15764a238c70SJohn Marino As for `atan', in case the exact mathematical result is +Pi or -Pi, 15774a238c70SJohn Marino its rounded result might be outside the function output range. 15784a238c70SJohn Marino 15794a238c70SJohn Marino `atan2(y, 0)' does not raise any floating-point exception. 15804a238c70SJohn Marino Special values are handled as described in the ISO C99 and IEEE 15814a238c70SJohn Marino 754-2008 standards for the `atan2' function: 15824a238c70SJohn Marino * `atan2(+0, -0)' returns +Pi. 15834a238c70SJohn Marino 15844a238c70SJohn Marino * `atan2(-0, -0)' returns -Pi. 15854a238c70SJohn Marino 15864a238c70SJohn Marino * `atan2(+0, +0)' returns +0. 15874a238c70SJohn Marino 15884a238c70SJohn Marino * `atan2(-0, +0)' returns -0. 15894a238c70SJohn Marino 15904a238c70SJohn Marino * `atan2(+0, x)' returns +Pi for x < 0. 15914a238c70SJohn Marino 15924a238c70SJohn Marino * `atan2(-0, x)' returns -Pi for x < 0. 15934a238c70SJohn Marino 15944a238c70SJohn Marino * `atan2(+0, x)' returns +0 for x > 0. 15954a238c70SJohn Marino 15964a238c70SJohn Marino * `atan2(-0, x)' returns -0 for x > 0. 15974a238c70SJohn Marino 15984a238c70SJohn Marino * `atan2(y, 0)' returns -Pi/2 for y < 0. 15994a238c70SJohn Marino 16004a238c70SJohn Marino * `atan2(y, 0)' returns +Pi/2 for y > 0. 16014a238c70SJohn Marino 16024a238c70SJohn Marino * `atan2(+Inf, -Inf)' returns +3*Pi/4. 16034a238c70SJohn Marino 16044a238c70SJohn Marino * `atan2(-Inf, -Inf)' returns -3*Pi/4. 16054a238c70SJohn Marino 16064a238c70SJohn Marino * `atan2(+Inf, +Inf)' returns +Pi/4. 16074a238c70SJohn Marino 16084a238c70SJohn Marino * `atan2(-Inf, +Inf)' returns -Pi/4. 16094a238c70SJohn Marino 16104a238c70SJohn Marino * `atan2(+Inf, x)' returns +Pi/2 for finite x. 16114a238c70SJohn Marino 16124a238c70SJohn Marino * `atan2(-Inf, x)' returns -Pi/2 for finite x. 16134a238c70SJohn Marino 16144a238c70SJohn Marino * `atan2(y, -Inf)' returns +Pi for finite y > 0. 16154a238c70SJohn Marino 16164a238c70SJohn Marino * `atan2(y, -Inf)' returns -Pi for finite y < 0. 16174a238c70SJohn Marino 16184a238c70SJohn Marino * `atan2(y, +Inf)' returns +0 for finite y > 0. 16194a238c70SJohn Marino 16204a238c70SJohn Marino * `atan2(y, +Inf)' returns -0 for finite y < 0. 16214a238c70SJohn Marino 16224a238c70SJohn Marino -- Function: int mpfr_cosh (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 16234a238c70SJohn Marino -- Function: int mpfr_sinh (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 16244a238c70SJohn Marino -- Function: int mpfr_tanh (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 16254a238c70SJohn Marino Set ROP to the hyperbolic cosine, sine or tangent of OP, rounded 16264a238c70SJohn Marino in the direction RND. 16274a238c70SJohn Marino 16284a238c70SJohn Marino -- Function: int mpfr_sinh_cosh (mpfr_t SOP, mpfr_t COP, mpfr_t OP, 16294a238c70SJohn Marino mpfr_rnd_t RND) 16304a238c70SJohn Marino Set simultaneously SOP to the hyperbolic sine of OP and COP to the 16314a238c70SJohn Marino hyperbolic cosine of OP, rounded in the direction RND with the 16324a238c70SJohn Marino corresponding precision of SOP and COP, which must be different 16334a238c70SJohn Marino variables. Return 0 iff both results are exact (see 16344a238c70SJohn Marino `mpfr_sin_cos' for a more detailed description of the return 16354a238c70SJohn Marino value). 16364a238c70SJohn Marino 16374a238c70SJohn Marino -- Function: int mpfr_sech (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 16384a238c70SJohn Marino -- Function: int mpfr_csch (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 16394a238c70SJohn Marino -- Function: int mpfr_coth (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 16404a238c70SJohn Marino Set ROP to the hyperbolic secant of OP, cosecant of OP, cotangent 16414a238c70SJohn Marino of OP, rounded in the direction RND. 16424a238c70SJohn Marino 16434a238c70SJohn Marino -- Function: int mpfr_acosh (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 16444a238c70SJohn Marino -- Function: int mpfr_asinh (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 16454a238c70SJohn Marino -- Function: int mpfr_atanh (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 16464a238c70SJohn Marino Set ROP to the inverse hyperbolic cosine, sine or tangent of OP, 16474a238c70SJohn Marino rounded in the direction RND. 16484a238c70SJohn Marino 16494a238c70SJohn Marino -- Function: int mpfr_fac_ui (mpfr_t ROP, unsigned long int OP, 16504a238c70SJohn Marino mpfr_rnd_t RND) 16514a238c70SJohn Marino Set ROP to the factorial of OP, rounded in the direction RND. 16524a238c70SJohn Marino 16534a238c70SJohn Marino -- Function: int mpfr_log1p (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 16544a238c70SJohn Marino Set ROP to the logarithm of one plus OP, rounded in the direction 16554a238c70SJohn Marino RND. 16564a238c70SJohn Marino 16574a238c70SJohn Marino -- Function: int mpfr_expm1 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 16584a238c70SJohn Marino Set ROP to the exponential of OP followed by a subtraction by one, 16594a238c70SJohn Marino rounded in the direction RND. 16604a238c70SJohn Marino 16614a238c70SJohn Marino -- Function: int mpfr_eint (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 16624a238c70SJohn Marino Set ROP to the exponential integral of OP, rounded in the 16634a238c70SJohn Marino direction RND. For positive OP, the exponential integral is the 16644a238c70SJohn Marino sum of Euler's constant, of the logarithm of OP, and of the sum 16654a238c70SJohn Marino for k from 1 to infinity of OP to the power k, divided by k and 16664a238c70SJohn Marino factorial(k). For negative OP, ROP is set to NaN (this definition 16674a238c70SJohn Marino for negative argument follows formula 5.1.2 from the Handbook of 16684a238c70SJohn Marino Mathematical Functions from Abramowitz and Stegun, a future 16694a238c70SJohn Marino version might use another definition). 16704a238c70SJohn Marino 16714a238c70SJohn Marino -- Function: int mpfr_li2 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 16724a238c70SJohn Marino Set ROP to real part of the dilogarithm of OP, rounded in the 16734a238c70SJohn Marino direction RND. MPFR defines the dilogarithm function as the 16744a238c70SJohn Marino integral of -log(1-t)/t from 0 to OP. 16754a238c70SJohn Marino 16764a238c70SJohn Marino -- Function: int mpfr_gamma (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 16774a238c70SJohn Marino Set ROP to the value of the Gamma function on OP, rounded in the 16784a238c70SJohn Marino direction RND. When OP is a negative integer, ROP is set to NaN. 16794a238c70SJohn Marino 16804a238c70SJohn Marino -- Function: int mpfr_lngamma (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 16814a238c70SJohn Marino Set ROP to the value of the logarithm of the Gamma function on OP, 16824a238c70SJohn Marino rounded in the direction RND. When -2K-1 <= OP <= -2K, K being a 16834a238c70SJohn Marino non-negative integer, ROP is set to NaN. See also `mpfr_lgamma'. 16844a238c70SJohn Marino 16854a238c70SJohn Marino -- Function: int mpfr_lgamma (mpfr_t ROP, int *SIGNP, mpfr_t OP, 16864a238c70SJohn Marino mpfr_rnd_t RND) 16874a238c70SJohn Marino Set ROP to the value of the logarithm of the absolute value of the 16884a238c70SJohn Marino Gamma function on OP, rounded in the direction RND. The sign (1 or 16894a238c70SJohn Marino -1) of Gamma(OP) is returned in the object pointed to by SIGNP. 16904a238c70SJohn Marino When OP is an infinity or a non-positive integer, set ROP to +Inf. 16914a238c70SJohn Marino When OP is NaN, -Inf or a negative integer, *SIGNP is undefined, 16924a238c70SJohn Marino and when OP is ±0, *SIGNP is the sign of the zero. 16934a238c70SJohn Marino 16944a238c70SJohn Marino -- Function: int mpfr_digamma (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 16954a238c70SJohn Marino Set ROP to the value of the Digamma (sometimes also called Psi) 16964a238c70SJohn Marino function on OP, rounded in the direction RND. When OP is a 16974a238c70SJohn Marino negative integer, set ROP to NaN. 16984a238c70SJohn Marino 16994a238c70SJohn Marino -- Function: int mpfr_zeta (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 17004a238c70SJohn Marino -- Function: int mpfr_zeta_ui (mpfr_t ROP, unsigned long OP, 17014a238c70SJohn Marino mpfr_rnd_t RND) 17024a238c70SJohn Marino Set ROP to the value of the Riemann Zeta function on OP, rounded 17034a238c70SJohn Marino in the direction RND. 17044a238c70SJohn Marino 17054a238c70SJohn Marino -- Function: int mpfr_erf (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 17064a238c70SJohn Marino -- Function: int mpfr_erfc (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 17074a238c70SJohn Marino Set ROP to the value of the error function on OP (resp. the 17084a238c70SJohn Marino complementary error function on OP) rounded in the direction RND. 17094a238c70SJohn Marino 17104a238c70SJohn Marino -- Function: int mpfr_j0 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 17114a238c70SJohn Marino -- Function: int mpfr_j1 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 17124a238c70SJohn Marino -- Function: int mpfr_jn (mpfr_t ROP, long N, mpfr_t OP, mpfr_rnd_t 17134a238c70SJohn Marino RND) 17144a238c70SJohn Marino Set ROP to the value of the first kind Bessel function of order 0, 17154a238c70SJohn Marino (resp. 1 and N) on OP, rounded in the direction RND. When OP is 17164a238c70SJohn Marino NaN, ROP is always set to NaN. When OP is plus or minus Infinity, 17174a238c70SJohn Marino ROP is set to +0. When OP is zero, and N is not zero, ROP is set 17184a238c70SJohn Marino to +0 or -0 depending on the parity and sign of N, and the sign of 17194a238c70SJohn Marino OP. 17204a238c70SJohn Marino 17214a238c70SJohn Marino -- Function: int mpfr_y0 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 17224a238c70SJohn Marino -- Function: int mpfr_y1 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 17234a238c70SJohn Marino -- Function: int mpfr_yn (mpfr_t ROP, long N, mpfr_t OP, mpfr_rnd_t 17244a238c70SJohn Marino RND) 17254a238c70SJohn Marino Set ROP to the value of the second kind Bessel function of order 0 17264a238c70SJohn Marino (resp. 1 and N) on OP, rounded in the direction RND. When OP is 17274a238c70SJohn Marino NaN or negative, ROP is always set to NaN. When OP is +Inf, ROP is 17284a238c70SJohn Marino set to +0. When OP is zero, ROP is set to +Inf or -Inf depending 17294a238c70SJohn Marino on the parity and sign of N. 17304a238c70SJohn Marino 17314a238c70SJohn Marino -- Function: int mpfr_fma (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, mpfr_t 17324a238c70SJohn Marino OP3, mpfr_rnd_t RND) 17334a238c70SJohn Marino -- Function: int mpfr_fms (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, mpfr_t 17344a238c70SJohn Marino OP3, mpfr_rnd_t RND) 17354a238c70SJohn Marino Set ROP to (OP1 times OP2) + OP3 (resp. (OP1 times OP2) - OP3) 17364a238c70SJohn Marino rounded in the direction RND. 17374a238c70SJohn Marino 17384a238c70SJohn Marino -- Function: int mpfr_agm (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, 17394a238c70SJohn Marino mpfr_rnd_t RND) 17404a238c70SJohn Marino Set ROP to the arithmetic-geometric mean of OP1 and OP2, rounded 17414a238c70SJohn Marino in the direction RND. The arithmetic-geometric mean is the common 17424a238c70SJohn Marino limit of the sequences U_N and V_N, where U_0=OP1, V_0=OP2, 17434a238c70SJohn Marino U_(N+1) is the arithmetic mean of U_N and V_N, and V_(N+1) is the 17444a238c70SJohn Marino geometric mean of U_N and V_N. If any operand is negative, set 17454a238c70SJohn Marino ROP to NaN. 17464a238c70SJohn Marino 17474a238c70SJohn Marino -- Function: int mpfr_hypot (mpfr_t ROP, mpfr_t X, mpfr_t Y, 17484a238c70SJohn Marino mpfr_rnd_t RND) 17494a238c70SJohn Marino Set ROP to the Euclidean norm of X and Y, i.e., the square root of 17504a238c70SJohn Marino the sum of the squares of X and Y, rounded in the direction RND. 17514a238c70SJohn Marino Special values are handled as described in Section F.9.4.3 of the 17524a238c70SJohn Marino ISO C99 and IEEE 754-2008 standards: If X or Y is an infinity, 17534a238c70SJohn Marino then +Inf is returned in ROP, even if the other number is NaN. 17544a238c70SJohn Marino 17554a238c70SJohn Marino -- Function: int mpfr_ai (mpfr_t ROP, mpfr_t X, mpfr_rnd_t RND) 17564a238c70SJohn Marino Set ROP to the value of the Airy function Ai on X, rounded in the 17574a238c70SJohn Marino direction RND. When X is NaN, ROP is always set to NaN. When X is 17584a238c70SJohn Marino +Inf or -Inf, ROP is +0. The current implementation is not 17594a238c70SJohn Marino intended to be used with large arguments. It works with abs(X) 17604a238c70SJohn Marino typically smaller than 500. For larger arguments, other methods 17614a238c70SJohn Marino should be used and will be implemented in a future version. 17624a238c70SJohn Marino 17634a238c70SJohn Marino -- Function: int mpfr_const_log2 (mpfr_t ROP, mpfr_rnd_t RND) 17644a238c70SJohn Marino -- Function: int mpfr_const_pi (mpfr_t ROP, mpfr_rnd_t RND) 17654a238c70SJohn Marino -- Function: int mpfr_const_euler (mpfr_t ROP, mpfr_rnd_t RND) 17664a238c70SJohn Marino -- Function: int mpfr_const_catalan (mpfr_t ROP, mpfr_rnd_t RND) 17674a238c70SJohn Marino Set ROP to the logarithm of 2, the value of Pi, of Euler's 17684a238c70SJohn Marino constant 0.577..., of Catalan's constant 0.915..., respectively, 17694a238c70SJohn Marino rounded in the direction RND. These functions cache the computed 17704a238c70SJohn Marino values to avoid other calculations if a lower or equal precision 17714a238c70SJohn Marino is requested. To free these caches, use `mpfr_free_cache'. 17724a238c70SJohn Marino 17734a238c70SJohn Marino -- Function: void mpfr_free_cache (void) 17744a238c70SJohn Marino Free various caches used by MPFR internally, in particular the 17754a238c70SJohn Marino caches used by the functions computing constants 17764a238c70SJohn Marino (`mpfr_const_log2', `mpfr_const_pi', `mpfr_const_euler' and 17774a238c70SJohn Marino `mpfr_const_catalan'). You should call this function before 17784a238c70SJohn Marino terminating a thread, even if you did not call these functions 17794a238c70SJohn Marino directly (they could have been called internally). 17804a238c70SJohn Marino 17814a238c70SJohn Marino -- Function: int mpfr_sum (mpfr_t ROP, mpfr_ptr const TAB[], unsigned 17824a238c70SJohn Marino long int N, mpfr_rnd_t RND) 17834a238c70SJohn Marino Set ROP to the sum of all elements of TAB, whose size is N, 17844a238c70SJohn Marino rounded in the direction RND. Warning: for efficiency reasons, TAB 17854a238c70SJohn Marino is an array of pointers to `mpfr_t', not an array of `mpfr_t'. If 17864a238c70SJohn Marino the returned `int' value is zero, ROP is guaranteed to be the 17874a238c70SJohn Marino exact sum; otherwise ROP might be smaller than, equal to, or 17884a238c70SJohn Marino larger than the exact sum (in accordance to the rounding mode). 17894a238c70SJohn Marino However, `mpfr_sum' does guarantee the result is correctly rounded. 17904a238c70SJohn Marino 17914a238c70SJohn Marino 17924a238c70SJohn MarinoFile: mpfr.info, Node: Input and Output Functions, Next: Formatted Output Functions, Prev: Special Functions, Up: MPFR Interface 17934a238c70SJohn Marino 17944a238c70SJohn Marino5.8 Input and Output Functions 17954a238c70SJohn Marino============================== 17964a238c70SJohn Marino 17974a238c70SJohn MarinoThis section describes functions that perform input from an input/output 17984a238c70SJohn Marinostream, and functions that output to an input/output stream. Passing a 17994a238c70SJohn Marinonull pointer for a `stream' to any of these functions will make them 18004a238c70SJohn Marinoread from `stdin' and write to `stdout', respectively. 18014a238c70SJohn Marino 18024a238c70SJohn Marino When using any of these functions, you must include the `<stdio.h>' 18034a238c70SJohn Marinostandard header before `mpfr.h', to allow `mpfr.h' to define prototypes 18044a238c70SJohn Marinofor these functions. 18054a238c70SJohn Marino 18064a238c70SJohn Marino -- Function: size_t mpfr_out_str (FILE *STREAM, int BASE, size_t N, 18074a238c70SJohn Marino mpfr_t OP, mpfr_rnd_t RND) 18084a238c70SJohn Marino Output OP on stream STREAM, as a string of digits in base BASE, 18094a238c70SJohn Marino rounded in the direction RND. The base may vary from 2 to 62. 18104a238c70SJohn Marino Print N significant digits exactly, or if N is 0, enough digits so 18114a238c70SJohn Marino that OP can be read back exactly (see `mpfr_get_str'). 18124a238c70SJohn Marino 18134a238c70SJohn Marino In addition to the significant digits, a decimal point (defined by 18144a238c70SJohn Marino the current locale) at the right of the first digit and a trailing 18154a238c70SJohn Marino exponent in base 10, in the form `eNNN', are printed. If BASE is 18164a238c70SJohn Marino greater than 10, `@' will be used instead of `e' as exponent 18174a238c70SJohn Marino delimiter. 18184a238c70SJohn Marino 18194a238c70SJohn Marino Return the number of characters written, or if an error occurred, 18204a238c70SJohn Marino return 0. 18214a238c70SJohn Marino 18224a238c70SJohn Marino -- Function: size_t mpfr_inp_str (mpfr_t ROP, FILE *STREAM, int BASE, 18234a238c70SJohn Marino mpfr_rnd_t RND) 18244a238c70SJohn Marino Input a string in base BASE from stream STREAM, rounded in the 18254a238c70SJohn Marino direction RND, and put the read float in ROP. 18264a238c70SJohn Marino 18274a238c70SJohn Marino This function reads a word (defined as a sequence of characters 18284a238c70SJohn Marino between whitespace) and parses it using `mpfr_set_str'. See the 18294a238c70SJohn Marino documentation of `mpfr_strtofr' for a detailed description of the 18304a238c70SJohn Marino valid string formats. 18314a238c70SJohn Marino 18324a238c70SJohn Marino Return the number of bytes read, or if an error occurred, return 0. 18334a238c70SJohn Marino 18344a238c70SJohn Marino 18354a238c70SJohn MarinoFile: mpfr.info, Node: Formatted Output Functions, Next: Integer Related Functions, Prev: Input and Output Functions, Up: MPFR Interface 18364a238c70SJohn Marino 18374a238c70SJohn Marino5.9 Formatted Output Functions 18384a238c70SJohn Marino============================== 18394a238c70SJohn Marino 18404a238c70SJohn Marino5.9.1 Requirements 18414a238c70SJohn Marino------------------ 18424a238c70SJohn Marino 18434a238c70SJohn MarinoThe class of `mpfr_printf' functions provides formatted output in a 18444a238c70SJohn Marinosimilar manner as the standard C `printf'. These functions are defined 18454a238c70SJohn Marinoonly if your system supports ISO C variadic functions and the 18464a238c70SJohn Marinocorresponding argument access macros. 18474a238c70SJohn Marino 18484a238c70SJohn Marino When using any of these functions, you must include the `<stdio.h>' 18494a238c70SJohn Marinostandard header before `mpfr.h', to allow `mpfr.h' to define prototypes 18504a238c70SJohn Marinofor these functions. 18514a238c70SJohn Marino 18524a238c70SJohn Marino5.9.2 Format String 18534a238c70SJohn Marino------------------- 18544a238c70SJohn Marino 18554a238c70SJohn MarinoThe format specification accepted by `mpfr_printf' is an extension of 18564a238c70SJohn Marinothe `printf' one. The conversion specification is of the form: 18574a238c70SJohn Marino % [flags] [width] [.[precision]] [type] [rounding] conv 18584a238c70SJohn Marino `flags', `width', and `precision' have the same meaning as for the 18594a238c70SJohn Marinostandard `printf' (in particular, notice that the `precision' is 18604a238c70SJohn Marinorelated to the number of digits displayed in the base chosen by `conv' 18614a238c70SJohn Marinoand not related to the internal precision of the `mpfr_t' variable). 18624a238c70SJohn Marino`mpfr_printf' accepts the same `type' specifiers as GMP (except the 18634a238c70SJohn Marinonon-standard and deprecated `q', use `ll' instead), namely the length 18644a238c70SJohn Marinomodifiers defined in the C standard: 18654a238c70SJohn Marino 18664a238c70SJohn Marino `h' `short' 18674a238c70SJohn Marino `hh' `char' 18684a238c70SJohn Marino `j' `intmax_t' or `uintmax_t' 18694a238c70SJohn Marino `l' `long' or `wchar_t' 18704a238c70SJohn Marino `ll' `long long' 18714a238c70SJohn Marino `L' `long double' 18724a238c70SJohn Marino `t' `ptrdiff_t' 18734a238c70SJohn Marino `z' `size_t' 18744a238c70SJohn Marino 18754a238c70SJohn Marino and the `type' specifiers defined in GMP plus `R' and `P' specific 18764a238c70SJohn Marinoto MPFR (the second column in the table below shows the type of the 18774a238c70SJohn Marinoargument read in the argument list and the kind of `conv' specifier to 18784a238c70SJohn Marinouse after the `type' specifier): 18794a238c70SJohn Marino 18804a238c70SJohn Marino `F' `mpf_t', float conversions 18814a238c70SJohn Marino `Q' `mpq_t', integer conversions 18824a238c70SJohn Marino `M' `mp_limb_t', integer conversions 18834a238c70SJohn Marino `N' `mp_limb_t' array, integer conversions 18844a238c70SJohn Marino `Z' `mpz_t', integer conversions 18854a238c70SJohn Marino `P' `mpfr_prec_t', integer conversions 18864a238c70SJohn Marino `R' `mpfr_t', float conversions 18874a238c70SJohn Marino 18884a238c70SJohn Marino The `type' specifiers have the same restrictions as those mentioned 18894a238c70SJohn Marinoin the GMP documentation: *note Formatted Output Strings: 18904a238c70SJohn Marino(gmp.info)Formatted Output Strings. In particular, the `type' 18914a238c70SJohn Marinospecifiers (except `R' and `P') are supported only if they are 18924a238c70SJohn Marinosupported by `gmp_printf' in your GMP build; this implies that the 18934a238c70SJohn Marinostandard specifiers, such as `t', must _also_ be supported by your C 18944a238c70SJohn Marinolibrary if you want to use them. 18954a238c70SJohn Marino 18964a238c70SJohn Marino The `rounding' field is specific to `mpfr_t' arguments and should 18974a238c70SJohn Marinonot be used with other types. 18984a238c70SJohn Marino 18994a238c70SJohn Marino With conversion specification not involving `P' and `R' types, 19004a238c70SJohn Marino`mpfr_printf' behaves exactly as `gmp_printf'. 19014a238c70SJohn Marino 19024a238c70SJohn Marino The `P' type specifies that a following `o', `u', `x', or `X' 19034a238c70SJohn Marinoconversion specifier applies to a `mpfr_prec_t' argument. It is needed 19044a238c70SJohn Marinobecause the `mpfr_prec_t' type does not necessarily correspond to an 19054a238c70SJohn Marino`unsigned int' or any fixed standard type. The `precision' field 19064a238c70SJohn Marinospecifies the minimum number of digits to appear. The default 19074a238c70SJohn Marino`precision' is 1. For example: 19084a238c70SJohn Marino mpfr_t x; 19094a238c70SJohn Marino mpfr_prec_t p; 19104a238c70SJohn Marino mpfr_init (x); 19114a238c70SJohn Marino ... 19124a238c70SJohn Marino p = mpfr_get_prec (x); 19134a238c70SJohn Marino mpfr_printf ("variable x with %Pu bits", p); 19144a238c70SJohn Marino 19154a238c70SJohn Marino The `R' type specifies that a following `a', `A', `b', `e', `E', 19164a238c70SJohn Marino`f', `F', `g', `G', or `n' conversion specifier applies to a `mpfr_t' 19174a238c70SJohn Marinoargument. The `R' type can be followed by a `rounding' specifier 19184a238c70SJohn Marinodenoted by one of the following characters: 19194a238c70SJohn Marino 19204a238c70SJohn Marino `U' round toward plus infinity 19214a238c70SJohn Marino `D' round toward minus infinity 19224a238c70SJohn Marino `Y' round away from zero 19234a238c70SJohn Marino `Z' round toward zero 19244a238c70SJohn Marino `N' round to nearest (with ties to even) 19254a238c70SJohn Marino `*' rounding mode indicated by the 19264a238c70SJohn Marino `mpfr_rnd_t' argument just before the 19274a238c70SJohn Marino corresponding `mpfr_t' variable. 19284a238c70SJohn Marino 19294a238c70SJohn Marino The default rounding mode is rounding to nearest. The following 19304a238c70SJohn Marinothree examples are equivalent: 19314a238c70SJohn Marino mpfr_t x; 19324a238c70SJohn Marino mpfr_init (x); 19334a238c70SJohn Marino ... 19344a238c70SJohn Marino mpfr_printf ("%.128Rf", x); 19354a238c70SJohn Marino mpfr_printf ("%.128RNf", x); 19364a238c70SJohn Marino mpfr_printf ("%.128R*f", MPFR_RNDN, x); 19374a238c70SJohn Marino 19384a238c70SJohn Marino Note that the rounding away from zero mode is specified with `Y' 19394a238c70SJohn Marinobecause ISO C reserves the `A' specifier for hexadecimal output (see 19404a238c70SJohn Marinobelow). 19414a238c70SJohn Marino 19424a238c70SJohn Marino The output `conv' specifiers allowed with `mpfr_t' parameter are: 19434a238c70SJohn Marino 19444a238c70SJohn Marino `a' `A' hex float, C99 style 19454a238c70SJohn Marino `b' binary output 19464a238c70SJohn Marino `e' `E' scientific format float 19474a238c70SJohn Marino `f' `F' fixed point float 19484a238c70SJohn Marino `g' `G' fixed or scientific float 19494a238c70SJohn Marino 19504a238c70SJohn Marino The conversion specifier `b' which displays the argument in binary is 19514a238c70SJohn Marinospecific to `mpfr_t' arguments and should not be used with other types. 19524a238c70SJohn MarinoOther conversion specifiers have the same meaning as for a `double' 19534a238c70SJohn Marinoargument. 19544a238c70SJohn Marino 19554a238c70SJohn Marino In case of non-decimal output, only the significand is written in the 19564a238c70SJohn Marinospecified base, the exponent is always displayed in decimal. Special 19574a238c70SJohn Marinovalues are always displayed as `nan', `-inf', and `inf' for `a', `b', 19584a238c70SJohn Marino`e', `f', and `g' specifiers and `NAN', `-INF', and `INF' for `A', `E', 19594a238c70SJohn Marino`F', and `G' specifiers. 19604a238c70SJohn Marino 19614a238c70SJohn Marino If the `precision' field is not empty, the `mpfr_t' number is 19624a238c70SJohn Marinorounded to the given precision in the direction specified by the 19634a238c70SJohn Marinorounding mode. If the precision is zero with rounding to nearest mode 19644a238c70SJohn Marinoand one of the following `conv' specifiers: `a', `A', `b', `e', `E', 19654a238c70SJohn Marinotie case is rounded to even when it lies between two consecutive values 19664a238c70SJohn Marinoat the wanted precision which have the same exponent, otherwise, it is 19674a238c70SJohn Marinorounded away from zero. For instance, 85 is displayed as "8e+1" and 95 19684a238c70SJohn Marinois displayed as "1e+2" with the format specification `"%.0RNe"'. This 19694a238c70SJohn Marinoalso applies when the `g' (resp. `G') conversion specifier uses the `e' 19704a238c70SJohn Marino(resp. `E') style. If the precision is set to a value greater than the 19714a238c70SJohn Marinomaximum value for an `int', it will be silently reduced down to 19724a238c70SJohn Marino`INT_MAX'. 19734a238c70SJohn Marino 19744a238c70SJohn Marino If the `precision' field is empty (as in `%Re' or `%.RE') with 19754a238c70SJohn Marino`conv' specifier `e' and `E', the number is displayed with enough 19764a238c70SJohn Marinodigits so that it can be read back exactly, assuming that the input and 19774a238c70SJohn Marinooutput variables have the same precision and that the input and output 19784a238c70SJohn Marinorounding modes are both rounding to nearest (as for `mpfr_get_str'). 19794a238c70SJohn MarinoThe default precision for an empty `precision' field with `conv' 19804a238c70SJohn Marinospecifiers `f', `F', `g', and `G' is 6. 19814a238c70SJohn Marino 19824a238c70SJohn Marino5.9.3 Functions 19834a238c70SJohn Marino--------------- 19844a238c70SJohn Marino 19854a238c70SJohn MarinoFor all the following functions, if the number of characters which 19864a238c70SJohn Marinoought to be written appears to exceed the maximum limit for an `int', 19874a238c70SJohn Marinonothing is written in the stream (resp. to `stdout', to BUF, to STR), 19884a238c70SJohn Marinothe function returns -1, sets the _erange_ flag, and (in POSIX system 19894a238c70SJohn Marinoonly) `errno' is set to `EOVERFLOW'. 19904a238c70SJohn Marino 19914a238c70SJohn Marino -- Function: int mpfr_fprintf (FILE *STREAM, const char *TEMPLATE, ...) 19924a238c70SJohn Marino -- Function: int mpfr_vfprintf (FILE *STREAM, const char *TEMPLATE, 19934a238c70SJohn Marino va_list AP) 19944a238c70SJohn Marino Print to the stream STREAM the optional arguments under the 19954a238c70SJohn Marino control of the template string TEMPLATE. Return the number of 19964a238c70SJohn Marino characters written or a negative value if an error occurred. 19974a238c70SJohn Marino 19984a238c70SJohn Marino -- Function: int mpfr_printf (const char *TEMPLATE, ...) 19994a238c70SJohn Marino -- Function: int mpfr_vprintf (const char *TEMPLATE, va_list AP) 20004a238c70SJohn Marino Print to `stdout' the optional arguments under the control of the 20014a238c70SJohn Marino template string TEMPLATE. Return the number of characters written 20024a238c70SJohn Marino or a negative value if an error occurred. 20034a238c70SJohn Marino 20044a238c70SJohn Marino -- Function: int mpfr_sprintf (char *BUF, const char *TEMPLATE, ...) 20054a238c70SJohn Marino -- Function: int mpfr_vsprintf (char *BUF, const char *TEMPLATE, 20064a238c70SJohn Marino va_list AP) 20074a238c70SJohn Marino Form a null-terminated string corresponding to the optional 20084a238c70SJohn Marino arguments under the control of the template string TEMPLATE, and 20094a238c70SJohn Marino print it in BUF. No overlap is permitted between BUF and the other 20104a238c70SJohn Marino arguments. Return the number of characters written in the array 20114a238c70SJohn Marino BUF _not counting_ the terminating null character or a negative 20124a238c70SJohn Marino value if an error occurred. 20134a238c70SJohn Marino 20144a238c70SJohn Marino -- Function: int mpfr_snprintf (char *BUF, size_t N, const char 20154a238c70SJohn Marino *TEMPLATE, ...) 20164a238c70SJohn Marino -- Function: int mpfr_vsnprintf (char *BUF, size_t N, const char 20174a238c70SJohn Marino *TEMPLATE, va_list AP) 20184a238c70SJohn Marino Form a null-terminated string corresponding to the optional 20194a238c70SJohn Marino arguments under the control of the template string TEMPLATE, and 20204a238c70SJohn Marino print it in BUF. If N is zero, nothing is written and BUF may be a 20214a238c70SJohn Marino null pointer, otherwise, the N-1 first characters are written in 20224a238c70SJohn Marino BUF and the N-th is a null character. Return the number of 20234a238c70SJohn Marino characters that would have been written had N be sufficiently 20244a238c70SJohn Marino large, _not counting_ the terminating null character, or a 20254a238c70SJohn Marino negative value if an error occurred. 20264a238c70SJohn Marino 20274a238c70SJohn Marino -- Function: int mpfr_asprintf (char **STR, const char *TEMPLATE, ...) 20284a238c70SJohn Marino -- Function: int mpfr_vasprintf (char **STR, const char *TEMPLATE, 20294a238c70SJohn Marino va_list AP) 20304a238c70SJohn Marino Write their output as a null terminated string in a block of 20314a238c70SJohn Marino memory allocated using the current allocation function. A pointer 20324a238c70SJohn Marino to the block is stored in STR. The block of memory must be freed 20334a238c70SJohn Marino using `mpfr_free_str'. The return value is the number of 20344a238c70SJohn Marino characters written in the string, excluding the null-terminator, 20354a238c70SJohn Marino or a negative value if an error occurred. 20364a238c70SJohn Marino 20374a238c70SJohn Marino 20384a238c70SJohn MarinoFile: mpfr.info, Node: Integer Related Functions, Next: Rounding Related Functions, Prev: Formatted Output Functions, Up: MPFR Interface 20394a238c70SJohn Marino 20404a238c70SJohn Marino5.10 Integer and Remainder Related Functions 20414a238c70SJohn Marino============================================ 20424a238c70SJohn Marino 20434a238c70SJohn Marino -- Function: int mpfr_rint (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 20444a238c70SJohn Marino -- Function: int mpfr_ceil (mpfr_t ROP, mpfr_t OP) 20454a238c70SJohn Marino -- Function: int mpfr_floor (mpfr_t ROP, mpfr_t OP) 20464a238c70SJohn Marino -- Function: int mpfr_round (mpfr_t ROP, mpfr_t OP) 20474a238c70SJohn Marino -- Function: int mpfr_trunc (mpfr_t ROP, mpfr_t OP) 20484a238c70SJohn Marino Set ROP to OP rounded to an integer. `mpfr_rint' rounds to the 20494a238c70SJohn Marino nearest representable integer in the given direction RND, 20504a238c70SJohn Marino `mpfr_ceil' rounds to the next higher or equal representable 20514a238c70SJohn Marino integer, `mpfr_floor' to the next lower or equal representable 20524a238c70SJohn Marino integer, `mpfr_round' to the nearest representable integer, 20534a238c70SJohn Marino rounding halfway cases away from zero (as in the roundTiesToAway 20544a238c70SJohn Marino mode of IEEE 754-2008), and `mpfr_trunc' to the next representable 20554a238c70SJohn Marino integer toward zero. 20564a238c70SJohn Marino 20574a238c70SJohn Marino The returned value is zero when the result is exact, positive when 20584a238c70SJohn Marino it is greater than the original value of OP, and negative when it 20594a238c70SJohn Marino is smaller. More precisely, the returned value is 0 when OP is an 20604a238c70SJohn Marino integer representable in ROP, 1 or -1 when OP is an integer that 20614a238c70SJohn Marino is not representable in ROP, 2 or -2 when OP is not an integer. 20624a238c70SJohn Marino 20634a238c70SJohn Marino Note that `mpfr_round' is different from `mpfr_rint' called with 20644a238c70SJohn Marino the rounding to nearest mode (where halfway cases are rounded to 20654a238c70SJohn Marino an even integer or significand). Note also that no double rounding 20664a238c70SJohn Marino is performed; for instance, 10.5 (1010.1 in binary) is rounded by 20674a238c70SJohn Marino `mpfr_rint' with rounding to nearest to 12 (1100 in binary) in 20684a238c70SJohn Marino 2-bit precision, because the two enclosing numbers representable 20694a238c70SJohn Marino on two bits are 8 and 12, and the closest is 12. (If one first 20704a238c70SJohn Marino rounded to an integer, one would round 10.5 to 10 with even 20714a238c70SJohn Marino rounding, and then 10 would be rounded to 8 again with even 20724a238c70SJohn Marino rounding.) 20734a238c70SJohn Marino 20744a238c70SJohn Marino -- Function: int mpfr_rint_ceil (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 20754a238c70SJohn Marino -- Function: int mpfr_rint_floor (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t 20764a238c70SJohn Marino RND) 20774a238c70SJohn Marino -- Function: int mpfr_rint_round (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t 20784a238c70SJohn Marino RND) 20794a238c70SJohn Marino -- Function: int mpfr_rint_trunc (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t 20804a238c70SJohn Marino RND) 20814a238c70SJohn Marino Set ROP to OP rounded to an integer. `mpfr_rint_ceil' rounds to 20824a238c70SJohn Marino the next higher or equal integer, `mpfr_rint_floor' to the next 20834a238c70SJohn Marino lower or equal integer, `mpfr_rint_round' to the nearest integer, 20844a238c70SJohn Marino rounding halfway cases away from zero, and `mpfr_rint_trunc' to 20854a238c70SJohn Marino the next integer toward zero. If the result is not representable, 20864a238c70SJohn Marino it is rounded in the direction RND. The returned value is the 20874a238c70SJohn Marino ternary value associated with the considered round-to-integer 20884a238c70SJohn Marino function (regarded in the same way as any other mathematical 20894a238c70SJohn Marino function). Contrary to `mpfr_rint', those functions do perform a 20904a238c70SJohn Marino double rounding: first OP is rounded to the nearest integer in the 20914a238c70SJohn Marino direction given by the function name, then this nearest integer 20924a238c70SJohn Marino (if not representable) is rounded in the given direction RND. For 20934a238c70SJohn Marino example, `mpfr_rint_round' with rounding to nearest and a precision 20944a238c70SJohn Marino of two bits rounds 6.5 to 7 (halfway cases away from zero), then 7 20954a238c70SJohn Marino is rounded to 8 by the round-even rule, despite the fact that 6 is 20964a238c70SJohn Marino also representable on two bits, and is closer to 6.5 than 8. 20974a238c70SJohn Marino 20984a238c70SJohn Marino -- Function: int mpfr_frac (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 20994a238c70SJohn Marino Set ROP to the fractional part of OP, having the same sign as OP, 21004a238c70SJohn Marino rounded in the direction RND (unlike in `mpfr_rint', RND affects 21014a238c70SJohn Marino only how the exact fractional part is rounded, not how the 21024a238c70SJohn Marino fractional part is generated). 21034a238c70SJohn Marino 21044a238c70SJohn Marino -- Function: int mpfr_modf (mpfr_t IOP, mpfr_t FOP, mpfr_t OP, 21054a238c70SJohn Marino mpfr_rnd_t RND) 21064a238c70SJohn Marino Set simultaneously IOP to the integral part of OP and FOP to the 21074a238c70SJohn Marino fractional part of OP, rounded in the direction RND with the 21084a238c70SJohn Marino corresponding precision of IOP and FOP (equivalent to 21094a238c70SJohn Marino `mpfr_trunc(IOP, OP, RND)' and `mpfr_frac(FOP, OP, RND)'). The 21104a238c70SJohn Marino variables IOP and FOP must be different. Return 0 iff both results 21114a238c70SJohn Marino are exact (see `mpfr_sin_cos' for a more detailed description of 21124a238c70SJohn Marino the return value). 21134a238c70SJohn Marino 21144a238c70SJohn Marino -- Function: int mpfr_fmod (mpfr_t R, mpfr_t X, mpfr_t Y, mpfr_rnd_t 21154a238c70SJohn Marino RND) 21164a238c70SJohn Marino -- Function: int mpfr_remainder (mpfr_t R, mpfr_t X, mpfr_t Y, 21174a238c70SJohn Marino mpfr_rnd_t RND) 21184a238c70SJohn Marino -- Function: int mpfr_remquo (mpfr_t R, long* Q, mpfr_t X, mpfr_t Y, 21194a238c70SJohn Marino mpfr_rnd_t RND) 21204a238c70SJohn Marino Set R to the value of X - NY, rounded according to the direction 21214a238c70SJohn Marino RND, where N is the integer quotient of X divided by Y, defined as 21224a238c70SJohn Marino follows: N is rounded toward zero for `mpfr_fmod', and to the 21234a238c70SJohn Marino nearest integer (ties rounded to even) for `mpfr_remainder' and 21244a238c70SJohn Marino `mpfr_remquo'. 21254a238c70SJohn Marino 21264a238c70SJohn Marino Special values are handled as described in Section F.9.7.1 of the 21274a238c70SJohn Marino ISO C99 standard: If X is infinite or Y is zero, R is NaN. If Y 21284a238c70SJohn Marino is infinite and X is finite, R is X rounded to the precision of R. 21294a238c70SJohn Marino If R is zero, it has the sign of X. The return value is the 21304a238c70SJohn Marino ternary value corresponding to R. 21314a238c70SJohn Marino 21324a238c70SJohn Marino Additionally, `mpfr_remquo' stores the low significant bits from 21334a238c70SJohn Marino the quotient N in *Q (more precisely the number of bits in a 21344a238c70SJohn Marino `long' minus one), with the sign of X divided by Y (except if 21354a238c70SJohn Marino those low bits are all zero, in which case zero is returned). 21364a238c70SJohn Marino Note that X may be so large in magnitude relative to Y that an 21374a238c70SJohn Marino exact representation of the quotient is not practical. The 21384a238c70SJohn Marino `mpfr_remainder' and `mpfr_remquo' functions are useful for 21394a238c70SJohn Marino additive argument reduction. 21404a238c70SJohn Marino 21414a238c70SJohn Marino -- Function: int mpfr_integer_p (mpfr_t OP) 21424a238c70SJohn Marino Return non-zero iff OP is an integer. 21434a238c70SJohn Marino 21444a238c70SJohn Marino 21454a238c70SJohn MarinoFile: mpfr.info, Node: Rounding Related Functions, Next: Miscellaneous Functions, Prev: Integer Related Functions, Up: MPFR Interface 21464a238c70SJohn Marino 21474a238c70SJohn Marino5.11 Rounding Related Functions 21484a238c70SJohn Marino=============================== 21494a238c70SJohn Marino 21504a238c70SJohn Marino -- Function: void mpfr_set_default_rounding_mode (mpfr_rnd_t RND) 21514a238c70SJohn Marino Set the default rounding mode to RND. The default rounding mode 21524a238c70SJohn Marino is to nearest initially. 21534a238c70SJohn Marino 21544a238c70SJohn Marino -- Function: mpfr_rnd_t mpfr_get_default_rounding_mode (void) 21554a238c70SJohn Marino Get the default rounding mode. 21564a238c70SJohn Marino 21574a238c70SJohn Marino -- Function: int mpfr_prec_round (mpfr_t X, mpfr_prec_t PREC, 21584a238c70SJohn Marino mpfr_rnd_t RND) 21594a238c70SJohn Marino Round X according to RND with precision PREC, which must be an 21604a238c70SJohn Marino integer between `MPFR_PREC_MIN' and `MPFR_PREC_MAX' (otherwise the 21614a238c70SJohn Marino behavior is undefined). If PREC is greater or equal to the 21624a238c70SJohn Marino precision of X, then new space is allocated for the significand, 21634a238c70SJohn Marino and it is filled with zeros. Otherwise, the significand is 21644a238c70SJohn Marino rounded to precision PREC with the given direction. In both cases, 21654a238c70SJohn Marino the precision of X is changed to PREC. 21664a238c70SJohn Marino 21674a238c70SJohn Marino Here is an example of how to use `mpfr_prec_round' to implement 21684a238c70SJohn Marino Newton's algorithm to compute the inverse of A, assuming X is 21694a238c70SJohn Marino already an approximation to N bits: 21704a238c70SJohn Marino mpfr_set_prec (t, 2 * n); 21714a238c70SJohn Marino mpfr_set (t, a, MPFR_RNDN); /* round a to 2n bits */ 21724a238c70SJohn Marino mpfr_mul (t, t, x, MPFR_RNDN); /* t is correct to 2n bits */ 21734a238c70SJohn Marino mpfr_ui_sub (t, 1, t, MPFR_RNDN); /* high n bits cancel with 1 */ 21744a238c70SJohn Marino mpfr_prec_round (t, n, MPFR_RNDN); /* t is correct to n bits */ 21754a238c70SJohn Marino mpfr_mul (t, t, x, MPFR_RNDN); /* t is correct to n bits */ 21764a238c70SJohn Marino mpfr_prec_round (x, 2 * n, MPFR_RNDN); /* exact */ 21774a238c70SJohn Marino mpfr_add (x, x, t, MPFR_RNDN); /* x is correct to 2n bits */ 21784a238c70SJohn Marino 21794a238c70SJohn Marino -- Function: int mpfr_can_round (mpfr_t B, mpfr_exp_t ERR, mpfr_rnd_t 21804a238c70SJohn Marino RND1, mpfr_rnd_t RND2, mpfr_prec_t PREC) 21814a238c70SJohn Marino Assuming B is an approximation of an unknown number X in the 21824a238c70SJohn Marino direction RND1 with error at most two to the power E(b)-ERR where 21834a238c70SJohn Marino E(b) is the exponent of B, return a non-zero value if one is able 21844a238c70SJohn Marino to round correctly X to precision PREC with the direction RND2, 21854a238c70SJohn Marino and 0 otherwise (including for NaN and Inf). This function *does 21864a238c70SJohn Marino not modify* its arguments. 21874a238c70SJohn Marino 21884a238c70SJohn Marino If RND1 is `MPFR_RNDN', then the sign of the error is unknown, but 21894a238c70SJohn Marino its absolute value is the same, so that the possible range is 21904a238c70SJohn Marino twice as large as with a directed rounding for RND1. 21914a238c70SJohn Marino 21924a238c70SJohn Marino Note: if one wants to also determine the correct *note ternary 21934a238c70SJohn Marino value:: when rounding B to precision PREC with rounding mode RND, 21944a238c70SJohn Marino a useful trick is the following: if (mpfr_can_round (b, err, MPFR_RNDN, MPFR_RNDZ, prec + (rnd == MPFR_RNDN))) 21954a238c70SJohn Marino ... 21964a238c70SJohn Marino Indeed, if RND is `MPFR_RNDN', this will check if one can round 21974a238c70SJohn Marino to PREC+1 bits with a directed rounding: if so, one can surely 21984a238c70SJohn Marino round to nearest to PREC bits, and in addition one can determine 21994a238c70SJohn Marino the correct ternary value, which would not be the case when B is 22004a238c70SJohn Marino near from a value exactly representable on PREC bits. 22014a238c70SJohn Marino 22024a238c70SJohn Marino -- Function: mpfr_prec_t mpfr_min_prec (mpfr_t X) 22034a238c70SJohn Marino Return the minimal number of bits required to store the 22044a238c70SJohn Marino significand of X, and 0 for special values, including 0. (Warning: 22054a238c70SJohn Marino the returned value can be less than `MPFR_PREC_MIN'.) 22064a238c70SJohn Marino 22074a238c70SJohn Marino The function name is subject to change. 22084a238c70SJohn Marino 22094a238c70SJohn Marino -- Function: const char * mpfr_print_rnd_mode (mpfr_rnd_t RND) 22104a238c70SJohn Marino Return a string ("MPFR_RNDD", "MPFR_RNDU", "MPFR_RNDN", 22114a238c70SJohn Marino "MPFR_RNDZ", "MPFR_RNDA") corresponding to the rounding mode RND, 22124a238c70SJohn Marino or a null pointer if RND is an invalid rounding mode. 22134a238c70SJohn Marino 22144a238c70SJohn Marino 22154a238c70SJohn MarinoFile: mpfr.info, Node: Miscellaneous Functions, Next: Exception Related Functions, Prev: Rounding Related Functions, Up: MPFR Interface 22164a238c70SJohn Marino 22174a238c70SJohn Marino5.12 Miscellaneous Functions 22184a238c70SJohn Marino============================ 22194a238c70SJohn Marino 22204a238c70SJohn Marino -- Function: void mpfr_nexttoward (mpfr_t X, mpfr_t Y) 22214a238c70SJohn Marino If X or Y is NaN, set X to NaN. If X and Y are equal, X is 22224a238c70SJohn Marino unchanged. Otherwise, if X is different from Y, replace X by the 22234a238c70SJohn Marino next floating-point number (with the precision of X and the 22244a238c70SJohn Marino current exponent range) in the direction of Y (the infinite values 22254a238c70SJohn Marino are seen as the smallest and largest floating-point numbers). If 22264a238c70SJohn Marino the result is zero, it keeps the same sign. No underflow or 22274a238c70SJohn Marino overflow is generated. 22284a238c70SJohn Marino 22294a238c70SJohn Marino -- Function: void mpfr_nextabove (mpfr_t X) 22304a238c70SJohn Marino -- Function: void mpfr_nextbelow (mpfr_t X) 22314a238c70SJohn Marino Equivalent to `mpfr_nexttoward' where Y is plus infinity (resp. 22324a238c70SJohn Marino minus infinity). 22334a238c70SJohn Marino 22344a238c70SJohn Marino -- Function: int mpfr_min (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, 22354a238c70SJohn Marino mpfr_rnd_t RND) 22364a238c70SJohn Marino -- Function: int mpfr_max (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, 22374a238c70SJohn Marino mpfr_rnd_t RND) 22384a238c70SJohn Marino Set ROP to the minimum (resp. maximum) of OP1 and OP2. If OP1 and 22394a238c70SJohn Marino OP2 are both NaN, then ROP is set to NaN. If OP1 or OP2 is NaN, 22404a238c70SJohn Marino then ROP is set to the numeric value. If OP1 and OP2 are zeros of 22414a238c70SJohn Marino different signs, then ROP is set to -0 (resp. +0). 22424a238c70SJohn Marino 22434a238c70SJohn Marino -- Function: int mpfr_urandomb (mpfr_t ROP, gmp_randstate_t STATE) 22444a238c70SJohn Marino Generate a uniformly distributed random float in the interval 0 <= 22454a238c70SJohn Marino ROP < 1. More precisely, the number can be seen as a float with a 22464a238c70SJohn Marino random non-normalized significand and exponent 0, which is then 22474a238c70SJohn Marino normalized (thus if E denotes the exponent after normalization, 22484a238c70SJohn Marino then the least -E significant bits of the significand are always 22494a238c70SJohn Marino 0). 22504a238c70SJohn Marino 22514a238c70SJohn Marino Return 0, unless the exponent is not in the current exponent 22524a238c70SJohn Marino range, in which case ROP is set to NaN and a non-zero value is 22534a238c70SJohn Marino returned (this should never happen in practice, except in very 22544a238c70SJohn Marino specific cases). The second argument is a `gmp_randstate_t' 22554a238c70SJohn Marino structure which should be created using the GMP `gmp_randinit' 22564a238c70SJohn Marino function (see the GMP manual). 22574a238c70SJohn Marino 22584a238c70SJohn Marino Note: for a given version of MPFR, the returned value of ROP and 22594a238c70SJohn Marino the new value of STATE (which controls further random values) do 22604a238c70SJohn Marino not depend on the machine word size. 22614a238c70SJohn Marino 22624a238c70SJohn Marino -- Function: int mpfr_urandom (mpfr_t ROP, gmp_randstate_t STATE, 22634a238c70SJohn Marino mpfr_rnd_t RND) 22644a238c70SJohn Marino Generate a uniformly distributed random float. The floating-point 22654a238c70SJohn Marino number ROP can be seen as if a random real number is generated 22664a238c70SJohn Marino according to the continuous uniform distribution on the interval 22674a238c70SJohn Marino [0, 1] and then rounded in the direction RND. 22684a238c70SJohn Marino 22694a238c70SJohn Marino The second argument is a `gmp_randstate_t' structure which should 22704a238c70SJohn Marino be created using the GMP `gmp_randinit' function (see the GMP 22714a238c70SJohn Marino manual). 22724a238c70SJohn Marino 22734a238c70SJohn Marino Note: the note for `mpfr_urandomb' holds too. In addition, the 22744a238c70SJohn Marino exponent range and the rounding mode might have a side effect on 22754a238c70SJohn Marino the next random state. 22764a238c70SJohn Marino 22774a238c70SJohn Marino -- Function: int mpfr_grandom (mpfr_t ROP1, mpfr_t ROP2, 22784a238c70SJohn Marino gmp_randstate_t STATE, mpfr_rnd_t RND) 22794a238c70SJohn Marino Generate two random floats according to a standard normal gaussian 22804a238c70SJohn Marino distribution. If ROP2 is a null pointer, then only one value is 22814a238c70SJohn Marino generated and stored in ROP1. 22824a238c70SJohn Marino 22834a238c70SJohn Marino The floating-point number ROP1 (and ROP2) can be seen as if a 22844a238c70SJohn Marino random real number were generated according to the standard normal 22854a238c70SJohn Marino gaussian distribution and then rounded in the direction RND. 22864a238c70SJohn Marino 22874a238c70SJohn Marino The third argument is a `gmp_randstate_t' structure, which should 22884a238c70SJohn Marino be created using the GMP `gmp_randinit' function (see the GMP 22894a238c70SJohn Marino manual). 22904a238c70SJohn Marino 2291*ab6d115fSJohn Marino The combination of the ternary values is returned like with 2292*ab6d115fSJohn Marino `mpfr_sin_cos'. If ROP2 is a null pointer, the second ternary 2293*ab6d115fSJohn Marino value is assumed to be 0 (note that the encoding of the only 2294*ab6d115fSJohn Marino ternary value is not the same as the usual encoding for functions 2295*ab6d115fSJohn Marino that return only one result). Otherwise the ternary value of a 2296*ab6d115fSJohn Marino random number is always non-zero. 2297*ab6d115fSJohn Marino 22984a238c70SJohn Marino Note: the note for `mpfr_urandomb' holds too. In addition, the 22994a238c70SJohn Marino exponent range and the rounding mode might have a side effect on 23004a238c70SJohn Marino the next random state. 23014a238c70SJohn Marino 23024a238c70SJohn Marino -- Function: mpfr_exp_t mpfr_get_exp (mpfr_t X) 23034a238c70SJohn Marino Return the exponent of X, assuming that X is a non-zero ordinary 23044a238c70SJohn Marino number and the significand is considered in [1/2,1). The behavior 23054a238c70SJohn Marino for NaN, infinity or zero is undefined. 23064a238c70SJohn Marino 23074a238c70SJohn Marino -- Function: int mpfr_set_exp (mpfr_t X, mpfr_exp_t E) 23084a238c70SJohn Marino Set the exponent of X if E is in the current exponent range, and 23094a238c70SJohn Marino return 0 (even if X is not a non-zero ordinary number); otherwise, 23104a238c70SJohn Marino return a non-zero value. The significand is assumed to be in 23114a238c70SJohn Marino [1/2,1). 23124a238c70SJohn Marino 23134a238c70SJohn Marino -- Function: int mpfr_signbit (mpfr_t OP) 23144a238c70SJohn Marino Return a non-zero value iff OP has its sign bit set (i.e., if it is 23154a238c70SJohn Marino negative, -0, or a NaN whose representation has its sign bit set). 23164a238c70SJohn Marino 23174a238c70SJohn Marino -- Function: int mpfr_setsign (mpfr_t ROP, mpfr_t OP, int S, 23184a238c70SJohn Marino mpfr_rnd_t RND) 23194a238c70SJohn Marino Set the value of ROP from OP, rounded toward the given direction 23204a238c70SJohn Marino RND, then set (resp. clear) its sign bit if S is non-zero (resp. 23214a238c70SJohn Marino zero), even when OP is a NaN. 23224a238c70SJohn Marino 23234a238c70SJohn Marino -- Function: int mpfr_copysign (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, 23244a238c70SJohn Marino mpfr_rnd_t RND) 23254a238c70SJohn Marino Set the value of ROP from OP1, rounded toward the given direction 23264a238c70SJohn Marino RND, then set its sign bit to that of OP2 (even when OP1 or OP2 is 23274a238c70SJohn Marino a NaN). This function is equivalent to `mpfr_setsign (ROP, OP1, 23284a238c70SJohn Marino mpfr_signbit (OP2), RND)'. 23294a238c70SJohn Marino 23304a238c70SJohn Marino -- Function: const char * mpfr_get_version (void) 23314a238c70SJohn Marino Return the MPFR version, as a null-terminated string. 23324a238c70SJohn Marino 23334a238c70SJohn Marino -- Macro: MPFR_VERSION 23344a238c70SJohn Marino -- Macro: MPFR_VERSION_MAJOR 23354a238c70SJohn Marino -- Macro: MPFR_VERSION_MINOR 23364a238c70SJohn Marino -- Macro: MPFR_VERSION_PATCHLEVEL 23374a238c70SJohn Marino -- Macro: MPFR_VERSION_STRING 23384a238c70SJohn Marino `MPFR_VERSION' is the version of MPFR as a preprocessing constant. 23394a238c70SJohn Marino `MPFR_VERSION_MAJOR', `MPFR_VERSION_MINOR' and 23404a238c70SJohn Marino `MPFR_VERSION_PATCHLEVEL' are respectively the major, minor and 23414a238c70SJohn Marino patch level of MPFR version, as preprocessing constants. 23424a238c70SJohn Marino `MPFR_VERSION_STRING' is the version (with an optional suffix, used 23434a238c70SJohn Marino in development and pre-release versions) as a string constant, 23444a238c70SJohn Marino which can be compared to the result of `mpfr_get_version' to check 23454a238c70SJohn Marino at run time the header file and library used match: 23464a238c70SJohn Marino if (strcmp (mpfr_get_version (), MPFR_VERSION_STRING)) 23474a238c70SJohn Marino fprintf (stderr, "Warning: header and library do not match\n"); 23484a238c70SJohn Marino Note: Obtaining different strings is not necessarily an error, as 23494a238c70SJohn Marino in general, a program compiled with some old MPFR version can be 23504a238c70SJohn Marino dynamically linked with a newer MPFR library version (if allowed 23514a238c70SJohn Marino by the library versioning system). 23524a238c70SJohn Marino 23534a238c70SJohn Marino -- Macro: long MPFR_VERSION_NUM (MAJOR, MINOR, PATCHLEVEL) 23544a238c70SJohn Marino Create an integer in the same format as used by `MPFR_VERSION' 23554a238c70SJohn Marino from the given MAJOR, MINOR and PATCHLEVEL. Here is an example of 23564a238c70SJohn Marino how to check the MPFR version at compile time: 23574a238c70SJohn Marino #if (!defined(MPFR_VERSION) || (MPFR_VERSION<MPFR_VERSION_NUM(3,0,0))) 23584a238c70SJohn Marino # error "Wrong MPFR version." 23594a238c70SJohn Marino #endif 23604a238c70SJohn Marino 23614a238c70SJohn Marino -- Function: const char * mpfr_get_patches (void) 23624a238c70SJohn Marino Return a null-terminated string containing the ids of the patches 23634a238c70SJohn Marino applied to the MPFR library (contents of the `PATCHES' file), 23644a238c70SJohn Marino separated by spaces. Note: If the program has been compiled with 23654a238c70SJohn Marino an older MPFR version and is dynamically linked with a new MPFR 23664a238c70SJohn Marino library version, the identifiers of the patches applied to the old 23674a238c70SJohn Marino (compile-time) MPFR version are not available (however this 23684a238c70SJohn Marino information should not have much interest in general). 23694a238c70SJohn Marino 23704a238c70SJohn Marino -- Function: int mpfr_buildopt_tls_p (void) 23714a238c70SJohn Marino Return a non-zero value if MPFR was compiled as thread safe using 23724a238c70SJohn Marino compiler-level Thread Local Storage (that is, MPFR was built with 23734a238c70SJohn Marino the `--enable-thread-safe' configure option, see `INSTALL' file), 23744a238c70SJohn Marino return zero otherwise. 23754a238c70SJohn Marino 23764a238c70SJohn Marino -- Function: int mpfr_buildopt_decimal_p (void) 23774a238c70SJohn Marino Return a non-zero value if MPFR was compiled with decimal float 23784a238c70SJohn Marino support (that is, MPFR was built with the `--enable-decimal-float' 23794a238c70SJohn Marino configure option), return zero otherwise. 23804a238c70SJohn Marino 23814a238c70SJohn Marino -- Function: int mpfr_buildopt_gmpinternals_p (void) 23824a238c70SJohn Marino Return a non-zero value if MPFR was compiled with GMP internals 23834a238c70SJohn Marino (that is, MPFR was built with either `--with-gmp-build' or 23844a238c70SJohn Marino `--enable-gmp-internals' configure option), return zero otherwise. 23854a238c70SJohn Marino 23864a238c70SJohn Marino -- Function: const char * mpfr_buildopt_tune_case (void) 23874a238c70SJohn Marino Return a string saying which thresholds file has been used at 23884a238c70SJohn Marino compile time. This file is normally selected from the processor 23894a238c70SJohn Marino type. 23904a238c70SJohn Marino 23914a238c70SJohn Marino 23924a238c70SJohn MarinoFile: mpfr.info, Node: Exception Related Functions, Next: Compatibility with MPF, Prev: Miscellaneous Functions, Up: MPFR Interface 23934a238c70SJohn Marino 23944a238c70SJohn Marino5.13 Exception Related Functions 23954a238c70SJohn Marino================================ 23964a238c70SJohn Marino 23974a238c70SJohn Marino -- Function: mpfr_exp_t mpfr_get_emin (void) 23984a238c70SJohn Marino -- Function: mpfr_exp_t mpfr_get_emax (void) 23994a238c70SJohn Marino Return the (current) smallest and largest exponents allowed for a 24004a238c70SJohn Marino floating-point variable. The smallest positive value of a 24014a238c70SJohn Marino floating-point variable is one half times 2 raised to the smallest 24024a238c70SJohn Marino exponent and the largest value has the form (1 - epsilon) times 2 24034a238c70SJohn Marino raised to the largest exponent, where epsilon depends on the 24044a238c70SJohn Marino precision of the considered variable. 24054a238c70SJohn Marino 24064a238c70SJohn Marino -- Function: int mpfr_set_emin (mpfr_exp_t EXP) 24074a238c70SJohn Marino -- Function: int mpfr_set_emax (mpfr_exp_t EXP) 24084a238c70SJohn Marino Set the smallest and largest exponents allowed for a 24094a238c70SJohn Marino floating-point variable. Return a non-zero value when EXP is not 24104a238c70SJohn Marino in the range accepted by the implementation (in that case the 24114a238c70SJohn Marino smallest or largest exponent is not changed), and zero otherwise. 24124a238c70SJohn Marino If the user changes the exponent range, it is her/his 24134a238c70SJohn Marino responsibility to check that all current floating-point variables 24144a238c70SJohn Marino are in the new allowed range (for example using 24154a238c70SJohn Marino `mpfr_check_range'), otherwise the subsequent behavior will be 24164a238c70SJohn Marino undefined, in the sense of the ISO C standard. 24174a238c70SJohn Marino 24184a238c70SJohn Marino -- Function: mpfr_exp_t mpfr_get_emin_min (void) 24194a238c70SJohn Marino -- Function: mpfr_exp_t mpfr_get_emin_max (void) 24204a238c70SJohn Marino -- Function: mpfr_exp_t mpfr_get_emax_min (void) 24214a238c70SJohn Marino -- Function: mpfr_exp_t mpfr_get_emax_max (void) 24224a238c70SJohn Marino Return the minimum and maximum of the exponents allowed for 24234a238c70SJohn Marino `mpfr_set_emin' and `mpfr_set_emax' respectively. These values 24244a238c70SJohn Marino are implementation dependent, thus a program using 24254a238c70SJohn Marino `mpfr_set_emax(mpfr_get_emax_max())' or 24264a238c70SJohn Marino `mpfr_set_emin(mpfr_get_emin_min())' may not be portable. 24274a238c70SJohn Marino 24284a238c70SJohn Marino -- Function: int mpfr_check_range (mpfr_t X, int T, mpfr_rnd_t RND) 24294a238c70SJohn Marino This function assumes that X is the correctly-rounded value of some 24304a238c70SJohn Marino real value Y in the direction RND and some extended exponent 24314a238c70SJohn Marino range, and that T is the corresponding *note ternary value::. For 24324a238c70SJohn Marino example, one performed `t = mpfr_log (x, u, rnd)', and Y is the 24334a238c70SJohn Marino exact logarithm of U. Thus T is negative if X is smaller than Y, 24344a238c70SJohn Marino positive if X is larger than Y, and zero if X equals Y. This 24354a238c70SJohn Marino function modifies X if needed to be in the current range of 24364a238c70SJohn Marino acceptable values: It generates an underflow or an overflow if the 24374a238c70SJohn Marino exponent of X is outside the current allowed range; the value of T 24384a238c70SJohn Marino may be used to avoid a double rounding. This function returns zero 24394a238c70SJohn Marino if the new value of X equals the exact one Y, a positive value if 24404a238c70SJohn Marino that new value is larger than Y, and a negative value if it is 24414a238c70SJohn Marino smaller than Y. Note that unlike most functions, the new result X 24424a238c70SJohn Marino is compared to the (unknown) exact one Y, not the input value X, 24434a238c70SJohn Marino i.e., the ternary value is propagated. 24444a238c70SJohn Marino 24454a238c70SJohn Marino Note: If X is an infinity and T is different from zero (i.e., if 24464a238c70SJohn Marino the rounded result is an inexact infinity), then the overflow flag 24474a238c70SJohn Marino is set. This is useful because `mpfr_check_range' is typically 24484a238c70SJohn Marino called (at least in MPFR functions) after restoring the flags that 24494a238c70SJohn Marino could have been set due to internal computations. 24504a238c70SJohn Marino 24514a238c70SJohn Marino -- Function: int mpfr_subnormalize (mpfr_t X, int T, mpfr_rnd_t RND) 24524a238c70SJohn Marino This function rounds X emulating subnormal number arithmetic: if X 24534a238c70SJohn Marino is outside the subnormal exponent range, it just propagates the 24544a238c70SJohn Marino *note ternary value:: T; otherwise, it rounds X to precision 24554a238c70SJohn Marino `EXP(x)-emin+1' according to rounding mode RND and previous 24564a238c70SJohn Marino ternary value T, avoiding double rounding problems. More 24574a238c70SJohn Marino precisely in the subnormal domain, denoting by E the value of 24584a238c70SJohn Marino `emin', X is rounded in fixed-point arithmetic to an integer 24594a238c70SJohn Marino multiple of two to the power E-1; as a consequence, 1.5 multiplied 24604a238c70SJohn Marino by two to the power E-1 when T is zero is rounded to two to the 24614a238c70SJohn Marino power E with rounding to nearest. 24624a238c70SJohn Marino 24634a238c70SJohn Marino `PREC(x)' is not modified by this function. RND and T must be the 24644a238c70SJohn Marino rounding mode and the returned ternary value used when computing X 24654a238c70SJohn Marino (as in `mpfr_check_range'). The subnormal exponent range is from 24664a238c70SJohn Marino `emin' to `emin+PREC(x)-1'. If the result cannot be represented 24674a238c70SJohn Marino in the current exponent range (due to a too small `emax'), the 24684a238c70SJohn Marino behavior is undefined. Note that unlike most functions, the 24694a238c70SJohn Marino result is compared to the exact one, not the input value X, i.e., 24704a238c70SJohn Marino the ternary value is propagated. 24714a238c70SJohn Marino 24724a238c70SJohn Marino As usual, if the returned ternary value is non zero, the inexact 24734a238c70SJohn Marino flag is set. Moreover, if a second rounding occurred (because the 24744a238c70SJohn Marino input X was in the subnormal range), the underflow flag is set. 24754a238c70SJohn Marino 24764a238c70SJohn Marino This is an example of how to emulate binary double IEEE 754 24774a238c70SJohn Marinoarithmetic (binary64 in IEEE 754-2008) using MPFR: 24784a238c70SJohn Marino 24794a238c70SJohn Marino { 24804a238c70SJohn Marino mpfr_t xa, xb; int i; volatile double a, b; 24814a238c70SJohn Marino 24824a238c70SJohn Marino mpfr_set_default_prec (53); 24834a238c70SJohn Marino mpfr_set_emin (-1073); mpfr_set_emax (1024); 24844a238c70SJohn Marino 24854a238c70SJohn Marino mpfr_init (xa); mpfr_init (xb); 24864a238c70SJohn Marino 24874a238c70SJohn Marino b = 34.3; mpfr_set_d (xb, b, MPFR_RNDN); 24884a238c70SJohn Marino a = 0x1.1235P-1021; mpfr_set_d (xa, a, MPFR_RNDN); 24894a238c70SJohn Marino 24904a238c70SJohn Marino a /= b; 24914a238c70SJohn Marino i = mpfr_div (xa, xa, xb, MPFR_RNDN); 24924a238c70SJohn Marino i = mpfr_subnormalize (xa, i, MPFR_RNDN); /* new ternary value */ 24934a238c70SJohn Marino 24944a238c70SJohn Marino mpfr_clear (xa); mpfr_clear (xb); 24954a238c70SJohn Marino } 24964a238c70SJohn Marino 24974a238c70SJohn Marino Warning: this emulates a double IEEE 754 arithmetic with correct 24984a238c70SJohn Marinorounding in the subnormal range, which may not be the case for your 24994a238c70SJohn Marinohardware. 25004a238c70SJohn Marino 25014a238c70SJohn Marino -- Function: void mpfr_clear_underflow (void) 25024a238c70SJohn Marino -- Function: void mpfr_clear_overflow (void) 25034a238c70SJohn Marino -- Function: void mpfr_clear_divby0 (void) 25044a238c70SJohn Marino -- Function: void mpfr_clear_nanflag (void) 25054a238c70SJohn Marino -- Function: void mpfr_clear_inexflag (void) 25064a238c70SJohn Marino -- Function: void mpfr_clear_erangeflag (void) 25074a238c70SJohn Marino Clear the underflow, overflow, divide-by-zero, invalid, inexact 25084a238c70SJohn Marino and _erange_ flags. 25094a238c70SJohn Marino 25104a238c70SJohn Marino -- Function: void mpfr_set_underflow (void) 25114a238c70SJohn Marino -- Function: void mpfr_set_overflow (void) 25124a238c70SJohn Marino -- Function: void mpfr_set_divby0 (void) 25134a238c70SJohn Marino -- Function: void mpfr_set_nanflag (void) 25144a238c70SJohn Marino -- Function: void mpfr_set_inexflag (void) 25154a238c70SJohn Marino -- Function: void mpfr_set_erangeflag (void) 25164a238c70SJohn Marino Set the underflow, overflow, divide-by-zero, invalid, inexact and 25174a238c70SJohn Marino _erange_ flags. 25184a238c70SJohn Marino 25194a238c70SJohn Marino -- Function: void mpfr_clear_flags (void) 25204a238c70SJohn Marino Clear all global flags (underflow, overflow, divide-by-zero, 25214a238c70SJohn Marino invalid, inexact, _erange_). 25224a238c70SJohn Marino 25234a238c70SJohn Marino -- Function: int mpfr_underflow_p (void) 25244a238c70SJohn Marino -- Function: int mpfr_overflow_p (void) 25254a238c70SJohn Marino -- Function: int mpfr_divby0_p (void) 25264a238c70SJohn Marino -- Function: int mpfr_nanflag_p (void) 25274a238c70SJohn Marino -- Function: int mpfr_inexflag_p (void) 25284a238c70SJohn Marino -- Function: int mpfr_erangeflag_p (void) 25294a238c70SJohn Marino Return the corresponding (underflow, overflow, divide-by-zero, 25304a238c70SJohn Marino invalid, inexact, _erange_) flag, which is non-zero iff the flag 25314a238c70SJohn Marino is set. 25324a238c70SJohn Marino 25334a238c70SJohn Marino 25344a238c70SJohn MarinoFile: mpfr.info, Node: Compatibility with MPF, Next: Custom Interface, Prev: Exception Related Functions, Up: MPFR Interface 25354a238c70SJohn Marino 25364a238c70SJohn Marino5.14 Compatibility With MPF 25374a238c70SJohn Marino=========================== 25384a238c70SJohn Marino 25394a238c70SJohn MarinoA header file `mpf2mpfr.h' is included in the distribution of MPFR for 25404a238c70SJohn Marinocompatibility with the GNU MP class MPF. By inserting the following 25414a238c70SJohn Marinotwo lines after the `#include <gmp.h>' line, 25424a238c70SJohn Marino#include <mpfr.h> 25434a238c70SJohn Marino#include <mpf2mpfr.h> 25444a238c70SJohn Marino any program written for MPF can be compiled directly with MPFR without 25454a238c70SJohn Marinoany changes (except the `gmp_printf' functions will not work for 25464a238c70SJohn Marinoarguments of type `mpfr_t'). All operations are then performed with 25474a238c70SJohn Marinothe default MPFR rounding mode, which can be reset with 25484a238c70SJohn Marino`mpfr_set_default_rounding_mode'. 25494a238c70SJohn Marino 25504a238c70SJohn Marino Warning: the `mpf_init' and `mpf_init2' functions initialize to 25514a238c70SJohn Marinozero, whereas the corresponding MPFR functions initialize to NaN: this 25524a238c70SJohn Marinois useful to detect uninitialized values, but is slightly incompatible 25534a238c70SJohn Marinowith MPF. 25544a238c70SJohn Marino 25554a238c70SJohn Marino -- Function: void mpfr_set_prec_raw (mpfr_t X, mpfr_prec_t PREC) 25564a238c70SJohn Marino Reset the precision of X to be *exactly* PREC bits. The only 25574a238c70SJohn Marino difference with `mpfr_set_prec' is that PREC is assumed to be 25584a238c70SJohn Marino small enough so that the significand fits into the current 25594a238c70SJohn Marino allocated memory space for X. Otherwise the behavior is undefined. 25604a238c70SJohn Marino 25614a238c70SJohn Marino -- Function: int mpfr_eq (mpfr_t OP1, mpfr_t OP2, unsigned long int 25624a238c70SJohn Marino OP3) 25634a238c70SJohn Marino Return non-zero if OP1 and OP2 are both non-zero ordinary numbers 25644a238c70SJohn Marino with the same exponent and the same first OP3 bits, both zero, or 25654a238c70SJohn Marino both infinities of the same sign. Return zero otherwise. This 25664a238c70SJohn Marino function is defined for compatibility with MPF, we do not recommend 25674a238c70SJohn Marino to use it otherwise. Do not use it either if you want to know 25684a238c70SJohn Marino whether two numbers are close to each other; for instance, 25694a238c70SJohn Marino 1.011111 and 1.100000 are regarded as different for any value of 25704a238c70SJohn Marino OP3 larger than 1. 25714a238c70SJohn Marino 25724a238c70SJohn Marino -- Function: void mpfr_reldiff (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, 25734a238c70SJohn Marino mpfr_rnd_t RND) 25744a238c70SJohn Marino Compute the relative difference between OP1 and OP2 and store the 25754a238c70SJohn Marino result in ROP. This function does not guarantee the correct 25764a238c70SJohn Marino rounding on the relative difference; it just computes 25774a238c70SJohn Marino |OP1-OP2|/OP1, using the precision of ROP and the rounding mode 25784a238c70SJohn Marino RND for all operations. 25794a238c70SJohn Marino 25804a238c70SJohn Marino -- Function: int mpfr_mul_2exp (mpfr_t ROP, mpfr_t OP1, unsigned long 25814a238c70SJohn Marino int OP2, mpfr_rnd_t RND) 25824a238c70SJohn Marino -- Function: int mpfr_div_2exp (mpfr_t ROP, mpfr_t OP1, unsigned long 25834a238c70SJohn Marino int OP2, mpfr_rnd_t RND) 25844a238c70SJohn Marino These functions are identical to `mpfr_mul_2ui' and `mpfr_div_2ui' 25854a238c70SJohn Marino respectively. These functions are only kept for compatibility 25864a238c70SJohn Marino with MPF, one should prefer `mpfr_mul_2ui' and `mpfr_div_2ui' 25874a238c70SJohn Marino otherwise. 25884a238c70SJohn Marino 25894a238c70SJohn Marino 25904a238c70SJohn MarinoFile: mpfr.info, Node: Custom Interface, Next: Internals, Prev: Compatibility with MPF, Up: MPFR Interface 25914a238c70SJohn Marino 25924a238c70SJohn Marino5.15 Custom Interface 25934a238c70SJohn Marino===================== 25944a238c70SJohn Marino 25954a238c70SJohn MarinoSome applications use a stack to handle the memory and their objects. 25964a238c70SJohn MarinoHowever, the MPFR memory design is not well suited for such a thing. So 25974a238c70SJohn Marinothat such applications are able to use MPFR, an auxiliary memory 25984a238c70SJohn Marinointerface has been created: the Custom Interface. 25994a238c70SJohn Marino 26004a238c70SJohn Marino The following interface allows one to use MPFR in two ways: 26014a238c70SJohn Marino * Either directly store a floating-point number as a `mpfr_t' on the 26024a238c70SJohn Marino stack. 26034a238c70SJohn Marino 26044a238c70SJohn Marino * Either store its own representation on the stack and construct a 26054a238c70SJohn Marino new temporary `mpfr_t' each time it is needed. 26064a238c70SJohn Marino Nothing has to be done to destroy the floating-point numbers except 26074a238c70SJohn Marinogarbaging the used memory: all the memory management (allocating, 26084a238c70SJohn Marinodestroying, garbaging) is left to the application. 26094a238c70SJohn Marino 26104a238c70SJohn Marino Each function in this interface is also implemented as a macro for 26114a238c70SJohn Marinoefficiency reasons: for example `mpfr_custom_init (s, p)' uses the 26124a238c70SJohn Marinomacro, while `(mpfr_custom_init) (s, p)' uses the function. 26134a238c70SJohn Marino 26144a238c70SJohn Marino Note 1: MPFR functions may still initialize temporary floating-point 26154a238c70SJohn Marinonumbers using `mpfr_init' and similar functions. See Custom Allocation 26164a238c70SJohn Marino(GNU MP). 26174a238c70SJohn Marino 26184a238c70SJohn Marino Note 2: MPFR functions may use the cached functions (`mpfr_const_pi' 26194a238c70SJohn Marinofor example), even if they are not explicitly called. You have to call 26204a238c70SJohn Marino`mpfr_free_cache' each time you garbage the memory iff `mpfr_init', 26214a238c70SJohn Marinothrough GMP Custom Allocation, allocates its memory on the application 26224a238c70SJohn Marinostack. 26234a238c70SJohn Marino 26244a238c70SJohn Marino -- Function: size_t mpfr_custom_get_size (mpfr_prec_t PREC) 26254a238c70SJohn Marino Return the needed size in bytes to store the significand of a 26264a238c70SJohn Marino floating-point number of precision PREC. 26274a238c70SJohn Marino 26284a238c70SJohn Marino -- Function: void mpfr_custom_init (void *SIGNIFICAND, mpfr_prec_t 26294a238c70SJohn Marino PREC) 26304a238c70SJohn Marino Initialize a significand of precision PREC, where SIGNIFICAND must 26314a238c70SJohn Marino be an area of `mpfr_custom_get_size (prec)' bytes at least and be 26324a238c70SJohn Marino suitably aligned for an array of `mp_limb_t' (GMP type, *note 26334a238c70SJohn Marino Internals::). 26344a238c70SJohn Marino 26354a238c70SJohn Marino -- Function: void mpfr_custom_init_set (mpfr_t X, int KIND, mpfr_exp_t 26364a238c70SJohn Marino EXP, mpfr_prec_t PREC, void *SIGNIFICAND) 26374a238c70SJohn Marino Perform a dummy initialization of a `mpfr_t' and set it to: 26384a238c70SJohn Marino * if `ABS(kind) == MPFR_NAN_KIND', X is set to NaN; 26394a238c70SJohn Marino 26404a238c70SJohn Marino * if `ABS(kind) == MPFR_INF_KIND', X is set to the infinity of 26414a238c70SJohn Marino sign `sign(kind)'; 26424a238c70SJohn Marino 26434a238c70SJohn Marino * if `ABS(kind) == MPFR_ZERO_KIND', X is set to the zero of 26444a238c70SJohn Marino sign `sign(kind)'; 26454a238c70SJohn Marino 26464a238c70SJohn Marino * if `ABS(kind) == MPFR_REGULAR_KIND', X is set to a regular 26474a238c70SJohn Marino number: `x = sign(kind)*significand*2^exp'. 26484a238c70SJohn Marino In all cases, it uses SIGNIFICAND directly for further computing 26494a238c70SJohn Marino involving X. It will not allocate anything. A floating-point 26504a238c70SJohn Marino number initialized with this function cannot be resized using 26514a238c70SJohn Marino `mpfr_set_prec' or `mpfr_prec_round', or cleared using 26524a238c70SJohn Marino `mpfr_clear'! The SIGNIFICAND must have been initialized with 26534a238c70SJohn Marino `mpfr_custom_init' using the same precision PREC. 26544a238c70SJohn Marino 26554a238c70SJohn Marino -- Function: int mpfr_custom_get_kind (mpfr_t X) 26564a238c70SJohn Marino Return the current kind of a `mpfr_t' as created by 26574a238c70SJohn Marino `mpfr_custom_init_set'. The behavior of this function for any 26584a238c70SJohn Marino `mpfr_t' not initialized with `mpfr_custom_init_set' is undefined. 26594a238c70SJohn Marino 26604a238c70SJohn Marino -- Function: void * mpfr_custom_get_significand (mpfr_t X) 26614a238c70SJohn Marino Return a pointer to the significand used by a `mpfr_t' initialized 26624a238c70SJohn Marino with `mpfr_custom_init_set'. The behavior of this function for 26634a238c70SJohn Marino any `mpfr_t' not initialized with `mpfr_custom_init_set' is 26644a238c70SJohn Marino undefined. 26654a238c70SJohn Marino 26664a238c70SJohn Marino -- Function: mpfr_exp_t mpfr_custom_get_exp (mpfr_t X) 26674a238c70SJohn Marino Return the exponent of X, assuming that X is a non-zero ordinary 26684a238c70SJohn Marino number. The return value for NaN, Infinity or zero is unspecified 26694a238c70SJohn Marino but does not produce any trap. The behavior of this function for 26704a238c70SJohn Marino any `mpfr_t' not initialized with `mpfr_custom_init_set' is 26714a238c70SJohn Marino undefined. 26724a238c70SJohn Marino 26734a238c70SJohn Marino -- Function: void mpfr_custom_move (mpfr_t X, void *NEW_POSITION) 26744a238c70SJohn Marino Inform MPFR that the significand of X has moved due to a garbage 26754a238c70SJohn Marino collect and update its new position to `new_position'. However 26764a238c70SJohn Marino the application has to move the significand and the `mpfr_t' 26774a238c70SJohn Marino itself. The behavior of this function for any `mpfr_t' not 26784a238c70SJohn Marino initialized with `mpfr_custom_init_set' is undefined. 26794a238c70SJohn Marino 26804a238c70SJohn Marino 26814a238c70SJohn MarinoFile: mpfr.info, Node: Internals, Prev: Custom Interface, Up: MPFR Interface 26824a238c70SJohn Marino 26834a238c70SJohn Marino5.16 Internals 26844a238c70SJohn Marino============== 26854a238c70SJohn Marino 26864a238c70SJohn MarinoA "limb" means the part of a multi-precision number that fits in a 26874a238c70SJohn Marinosingle word. Usually a limb contains 32 or 64 bits. The C data type 26884a238c70SJohn Marinofor a limb is `mp_limb_t'. 26894a238c70SJohn Marino 26904a238c70SJohn Marino The `mpfr_t' type is internally defined as a one-element array of a 26914a238c70SJohn Marinostructure, and `mpfr_ptr' is the C data type representing a pointer to 26924a238c70SJohn Marinothis structure. The `mpfr_t' type consists of four fields: 26934a238c70SJohn Marino 26944a238c70SJohn Marino * The `_mpfr_prec' field is used to store the precision of the 26954a238c70SJohn Marino variable (in bits); this is not less than `MPFR_PREC_MIN'. 26964a238c70SJohn Marino 26974a238c70SJohn Marino * The `_mpfr_sign' field is used to store the sign of the variable. 26984a238c70SJohn Marino 26994a238c70SJohn Marino * The `_mpfr_exp' field stores the exponent. An exponent of 0 means 27004a238c70SJohn Marino a radix point just above the most significant limb. Non-zero 27014a238c70SJohn Marino values n are a multiplier 2^n relative to that point. A NaN, an 27024a238c70SJohn Marino infinity and a zero are indicated by special values of the exponent 27034a238c70SJohn Marino field. 27044a238c70SJohn Marino 27054a238c70SJohn Marino * Finally, the `_mpfr_d' field is a pointer to the limbs, least 27064a238c70SJohn Marino significant limbs stored first. The number of limbs in use is 27074a238c70SJohn Marino controlled by `_mpfr_prec', namely 27084a238c70SJohn Marino ceil(`_mpfr_prec'/`mp_bits_per_limb'). Non-singular (i.e., 27094a238c70SJohn Marino different from NaN, Infinity or zero) values always have the most 27104a238c70SJohn Marino significant bit of the most significant limb set to 1. When the 27114a238c70SJohn Marino precision does not correspond to a whole number of limbs, the 27124a238c70SJohn Marino excess bits at the low end of the data are zeros. 27134a238c70SJohn Marino 27144a238c70SJohn Marino 27154a238c70SJohn Marino 27164a238c70SJohn MarinoFile: mpfr.info, Node: API Compatibility, Next: Contributors, Prev: MPFR Interface, Up: Top 27174a238c70SJohn Marino 27184a238c70SJohn Marino6 API Compatibility 27194a238c70SJohn Marino******************* 27204a238c70SJohn Marino 27214a238c70SJohn MarinoThe goal of this section is to describe some API changes that occurred 27224a238c70SJohn Marinofrom one version of MPFR to another, and how to write code that can be 27234a238c70SJohn Marinocompiled and run with older MPFR versions. The minimum MPFR version 27244a238c70SJohn Marinothat is considered here is 2.2.0 (released on 20 September 2005). 27254a238c70SJohn Marino 27264a238c70SJohn Marino API changes can only occur between major or minor versions. Thus the 27274a238c70SJohn Marinopatchlevel (the third number in the MPFR version) will be ignored in 27284a238c70SJohn Marinothe following. If a program does not use MPFR internals, changes in 27294a238c70SJohn Marinothe behavior between two versions differing only by the patchlevel 27304a238c70SJohn Marinoshould only result from what was regarded as a bug or unspecified 27314a238c70SJohn Marinobehavior. 27324a238c70SJohn Marino 27334a238c70SJohn Marino As a general rule, a program written for some MPFR version should 27344a238c70SJohn Marinowork with later versions, possibly except at a new major version, where 27354a238c70SJohn Marinosome features (described as obsolete for some time) can be removed. In 27364a238c70SJohn Marinosuch a case, a failure should occur during compilation or linking. If 27374a238c70SJohn Marinoa result becomes incorrect because of such a change, please look at the 27384a238c70SJohn Marinovarious changes below (they are minimal, and most software should be 27394a238c70SJohn Marinounaffected), at the FAQ and at the MPFR web page for your version (a 27404a238c70SJohn Marinobug could have been introduced and be already fixed); and if the 27414a238c70SJohn Marinoproblem is not mentioned, please send us a bug report (*note Reporting 27424a238c70SJohn MarinoBugs::). 27434a238c70SJohn Marino 27444a238c70SJohn Marino However, a program written for the current MPFR version (as 27454a238c70SJohn Marinodocumented by this manual) may not necessarily work with previous 27464a238c70SJohn Marinoversions of MPFR. This section should help developers to write 27474a238c70SJohn Marinoportable code. 27484a238c70SJohn Marino 27494a238c70SJohn Marino Note: Information given here may be incomplete. API changes are 27504a238c70SJohn Marinoalso described in the NEWS file (for each version, instead of being 27514a238c70SJohn Marinoclassified like here), together with other changes. 27524a238c70SJohn Marino 27534a238c70SJohn Marino* Menu: 27544a238c70SJohn Marino 27554a238c70SJohn Marino* Type and Macro Changes:: 27564a238c70SJohn Marino* Added Functions:: 27574a238c70SJohn Marino* Changed Functions:: 27584a238c70SJohn Marino* Removed Functions:: 27594a238c70SJohn Marino* Other Changes:: 27604a238c70SJohn Marino 27614a238c70SJohn Marino 27624a238c70SJohn MarinoFile: mpfr.info, Node: Type and Macro Changes, Next: Added Functions, Prev: API Compatibility, Up: API Compatibility 27634a238c70SJohn Marino 27644a238c70SJohn Marino6.1 Type and Macro Changes 27654a238c70SJohn Marino========================== 27664a238c70SJohn Marino 27674a238c70SJohn MarinoThe official type for exponent values changed from `mp_exp_t' to 27684a238c70SJohn Marino`mpfr_exp_t' in MPFR 3.0. The type `mp_exp_t' will remain available as 27694a238c70SJohn Marinoit comes from GMP (with a different meaning). These types are 27704a238c70SJohn Marinocurrently the same (`mpfr_exp_t' is defined as `mp_exp_t' with 27714a238c70SJohn Marino`typedef'), so that programs can still use `mp_exp_t'; but this may 27724a238c70SJohn Marinochange in the future. Alternatively, using the following code after 27734a238c70SJohn Marinoincluding `mpfr.h' will work with official MPFR versions, as 27744a238c70SJohn Marino`mpfr_exp_t' was never defined in MPFR 2.x: 27754a238c70SJohn Marino #if MPFR_VERSION_MAJOR < 3 27764a238c70SJohn Marino typedef mp_exp_t mpfr_exp_t; 27774a238c70SJohn Marino #endif 27784a238c70SJohn Marino 27794a238c70SJohn Marino The official types for precision values and for rounding modes 27804a238c70SJohn Marinorespectively changed from `mp_prec_t' and `mp_rnd_t' to `mpfr_prec_t' 27814a238c70SJohn Marinoand `mpfr_rnd_t' in MPFR 3.0. This change was actually done a long 27824a238c70SJohn Marinotime ago in MPFR, at least since MPFR 2.2.0, with the following code in 27834a238c70SJohn Marino`mpfr.h': 27844a238c70SJohn Marino #ifndef mp_rnd_t 27854a238c70SJohn Marino # define mp_rnd_t mpfr_rnd_t 27864a238c70SJohn Marino #endif 27874a238c70SJohn Marino #ifndef mp_prec_t 27884a238c70SJohn Marino # define mp_prec_t mpfr_prec_t 27894a238c70SJohn Marino #endif 27904a238c70SJohn Marino This means that it is safe to use the new official types 27914a238c70SJohn Marino`mpfr_prec_t' and `mpfr_rnd_t' in your programs. The types `mp_prec_t' 27924a238c70SJohn Marinoand `mp_rnd_t' (defined in MPFR only) may be removed in the future, as 27934a238c70SJohn Marinothe prefix `mp_' is reserved by GMP. 27944a238c70SJohn Marino 27954a238c70SJohn Marino The precision type `mpfr_prec_t' (`mp_prec_t') was unsigned before 27964a238c70SJohn MarinoMPFR 3.0; it is now signed. `MPFR_PREC_MAX' has not changed, though. 27974a238c70SJohn MarinoIndeed the MPFR code requires that `MPFR_PREC_MAX' be representable in 27984a238c70SJohn Marinothe exponent type, which may have the same size as `mpfr_prec_t' but 27994a238c70SJohn Marinohas always been signed. The consequence is that valid code that does 28004a238c70SJohn Marinonot assume anything about the signedness of `mpfr_prec_t' should work 28014a238c70SJohn Marinowith past and new MPFR versions. This change was useful as the use of 28024a238c70SJohn Marinounsigned types tends to convert signed values to unsigned ones in 28034a238c70SJohn Marinoexpressions due to the usual arithmetic conversions, which can yield 28044a238c70SJohn Marinoincorrect results if a negative value is converted in such a way. 28054a238c70SJohn MarinoWarning! A program assuming (intentionally or not) that `mpfr_prec_t' 28064a238c70SJohn Marinois signed may be affected by this problem when it is built and run 28074a238c70SJohn Marinoagainst MPFR 2.x. 28084a238c70SJohn Marino 28094a238c70SJohn Marino The rounding modes `GMP_RNDx' were renamed to `MPFR_RNDx' in MPFR 28104a238c70SJohn Marino3.0. However the old names `GMP_RNDx' have been kept for compatibility 28114a238c70SJohn Marino(this might change in future versions), using: 28124a238c70SJohn Marino #define GMP_RNDN MPFR_RNDN 28134a238c70SJohn Marino #define GMP_RNDZ MPFR_RNDZ 28144a238c70SJohn Marino #define GMP_RNDU MPFR_RNDU 28154a238c70SJohn Marino #define GMP_RNDD MPFR_RNDD 28164a238c70SJohn Marino The rounding mode "round away from zero" (`MPFR_RNDA') was added in 28174a238c70SJohn MarinoMPFR 3.0 (however no rounding mode `GMP_RNDA' exists). 28184a238c70SJohn Marino 28194a238c70SJohn Marino 28204a238c70SJohn MarinoFile: mpfr.info, Node: Added Functions, Next: Changed Functions, Prev: Type and Macro Changes, Up: API Compatibility 28214a238c70SJohn Marino 28224a238c70SJohn Marino6.2 Added Functions 28234a238c70SJohn Marino=================== 28244a238c70SJohn Marino 28254a238c70SJohn MarinoWe give here in alphabetical order the functions that were added after 28264a238c70SJohn MarinoMPFR 2.2, and in which MPFR version. 28274a238c70SJohn Marino 28284a238c70SJohn Marino * `mpfr_add_d' in MPFR 2.4. 28294a238c70SJohn Marino 28304a238c70SJohn Marino * `mpfr_ai' in MPFR 3.0 (incomplete, experimental). 28314a238c70SJohn Marino 28324a238c70SJohn Marino * `mpfr_asprintf' in MPFR 2.4. 28334a238c70SJohn Marino 28344a238c70SJohn Marino * `mpfr_buildopt_decimal_p' and `mpfr_buildopt_tls_p' in MPFR 3.0. 28354a238c70SJohn Marino 28364a238c70SJohn Marino * `mpfr_buildopt_gmpinternals_p' and `mpfr_buildopt_tune_case' in 28374a238c70SJohn Marino MPFR 3.1. 28384a238c70SJohn Marino 28394a238c70SJohn Marino * `mpfr_clear_divby0' in MPFR 3.1 (new divide-by-zero exception). 28404a238c70SJohn Marino 28414a238c70SJohn Marino * `mpfr_copysign' in MPFR 2.3. Note: MPFR 2.2 had a `mpfr_copysign' 28424a238c70SJohn Marino function that was available, but not documented, and with a slight 28434a238c70SJohn Marino difference in the semantics (when the second input operand is a 28444a238c70SJohn Marino NaN). 28454a238c70SJohn Marino 28464a238c70SJohn Marino * `mpfr_custom_get_significand' in MPFR 3.0. This function was 28474a238c70SJohn Marino named `mpfr_custom_get_mantissa' in previous versions; 28484a238c70SJohn Marino `mpfr_custom_get_mantissa' is still available via a macro in 28494a238c70SJohn Marino `mpfr.h': 28504a238c70SJohn Marino #define mpfr_custom_get_mantissa mpfr_custom_get_significand 28514a238c70SJohn Marino Thus code that needs to work with both MPFR 2.x and MPFR 3.x should 28524a238c70SJohn Marino use `mpfr_custom_get_mantissa'. 28534a238c70SJohn Marino 28544a238c70SJohn Marino * `mpfr_d_div' and `mpfr_d_sub' in MPFR 2.4. 28554a238c70SJohn Marino 28564a238c70SJohn Marino * `mpfr_digamma' in MPFR 3.0. 28574a238c70SJohn Marino 28584a238c70SJohn Marino * `mpfr_divby0_p' in MPFR 3.1 (new divide-by-zero exception). 28594a238c70SJohn Marino 28604a238c70SJohn Marino * `mpfr_div_d' in MPFR 2.4. 28614a238c70SJohn Marino 28624a238c70SJohn Marino * `mpfr_fmod' in MPFR 2.4. 28634a238c70SJohn Marino 28644a238c70SJohn Marino * `mpfr_fms' in MPFR 2.3. 28654a238c70SJohn Marino 28664a238c70SJohn Marino * `mpfr_fprintf' in MPFR 2.4. 28674a238c70SJohn Marino 28684a238c70SJohn Marino * `mpfr_frexp' in MPFR 3.1. 28694a238c70SJohn Marino 28704a238c70SJohn Marino * `mpfr_get_flt' in MPFR 3.0. 28714a238c70SJohn Marino 28724a238c70SJohn Marino * `mpfr_get_patches' in MPFR 2.3. 28734a238c70SJohn Marino 28744a238c70SJohn Marino * `mpfr_get_z_2exp' in MPFR 3.0. This function was named 28754a238c70SJohn Marino `mpfr_get_z_exp' in previous versions; `mpfr_get_z_exp' is still 28764a238c70SJohn Marino available via a macro in `mpfr.h': 28774a238c70SJohn Marino #define mpfr_get_z_exp mpfr_get_z_2exp 28784a238c70SJohn Marino Thus code that needs to work with both MPFR 2.x and MPFR 3.x should 28794a238c70SJohn Marino use `mpfr_get_z_exp'. 28804a238c70SJohn Marino 28814a238c70SJohn Marino * `mpfr_grandom' in MPFR 3.1. 28824a238c70SJohn Marino 28834a238c70SJohn Marino * `mpfr_j0', `mpfr_j1' and `mpfr_jn' in MPFR 2.3. 28844a238c70SJohn Marino 28854a238c70SJohn Marino * `mpfr_lgamma' in MPFR 2.3. 28864a238c70SJohn Marino 28874a238c70SJohn Marino * `mpfr_li2' in MPFR 2.4. 28884a238c70SJohn Marino 28894a238c70SJohn Marino * `mpfr_min_prec' in MPFR 3.0. 28904a238c70SJohn Marino 28914a238c70SJohn Marino * `mpfr_modf' in MPFR 2.4. 28924a238c70SJohn Marino 28934a238c70SJohn Marino * `mpfr_mul_d' in MPFR 2.4. 28944a238c70SJohn Marino 28954a238c70SJohn Marino * `mpfr_printf' in MPFR 2.4. 28964a238c70SJohn Marino 28974a238c70SJohn Marino * `mpfr_rec_sqrt' in MPFR 2.4. 28984a238c70SJohn Marino 28994a238c70SJohn Marino * `mpfr_regular_p' in MPFR 3.0. 29004a238c70SJohn Marino 29014a238c70SJohn Marino * `mpfr_remainder' and `mpfr_remquo' in MPFR 2.3. 29024a238c70SJohn Marino 29034a238c70SJohn Marino * `mpfr_set_divby0' in MPFR 3.1 (new divide-by-zero exception). 29044a238c70SJohn Marino 29054a238c70SJohn Marino * `mpfr_set_flt' in MPFR 3.0. 29064a238c70SJohn Marino 29074a238c70SJohn Marino * `mpfr_set_z_2exp' in MPFR 3.0. 29084a238c70SJohn Marino 29094a238c70SJohn Marino * `mpfr_set_zero' in MPFR 3.0. 29104a238c70SJohn Marino 29114a238c70SJohn Marino * `mpfr_setsign' in MPFR 2.3. 29124a238c70SJohn Marino 29134a238c70SJohn Marino * `mpfr_signbit' in MPFR 2.3. 29144a238c70SJohn Marino 29154a238c70SJohn Marino * `mpfr_sinh_cosh' in MPFR 2.4. 29164a238c70SJohn Marino 29174a238c70SJohn Marino * `mpfr_snprintf' and `mpfr_sprintf' in MPFR 2.4. 29184a238c70SJohn Marino 29194a238c70SJohn Marino * `mpfr_sub_d' in MPFR 2.4. 29204a238c70SJohn Marino 29214a238c70SJohn Marino * `mpfr_urandom' in MPFR 3.0. 29224a238c70SJohn Marino 29234a238c70SJohn Marino * `mpfr_vasprintf', `mpfr_vfprintf', `mpfr_vprintf', 29244a238c70SJohn Marino `mpfr_vsprintf' and `mpfr_vsnprintf' in MPFR 2.4. 29254a238c70SJohn Marino 29264a238c70SJohn Marino * `mpfr_y0', `mpfr_y1' and `mpfr_yn' in MPFR 2.3. 29274a238c70SJohn Marino 29284a238c70SJohn Marino * `mpfr_z_sub' in MPFR 3.1. 29294a238c70SJohn Marino 29304a238c70SJohn Marino 29314a238c70SJohn Marino 29324a238c70SJohn MarinoFile: mpfr.info, Node: Changed Functions, Next: Removed Functions, Prev: Added Functions, Up: API Compatibility 29334a238c70SJohn Marino 29344a238c70SJohn Marino6.3 Changed Functions 29354a238c70SJohn Marino===================== 29364a238c70SJohn Marino 29374a238c70SJohn MarinoThe following functions have changed after MPFR 2.2. Changes can affect 29384a238c70SJohn Marinothe behavior of code written for some MPFR version when built and run 29394a238c70SJohn Marinoagainst another MPFR version (older or newer), as described below. 29404a238c70SJohn Marino 29414a238c70SJohn Marino * `mpfr_check_range' changed in MPFR 2.3.2 and MPFR 2.4. If the 29424a238c70SJohn Marino value is an inexact infinity, the overflow flag is now set (in 29434a238c70SJohn Marino case it was lost), while it was previously left unchanged. This 29444a238c70SJohn Marino is really what is expected in practice (and what the MPFR code was 29454a238c70SJohn Marino expecting), so that the previous behavior was regarded as a bug. 29464a238c70SJohn Marino Hence the change in MPFR 2.3.2. 29474a238c70SJohn Marino 29484a238c70SJohn Marino * `mpfr_get_f' changed in MPFR 3.0. This function was returning 29494a238c70SJohn Marino zero, except for NaN and Inf, which do not exist in MPF. The 29504a238c70SJohn Marino _erange_ flag is now set in these cases, and `mpfr_get_f' now 29514a238c70SJohn Marino returns the usual ternary value. 29524a238c70SJohn Marino 29534a238c70SJohn Marino * `mpfr_get_si', `mpfr_get_sj', `mpfr_get_ui' and `mpfr_get_uj' 29544a238c70SJohn Marino changed in MPFR 3.0. In previous MPFR versions, the cases where 29554a238c70SJohn Marino the _erange_ flag is set were unspecified. 29564a238c70SJohn Marino 29574a238c70SJohn Marino * `mpfr_get_z' changed in MPFR 3.0. The return type was `void'; it 29584a238c70SJohn Marino is now `int', and the usual ternary value is returned. Thus 29594a238c70SJohn Marino programs that need to work with both MPFR 2.x and 3.x must not use 29604a238c70SJohn Marino the return value. Even in this case, C code using `mpfr_get_z' as 29614a238c70SJohn Marino the second or third term of a conditional operator may also be 29624a238c70SJohn Marino affected. For instance, the following is correct with MPFR 3.0, 29634a238c70SJohn Marino but not with MPFR 2.x: 29644a238c70SJohn Marino bool ? mpfr_get_z(...) : mpfr_add(...); 29654a238c70SJohn Marino On the other hand, the following is correct with MPFR 2.x, but not 29664a238c70SJohn Marino with MPFR 3.0: 29674a238c70SJohn Marino bool ? mpfr_get_z(...) : (void) mpfr_add(...); 29684a238c70SJohn Marino Portable code should cast `mpfr_get_z(...)' to `void' to use the 29694a238c70SJohn Marino type `void' for both terms of the conditional operator, as in: 29704a238c70SJohn Marino bool ? (void) mpfr_get_z(...) : (void) mpfr_add(...); 29714a238c70SJohn Marino Alternatively, `if ... else' can be used instead of the 29724a238c70SJohn Marino conditional operator. 29734a238c70SJohn Marino 29744a238c70SJohn Marino Moreover the cases where the _erange_ flag is set were unspecified 29754a238c70SJohn Marino in MPFR 2.x. 29764a238c70SJohn Marino 29774a238c70SJohn Marino * `mpfr_get_z_exp' changed in MPFR 3.0. In previous MPFR versions, 29784a238c70SJohn Marino the cases where the _erange_ flag is set were unspecified. Note: 29794a238c70SJohn Marino this function has been renamed to `mpfr_get_z_2exp' in MPFR 3.0, 29804a238c70SJohn Marino but `mpfr_get_z_exp' is still available for compatibility reasons. 29814a238c70SJohn Marino 29824a238c70SJohn Marino * `mpfr_strtofr' changed in MPFR 2.3.1 and MPFR 2.4. This was 29834a238c70SJohn Marino actually a bug fix since the code and the documentation did not 29844a238c70SJohn Marino match. But both were changed in order to have a more consistent 29854a238c70SJohn Marino and useful behavior. The main changes in the code are as follows. 29864a238c70SJohn Marino The binary exponent is now accepted even without the `0b' or `0x' 29874a238c70SJohn Marino prefix. Data corresponding to NaN can now have an optional sign 29884a238c70SJohn Marino (such data were previously invalid). 29894a238c70SJohn Marino 29904a238c70SJohn Marino * `mpfr_strtofr' changed in MPFR 3.0. This function now accepts 29914a238c70SJohn Marino bases from 37 to 62 (no changes for the other bases). Note: if an 29924a238c70SJohn Marino unsupported base is provided to this function, the behavior is 29934a238c70SJohn Marino undefined; more precisely, in MPFR 2.3.1 and later, providing an 29944a238c70SJohn Marino unsupported base yields an assertion failure (this behavior may 29954a238c70SJohn Marino change in the future). 29964a238c70SJohn Marino 29974a238c70SJohn Marino * `mpfr_subnormalize' changed in MPFR 3.1. This was actually 29984a238c70SJohn Marino regarded as a bug fix. The `mpfr_subnormalize' implementation up 29994a238c70SJohn Marino to MPFR 3.0.0 did not change the flags. In particular, it did not 30004a238c70SJohn Marino follow the generic rule concerning the inexact flag (and no 30014a238c70SJohn Marino special behavior was specified). The case of the underflow flag 30024a238c70SJohn Marino was more a lack of specification. 30034a238c70SJohn Marino 30044a238c70SJohn Marino * `mpfr_urandom' and `mpfr_urandomb' changed in MPFR 3.1. Their 30054a238c70SJohn Marino behavior no longer depends on the platform (assuming this is also 3006*ab6d115fSJohn Marino true for GMP's random generator, which is not the case between GMP 3007*ab6d115fSJohn Marino 4.1 and 4.2 if `gmp_randinit_default' is used). As a consequence, 3008*ab6d115fSJohn Marino the returned values can be different between MPFR 3.1 and previous 3009*ab6d115fSJohn Marino MPFR versions. Note: as the reproducibility of these functions 3010*ab6d115fSJohn Marino was not specified before MPFR 3.1, the MPFR 3.1 behavior is _not_ 3011*ab6d115fSJohn Marino regarded as backward incompatible with previous versions. 30124a238c70SJohn Marino 30134a238c70SJohn Marino 30144a238c70SJohn Marino 30154a238c70SJohn MarinoFile: mpfr.info, Node: Removed Functions, Next: Other Changes, Prev: Changed Functions, Up: API Compatibility 30164a238c70SJohn Marino 30174a238c70SJohn Marino6.4 Removed Functions 30184a238c70SJohn Marino===================== 30194a238c70SJohn Marino 30204a238c70SJohn MarinoFunctions `mpfr_random' and `mpfr_random2' have been removed in MPFR 30214a238c70SJohn Marino3.0 (this only affects old code built against MPFR 3.0 or later). (The 30224a238c70SJohn Marinofunction `mpfr_random' had been deprecated since at least MPFR 2.2.0, 30234a238c70SJohn Marinoand `mpfr_random2' since MPFR 2.4.0.) 30244a238c70SJohn Marino 30254a238c70SJohn Marino 30264a238c70SJohn MarinoFile: mpfr.info, Node: Other Changes, Prev: Removed Functions, Up: API Compatibility 30274a238c70SJohn Marino 30284a238c70SJohn Marino6.5 Other Changes 30294a238c70SJohn Marino================= 30304a238c70SJohn Marino 30314a238c70SJohn MarinoFor users of a C++ compiler, the way how the availability of `intmax_t' 30324a238c70SJohn Marinois detected has changed in MPFR 3.0. In MPFR 2.x, if a macro 30334a238c70SJohn Marino`INTMAX_C' or `UINTMAX_C' was defined (e.g. when the 30344a238c70SJohn Marino`__STDC_CONSTANT_MACROS' macro had been defined before `<stdint.h>' or 30354a238c70SJohn Marino`<inttypes.h>' has been included), `intmax_t' was assumed to be defined. 30364a238c70SJohn MarinoHowever this was not always the case (more precisely, `intmax_t' can be 30374a238c70SJohn Marinodefined only in the namespace `std', as with Boost), so that 30384a238c70SJohn Marinocompilations could fail. Thus the check for `INTMAX_C' or `UINTMAX_C' 30394a238c70SJohn Marinois now disabled for C++ compilers, with the following consequences: 30404a238c70SJohn Marino 30414a238c70SJohn Marino * Programs written for MPFR 2.x that need `intmax_t' may no longer 30424a238c70SJohn Marino be compiled against MPFR 3.0: a `#define MPFR_USE_INTMAX_T' may be 30434a238c70SJohn Marino necessary before `mpfr.h' is included. 30444a238c70SJohn Marino 30454a238c70SJohn Marino * The compilation of programs that work with MPFR 3.0 may fail with 30464a238c70SJohn Marino MPFR 2.x due to the problem described above. Workarounds are 30474a238c70SJohn Marino possible, such as defining `intmax_t' and `uintmax_t' in the global 30484a238c70SJohn Marino namespace, though this is not clean. 30494a238c70SJohn Marino 30504a238c70SJohn Marino 30514a238c70SJohn Marino The divide-by-zero exception is new in MPFR 3.1. However it should 30524a238c70SJohn Marinonot introduce incompatible changes for programs that strictly follow 30534a238c70SJohn Marinothe MPFR API since the exception can only be seen via new functions. 30544a238c70SJohn Marino 30554a238c70SJohn Marino As of MPFR 3.1, the `mpfr.h' header can be included several times, 30564a238c70SJohn Marinowhile still supporting optional functions (*note Headers and 30574a238c70SJohn MarinoLibraries::). 30584a238c70SJohn Marino 30594a238c70SJohn Marino 30604a238c70SJohn MarinoFile: mpfr.info, Node: Contributors, Next: References, Prev: API Compatibility, Up: Top 30614a238c70SJohn Marino 30624a238c70SJohn MarinoContributors 30634a238c70SJohn Marino************ 30644a238c70SJohn Marino 30654a238c70SJohn MarinoThe main developers of MPFR are Guillaume Hanrot, Vincent Lefèvre, 30664a238c70SJohn MarinoPatrick Pélissier, Philippe Théveny and Paul Zimmermann. 30674a238c70SJohn Marino 30684a238c70SJohn Marino Sylvie Boldo from ENS-Lyon, France, contributed the functions 30694a238c70SJohn Marino`mpfr_agm' and `mpfr_log'. Sylvain Chevillard contributed the 30704a238c70SJohn Marino`mpfr_ai' function. David Daney contributed the hyperbolic and inverse 30714a238c70SJohn Marinohyperbolic functions, the base-2 exponential, and the factorial 30724a238c70SJohn Marinofunction. Alain Delplanque contributed the new version of the 30734a238c70SJohn Marino`mpfr_get_str' function. Mathieu Dutour contributed the functions 30744a238c70SJohn Marino`mpfr_acos', `mpfr_asin' and `mpfr_atan', and a previous version of 30754a238c70SJohn Marino`mpfr_gamma'. Laurent Fousse contributed the `mpfr_sum' function. 30764a238c70SJohn MarinoEmmanuel Jeandel, from ENS-Lyon too, contributed the generic 30774a238c70SJohn Marinohypergeometric code, as well as the internal function `mpfr_exp3', a 30784a238c70SJohn Marinofirst implementation of the sine and cosine, and improved versions of 30794a238c70SJohn Marino`mpfr_const_log2' and `mpfr_const_pi'. Ludovic Meunier helped in the 30804a238c70SJohn Marinodesign of the `mpfr_erf' code. Jean-Luc Rémy contributed the 30814a238c70SJohn Marino`mpfr_zeta' code. Fabrice Rouillier contributed the `mpfr_xxx_z' and 30824a238c70SJohn Marino`mpfr_xxx_q' functions, and helped to the Microsoft Windows porting. 30834a238c70SJohn MarinoDamien Stehlé contributed the `mpfr_get_ld_2exp' function. 30844a238c70SJohn Marino 30854a238c70SJohn Marino We would like to thank Jean-Michel Muller and Joris van der Hoeven 30864a238c70SJohn Marinofor very fruitful discussions at the beginning of that project, 30874a238c70SJohn MarinoTorbjörn Granlund and Kevin Ryde for their help about design issues, 30884a238c70SJohn Marinoand Nathalie Revol for her careful reading of a previous version of 30894a238c70SJohn Marinothis documentation. In particular Kevin Ryde did a tremendous job for 30904a238c70SJohn Marinothe portability of MPFR in 2002-2004. 30914a238c70SJohn Marino 30924a238c70SJohn Marino The development of the MPFR library would not have been possible 30934a238c70SJohn Marinowithout the continuous support of INRIA, and of the LORIA (Nancy, 30944a238c70SJohn MarinoFrance) and LIP (Lyon, France) laboratories. In particular the main 30954a238c70SJohn Marinoauthors were or are members of the PolKA, Spaces, Cacao and Caramel 3096*ab6d115fSJohn Marinoproject-teams at LORIA and of the Arénaire and AriC project-teams at 3097*ab6d115fSJohn MarinoLIP. This project was started during the Fiable (reliable in French) 3098*ab6d115fSJohn Marinoaction supported by INRIA, and continued during the AOC action. The 30994a238c70SJohn Marinodevelopment of MPFR was also supported by a grant (202F0659 00 MPN 121) 31004a238c70SJohn Marinofrom the Conseil Régional de Lorraine in 2002, from INRIA by an 31014a238c70SJohn Marino"associate engineer" grant (2003-2005), an "opération de développement 31024a238c70SJohn Marinologiciel" grant (2007-2009), and the post-doctoral grant of Sylvain 3103*ab6d115fSJohn MarinoChevillard in 2009-2010. The MPFR-MPC workshop in June 2012 was partly 3104*ab6d115fSJohn Marinosupported by the ERC grant ANTICS of Andreas Enge. 31054a238c70SJohn Marino 31064a238c70SJohn Marino 31074a238c70SJohn MarinoFile: mpfr.info, Node: References, Next: GNU Free Documentation License, Prev: Contributors, Up: Top 31084a238c70SJohn Marino 31094a238c70SJohn MarinoReferences 31104a238c70SJohn Marino********** 31114a238c70SJohn Marino 31124a238c70SJohn Marino * Richard Brent and Paul Zimmermann, "Modern Computer Arithmetic", 31134a238c70SJohn Marino Cambridge University Press (to appear), also available from the 31144a238c70SJohn Marino authors' web pages. 31154a238c70SJohn Marino 31164a238c70SJohn Marino * Laurent Fousse, Guillaume Hanrot, Vincent Lefèvre, Patrick 31174a238c70SJohn Marino Pélissier and Paul Zimmermann, "MPFR: A Multiple-Precision Binary 31184a238c70SJohn Marino Floating-Point Library With Correct Rounding", ACM Transactions on 31194a238c70SJohn Marino Mathematical Software, volume 33, issue 2, article 13, 15 pages, 31204a238c70SJohn Marino 2007, `http://doi.acm.org/10.1145/1236463.1236468'. 31214a238c70SJohn Marino 31224a238c70SJohn Marino * Torbjörn Granlund, "GNU MP: The GNU Multiple Precision Arithmetic 31234a238c70SJohn Marino Library", version 5.0.1, 2010, `http://gmplib.org'. 31244a238c70SJohn Marino 31254a238c70SJohn Marino * IEEE standard for binary floating-point arithmetic, Technical 31264a238c70SJohn Marino Report ANSI-IEEE Standard 754-1985, New York, 1985. Approved 31274a238c70SJohn Marino March 21, 1985: IEEE Standards Board; approved July 26, 1985: 31284a238c70SJohn Marino American National Standards Institute, 18 pages. 31294a238c70SJohn Marino 31304a238c70SJohn Marino * IEEE Standard for Floating-Point Arithmetic, ANSI-IEEE Standard 31314a238c70SJohn Marino 754-2008, 2008. Revision of ANSI-IEEE Standard 754-1985, approved 31324a238c70SJohn Marino June 12, 2008: IEEE Standards Board, 70 pages. 31334a238c70SJohn Marino 31344a238c70SJohn Marino * Donald E. Knuth, "The Art of Computer Programming", vol 2, 31354a238c70SJohn Marino "Seminumerical Algorithms", 2nd edition, Addison-Wesley, 1981. 31364a238c70SJohn Marino 31374a238c70SJohn Marino * Jean-Michel Muller, "Elementary Functions, Algorithms and 31384a238c70SJohn Marino Implementation", Birkhäuser, Boston, 2nd edition, 2006. 31394a238c70SJohn Marino 31404a238c70SJohn Marino * Jean-Michel Muller, Nicolas Brisebarre, Florent de Dinechin, 31414a238c70SJohn Marino Claude-Pierre Jeannerod, Vincent Lefèvre, Guillaume Melquiond, 31424a238c70SJohn Marino Nathalie Revol, Damien Stehlé and Serge Torrès, "Handbook of 31434a238c70SJohn Marino Floating-Point Arithmetic", Birkhäuser, Boston, 2009. 31444a238c70SJohn Marino 31454a238c70SJohn Marino 31464a238c70SJohn Marino 31474a238c70SJohn MarinoFile: mpfr.info, Node: GNU Free Documentation License, Next: Concept Index, Prev: References, Up: Top 31484a238c70SJohn Marino 31494a238c70SJohn MarinoAppendix A GNU Free Documentation License 31504a238c70SJohn Marino***************************************** 31514a238c70SJohn Marino 31524a238c70SJohn Marino Version 1.2, November 2002 31534a238c70SJohn Marino 31544a238c70SJohn Marino Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. 31554a238c70SJohn Marino 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 31564a238c70SJohn Marino 31574a238c70SJohn Marino Everyone is permitted to copy and distribute verbatim copies 31584a238c70SJohn Marino of this license document, but changing it is not allowed. 31594a238c70SJohn Marino 31604a238c70SJohn Marino 0. PREAMBLE 31614a238c70SJohn Marino 31624a238c70SJohn Marino The purpose of this License is to make a manual, textbook, or other 31634a238c70SJohn Marino functional and useful document "free" in the sense of freedom: to 31644a238c70SJohn Marino assure everyone the effective freedom to copy and redistribute it, 31654a238c70SJohn Marino with or without modifying it, either commercially or 31664a238c70SJohn Marino noncommercially. Secondarily, this License preserves for the 31674a238c70SJohn Marino author and publisher a way to get credit for their work, while not 31684a238c70SJohn Marino being considered responsible for modifications made by others. 31694a238c70SJohn Marino 31704a238c70SJohn Marino This License is a kind of "copyleft", which means that derivative 31714a238c70SJohn Marino works of the document must themselves be free in the same sense. 31724a238c70SJohn Marino It complements the GNU General Public License, which is a copyleft 31734a238c70SJohn Marino license designed for free software. 31744a238c70SJohn Marino 31754a238c70SJohn Marino We have designed this License in order to use it for manuals for 31764a238c70SJohn Marino free software, because free software needs free documentation: a 31774a238c70SJohn Marino free program should come with manuals providing the same freedoms 31784a238c70SJohn Marino that the software does. But this License is not limited to 31794a238c70SJohn Marino software manuals; it can be used for any textual work, regardless 31804a238c70SJohn Marino of subject matter or whether it is published as a printed book. 31814a238c70SJohn Marino We recommend this License principally for works whose purpose is 31824a238c70SJohn Marino instruction or reference. 31834a238c70SJohn Marino 31844a238c70SJohn Marino 1. APPLICABILITY AND DEFINITIONS 31854a238c70SJohn Marino 31864a238c70SJohn Marino This License applies to any manual or other work, in any medium, 31874a238c70SJohn Marino that contains a notice placed by the copyright holder saying it 31884a238c70SJohn Marino can be distributed under the terms of this License. Such a notice 31894a238c70SJohn Marino grants a world-wide, royalty-free license, unlimited in duration, 31904a238c70SJohn Marino to use that work under the conditions stated herein. The 31914a238c70SJohn Marino "Document", below, refers to any such manual or work. Any member 31924a238c70SJohn Marino of the public is a licensee, and is addressed as "you". You 31934a238c70SJohn Marino accept the license if you copy, modify or distribute the work in a 31944a238c70SJohn Marino way requiring permission under copyright law. 31954a238c70SJohn Marino 31964a238c70SJohn Marino A "Modified Version" of the Document means any work containing the 31974a238c70SJohn Marino Document or a portion of it, either copied verbatim, or with 31984a238c70SJohn Marino modifications and/or translated into another language. 31994a238c70SJohn Marino 32004a238c70SJohn Marino A "Secondary Section" is a named appendix or a front-matter section 32014a238c70SJohn Marino of the Document that deals exclusively with the relationship of the 32024a238c70SJohn Marino publishers or authors of the Document to the Document's overall 32034a238c70SJohn Marino subject (or to related matters) and contains nothing that could 32044a238c70SJohn Marino fall directly within that overall subject. (Thus, if the Document 32054a238c70SJohn Marino is in part a textbook of mathematics, a Secondary Section may not 32064a238c70SJohn Marino explain any mathematics.) The relationship could be a matter of 32074a238c70SJohn Marino historical connection with the subject or with related matters, or 32084a238c70SJohn Marino of legal, commercial, philosophical, ethical or political position 32094a238c70SJohn Marino regarding them. 32104a238c70SJohn Marino 32114a238c70SJohn Marino The "Invariant Sections" are certain Secondary Sections whose 32124a238c70SJohn Marino titles are designated, as being those of Invariant Sections, in 32134a238c70SJohn Marino the notice that says that the Document is released under this 32144a238c70SJohn Marino License. If a section does not fit the above definition of 32154a238c70SJohn Marino Secondary then it is not allowed to be designated as Invariant. 32164a238c70SJohn Marino The Document may contain zero Invariant Sections. If the Document 32174a238c70SJohn Marino does not identify any Invariant Sections then there are none. 32184a238c70SJohn Marino 32194a238c70SJohn Marino The "Cover Texts" are certain short passages of text that are 32204a238c70SJohn Marino listed, as Front-Cover Texts or Back-Cover Texts, in the notice 32214a238c70SJohn Marino that says that the Document is released under this License. A 32224a238c70SJohn Marino Front-Cover Text may be at most 5 words, and a Back-Cover Text may 32234a238c70SJohn Marino be at most 25 words. 32244a238c70SJohn Marino 32254a238c70SJohn Marino A "Transparent" copy of the Document means a machine-readable copy, 32264a238c70SJohn Marino represented in a format whose specification is available to the 32274a238c70SJohn Marino general public, that is suitable for revising the document 32284a238c70SJohn Marino straightforwardly with generic text editors or (for images 32294a238c70SJohn Marino composed of pixels) generic paint programs or (for drawings) some 32304a238c70SJohn Marino widely available drawing editor, and that is suitable for input to 32314a238c70SJohn Marino text formatters or for automatic translation to a variety of 32324a238c70SJohn Marino formats suitable for input to text formatters. A copy made in an 32334a238c70SJohn Marino otherwise Transparent file format whose markup, or absence of 32344a238c70SJohn Marino markup, has been arranged to thwart or discourage subsequent 32354a238c70SJohn Marino modification by readers is not Transparent. An image format is 32364a238c70SJohn Marino not Transparent if used for any substantial amount of text. A 32374a238c70SJohn Marino copy that is not "Transparent" is called "Opaque". 32384a238c70SJohn Marino 32394a238c70SJohn Marino Examples of suitable formats for Transparent copies include plain 32404a238c70SJohn Marino ASCII without markup, Texinfo input format, LaTeX input format, 32414a238c70SJohn Marino SGML or XML using a publicly available DTD, and 32424a238c70SJohn Marino standard-conforming simple HTML, PostScript or PDF designed for 32434a238c70SJohn Marino human modification. Examples of transparent image formats include 32444a238c70SJohn Marino PNG, XCF and JPG. Opaque formats include proprietary formats that 32454a238c70SJohn Marino can be read and edited only by proprietary word processors, SGML or 32464a238c70SJohn Marino XML for which the DTD and/or processing tools are not generally 32474a238c70SJohn Marino available, and the machine-generated HTML, PostScript or PDF 32484a238c70SJohn Marino produced by some word processors for output purposes only. 32494a238c70SJohn Marino 32504a238c70SJohn Marino The "Title Page" means, for a printed book, the title page itself, 32514a238c70SJohn Marino plus such following pages as are needed to hold, legibly, the 32524a238c70SJohn Marino material this License requires to appear in the title page. For 32534a238c70SJohn Marino works in formats which do not have any title page as such, "Title 32544a238c70SJohn Marino Page" means the text near the most prominent appearance of the 32554a238c70SJohn Marino work's title, preceding the beginning of the body of the text. 32564a238c70SJohn Marino 32574a238c70SJohn Marino A section "Entitled XYZ" means a named subunit of the Document 32584a238c70SJohn Marino whose title either is precisely XYZ or contains XYZ in parentheses 32594a238c70SJohn Marino following text that translates XYZ in another language. (Here XYZ 32604a238c70SJohn Marino stands for a specific section name mentioned below, such as 32614a238c70SJohn Marino "Acknowledgements", "Dedications", "Endorsements", or "History".) 32624a238c70SJohn Marino To "Preserve the Title" of such a section when you modify the 32634a238c70SJohn Marino Document means that it remains a section "Entitled XYZ" according 32644a238c70SJohn Marino to this definition. 32654a238c70SJohn Marino 32664a238c70SJohn Marino The Document may include Warranty Disclaimers next to the notice 32674a238c70SJohn Marino which states that this License applies to the Document. These 32684a238c70SJohn Marino Warranty Disclaimers are considered to be included by reference in 32694a238c70SJohn Marino this License, but only as regards disclaiming warranties: any other 32704a238c70SJohn Marino implication that these Warranty Disclaimers may have is void and 32714a238c70SJohn Marino has no effect on the meaning of this License. 32724a238c70SJohn Marino 32734a238c70SJohn Marino 2. VERBATIM COPYING 32744a238c70SJohn Marino 32754a238c70SJohn Marino You may copy and distribute the Document in any medium, either 32764a238c70SJohn Marino commercially or noncommercially, provided that this License, the 32774a238c70SJohn Marino copyright notices, and the license notice saying this License 32784a238c70SJohn Marino applies to the Document are reproduced in all copies, and that you 32794a238c70SJohn Marino add no other conditions whatsoever to those of this License. You 32804a238c70SJohn Marino may not use technical measures to obstruct or control the reading 32814a238c70SJohn Marino or further copying of the copies you make or distribute. However, 32824a238c70SJohn Marino you may accept compensation in exchange for copies. If you 32834a238c70SJohn Marino distribute a large enough number of copies you must also follow 32844a238c70SJohn Marino the conditions in section 3. 32854a238c70SJohn Marino 32864a238c70SJohn Marino You may also lend copies, under the same conditions stated above, 32874a238c70SJohn Marino and you may publicly display copies. 32884a238c70SJohn Marino 32894a238c70SJohn Marino 3. COPYING IN QUANTITY 32904a238c70SJohn Marino 32914a238c70SJohn Marino If you publish printed copies (or copies in media that commonly 32924a238c70SJohn Marino have printed covers) of the Document, numbering more than 100, and 32934a238c70SJohn Marino the Document's license notice requires Cover Texts, you must 32944a238c70SJohn Marino enclose the copies in covers that carry, clearly and legibly, all 32954a238c70SJohn Marino these Cover Texts: Front-Cover Texts on the front cover, and 32964a238c70SJohn Marino Back-Cover Texts on the back cover. Both covers must also clearly 32974a238c70SJohn Marino and legibly identify you as the publisher of these copies. The 32984a238c70SJohn Marino front cover must present the full title with all words of the 32994a238c70SJohn Marino title equally prominent and visible. You may add other material 33004a238c70SJohn Marino on the covers in addition. Copying with changes limited to the 33014a238c70SJohn Marino covers, as long as they preserve the title of the Document and 33024a238c70SJohn Marino satisfy these conditions, can be treated as verbatim copying in 33034a238c70SJohn Marino other respects. 33044a238c70SJohn Marino 33054a238c70SJohn Marino If the required texts for either cover are too voluminous to fit 33064a238c70SJohn Marino legibly, you should put the first ones listed (as many as fit 33074a238c70SJohn Marino reasonably) on the actual cover, and continue the rest onto 33084a238c70SJohn Marino adjacent pages. 33094a238c70SJohn Marino 33104a238c70SJohn Marino If you publish or distribute Opaque copies of the Document 33114a238c70SJohn Marino numbering more than 100, you must either include a 33124a238c70SJohn Marino machine-readable Transparent copy along with each Opaque copy, or 33134a238c70SJohn Marino state in or with each Opaque copy a computer-network location from 33144a238c70SJohn Marino which the general network-using public has access to download 33154a238c70SJohn Marino using public-standard network protocols a complete Transparent 33164a238c70SJohn Marino copy of the Document, free of added material. If you use the 33174a238c70SJohn Marino latter option, you must take reasonably prudent steps, when you 33184a238c70SJohn Marino begin distribution of Opaque copies in quantity, to ensure that 33194a238c70SJohn Marino this Transparent copy will remain thus accessible at the stated 33204a238c70SJohn Marino location until at least one year after the last time you 33214a238c70SJohn Marino distribute an Opaque copy (directly or through your agents or 33224a238c70SJohn Marino retailers) of that edition to the public. 33234a238c70SJohn Marino 33244a238c70SJohn Marino It is requested, but not required, that you contact the authors of 33254a238c70SJohn Marino the Document well before redistributing any large number of 33264a238c70SJohn Marino copies, to give them a chance to provide you with an updated 33274a238c70SJohn Marino version of the Document. 33284a238c70SJohn Marino 33294a238c70SJohn Marino 4. MODIFICATIONS 33304a238c70SJohn Marino 33314a238c70SJohn Marino You may copy and distribute a Modified Version of the Document 33324a238c70SJohn Marino under the conditions of sections 2 and 3 above, provided that you 33334a238c70SJohn Marino release the Modified Version under precisely this License, with 33344a238c70SJohn Marino the Modified Version filling the role of the Document, thus 33354a238c70SJohn Marino licensing distribution and modification of the Modified Version to 33364a238c70SJohn Marino whoever possesses a copy of it. In addition, you must do these 33374a238c70SJohn Marino things in the Modified Version: 33384a238c70SJohn Marino 33394a238c70SJohn Marino A. Use in the Title Page (and on the covers, if any) a title 33404a238c70SJohn Marino distinct from that of the Document, and from those of 33414a238c70SJohn Marino previous versions (which should, if there were any, be listed 33424a238c70SJohn Marino in the History section of the Document). You may use the 33434a238c70SJohn Marino same title as a previous version if the original publisher of 33444a238c70SJohn Marino that version gives permission. 33454a238c70SJohn Marino 33464a238c70SJohn Marino B. List on the Title Page, as authors, one or more persons or 33474a238c70SJohn Marino entities responsible for authorship of the modifications in 33484a238c70SJohn Marino the Modified Version, together with at least five of the 33494a238c70SJohn Marino principal authors of the Document (all of its principal 33504a238c70SJohn Marino authors, if it has fewer than five), unless they release you 33514a238c70SJohn Marino from this requirement. 33524a238c70SJohn Marino 33534a238c70SJohn Marino C. State on the Title page the name of the publisher of the 33544a238c70SJohn Marino Modified Version, as the publisher. 33554a238c70SJohn Marino 33564a238c70SJohn Marino D. Preserve all the copyright notices of the Document. 33574a238c70SJohn Marino 33584a238c70SJohn Marino E. Add an appropriate copyright notice for your modifications 33594a238c70SJohn Marino adjacent to the other copyright notices. 33604a238c70SJohn Marino 33614a238c70SJohn Marino F. Include, immediately after the copyright notices, a license 33624a238c70SJohn Marino notice giving the public permission to use the Modified 33634a238c70SJohn Marino Version under the terms of this License, in the form shown in 33644a238c70SJohn Marino the Addendum below. 33654a238c70SJohn Marino 33664a238c70SJohn Marino G. Preserve in that license notice the full lists of Invariant 33674a238c70SJohn Marino Sections and required Cover Texts given in the Document's 33684a238c70SJohn Marino license notice. 33694a238c70SJohn Marino 33704a238c70SJohn Marino H. Include an unaltered copy of this License. 33714a238c70SJohn Marino 33724a238c70SJohn Marino I. Preserve the section Entitled "History", Preserve its Title, 33734a238c70SJohn Marino and add to it an item stating at least the title, year, new 33744a238c70SJohn Marino authors, and publisher of the Modified Version as given on 33754a238c70SJohn Marino the Title Page. If there is no section Entitled "History" in 33764a238c70SJohn Marino the Document, create one stating the title, year, authors, 33774a238c70SJohn Marino and publisher of the Document as given on its Title Page, 33784a238c70SJohn Marino then add an item describing the Modified Version as stated in 33794a238c70SJohn Marino the previous sentence. 33804a238c70SJohn Marino 33814a238c70SJohn Marino J. Preserve the network location, if any, given in the Document 33824a238c70SJohn Marino for public access to a Transparent copy of the Document, and 33834a238c70SJohn Marino likewise the network locations given in the Document for 33844a238c70SJohn Marino previous versions it was based on. These may be placed in 33854a238c70SJohn Marino the "History" section. You may omit a network location for a 33864a238c70SJohn Marino work that was published at least four years before the 33874a238c70SJohn Marino Document itself, or if the original publisher of the version 33884a238c70SJohn Marino it refers to gives permission. 33894a238c70SJohn Marino 33904a238c70SJohn Marino K. For any section Entitled "Acknowledgements" or "Dedications", 33914a238c70SJohn Marino Preserve the Title of the section, and preserve in the 33924a238c70SJohn Marino section all the substance and tone of each of the contributor 33934a238c70SJohn Marino acknowledgements and/or dedications given therein. 33944a238c70SJohn Marino 33954a238c70SJohn Marino L. Preserve all the Invariant Sections of the Document, 33964a238c70SJohn Marino unaltered in their text and in their titles. Section numbers 33974a238c70SJohn Marino or the equivalent are not considered part of the section 33984a238c70SJohn Marino titles. 33994a238c70SJohn Marino 34004a238c70SJohn Marino M. Delete any section Entitled "Endorsements". Such a section 34014a238c70SJohn Marino may not be included in the Modified Version. 34024a238c70SJohn Marino 34034a238c70SJohn Marino N. Do not retitle any existing section to be Entitled 34044a238c70SJohn Marino "Endorsements" or to conflict in title with any Invariant 34054a238c70SJohn Marino Section. 34064a238c70SJohn Marino 34074a238c70SJohn Marino O. Preserve any Warranty Disclaimers. 34084a238c70SJohn Marino 34094a238c70SJohn Marino If the Modified Version includes new front-matter sections or 34104a238c70SJohn Marino appendices that qualify as Secondary Sections and contain no 34114a238c70SJohn Marino material copied from the Document, you may at your option 34124a238c70SJohn Marino designate some or all of these sections as invariant. To do this, 34134a238c70SJohn Marino add their titles to the list of Invariant Sections in the Modified 34144a238c70SJohn Marino Version's license notice. These titles must be distinct from any 34154a238c70SJohn Marino other section titles. 34164a238c70SJohn Marino 34174a238c70SJohn Marino You may add a section Entitled "Endorsements", provided it contains 34184a238c70SJohn Marino nothing but endorsements of your Modified Version by various 34194a238c70SJohn Marino parties--for example, statements of peer review or that the text 34204a238c70SJohn Marino has been approved by an organization as the authoritative 34214a238c70SJohn Marino definition of a standard. 34224a238c70SJohn Marino 34234a238c70SJohn Marino You may add a passage of up to five words as a Front-Cover Text, 34244a238c70SJohn Marino and a passage of up to 25 words as a Back-Cover Text, to the end 34254a238c70SJohn Marino of the list of Cover Texts in the Modified Version. Only one 34264a238c70SJohn Marino passage of Front-Cover Text and one of Back-Cover Text may be 34274a238c70SJohn Marino added by (or through arrangements made by) any one entity. If the 34284a238c70SJohn Marino Document already includes a cover text for the same cover, 34294a238c70SJohn Marino previously added by you or by arrangement made by the same entity 34304a238c70SJohn Marino you are acting on behalf of, you may not add another; but you may 34314a238c70SJohn Marino replace the old one, on explicit permission from the previous 34324a238c70SJohn Marino publisher that added the old one. 34334a238c70SJohn Marino 34344a238c70SJohn Marino The author(s) and publisher(s) of the Document do not by this 34354a238c70SJohn Marino License give permission to use their names for publicity for or to 34364a238c70SJohn Marino assert or imply endorsement of any Modified Version. 34374a238c70SJohn Marino 34384a238c70SJohn Marino 5. COMBINING DOCUMENTS 34394a238c70SJohn Marino 34404a238c70SJohn Marino You may combine the Document with other documents released under 34414a238c70SJohn Marino this License, under the terms defined in section 4 above for 34424a238c70SJohn Marino modified versions, provided that you include in the combination 34434a238c70SJohn Marino all of the Invariant Sections of all of the original documents, 34444a238c70SJohn Marino unmodified, and list them all as Invariant Sections of your 34454a238c70SJohn Marino combined work in its license notice, and that you preserve all 34464a238c70SJohn Marino their Warranty Disclaimers. 34474a238c70SJohn Marino 34484a238c70SJohn Marino The combined work need only contain one copy of this License, and 34494a238c70SJohn Marino multiple identical Invariant Sections may be replaced with a single 34504a238c70SJohn Marino copy. If there are multiple Invariant Sections with the same name 34514a238c70SJohn Marino but different contents, make the title of each such section unique 34524a238c70SJohn Marino by adding at the end of it, in parentheses, the name of the 34534a238c70SJohn Marino original author or publisher of that section if known, or else a 34544a238c70SJohn Marino unique number. Make the same adjustment to the section titles in 34554a238c70SJohn Marino the list of Invariant Sections in the license notice of the 34564a238c70SJohn Marino combined work. 34574a238c70SJohn Marino 34584a238c70SJohn Marino In the combination, you must combine any sections Entitled 34594a238c70SJohn Marino "History" in the various original documents, forming one section 34604a238c70SJohn Marino Entitled "History"; likewise combine any sections Entitled 34614a238c70SJohn Marino "Acknowledgements", and any sections Entitled "Dedications". You 34624a238c70SJohn Marino must delete all sections Entitled "Endorsements." 34634a238c70SJohn Marino 34644a238c70SJohn Marino 6. COLLECTIONS OF DOCUMENTS 34654a238c70SJohn Marino 34664a238c70SJohn Marino You may make a collection consisting of the Document and other 34674a238c70SJohn Marino documents released under this License, and replace the individual 34684a238c70SJohn Marino copies of this License in the various documents with a single copy 34694a238c70SJohn Marino that is included in the collection, provided that you follow the 34704a238c70SJohn Marino rules of this License for verbatim copying of each of the 34714a238c70SJohn Marino documents in all other respects. 34724a238c70SJohn Marino 34734a238c70SJohn Marino You may extract a single document from such a collection, and 34744a238c70SJohn Marino distribute it individually under this License, provided you insert 34754a238c70SJohn Marino a copy of this License into the extracted document, and follow 34764a238c70SJohn Marino this License in all other respects regarding verbatim copying of 34774a238c70SJohn Marino that document. 34784a238c70SJohn Marino 34794a238c70SJohn Marino 7. AGGREGATION WITH INDEPENDENT WORKS 34804a238c70SJohn Marino 34814a238c70SJohn Marino A compilation of the Document or its derivatives with other 34824a238c70SJohn Marino separate and independent documents or works, in or on a volume of 34834a238c70SJohn Marino a storage or distribution medium, is called an "aggregate" if the 34844a238c70SJohn Marino copyright resulting from the compilation is not used to limit the 34854a238c70SJohn Marino legal rights of the compilation's users beyond what the individual 34864a238c70SJohn Marino works permit. When the Document is included in an aggregate, this 34874a238c70SJohn Marino License does not apply to the other works in the aggregate which 34884a238c70SJohn Marino are not themselves derivative works of the Document. 34894a238c70SJohn Marino 34904a238c70SJohn Marino If the Cover Text requirement of section 3 is applicable to these 34914a238c70SJohn Marino copies of the Document, then if the Document is less than one half 34924a238c70SJohn Marino of the entire aggregate, the Document's Cover Texts may be placed 34934a238c70SJohn Marino on covers that bracket the Document within the aggregate, or the 34944a238c70SJohn Marino electronic equivalent of covers if the Document is in electronic 34954a238c70SJohn Marino form. Otherwise they must appear on printed covers that bracket 34964a238c70SJohn Marino the whole aggregate. 34974a238c70SJohn Marino 34984a238c70SJohn Marino 8. TRANSLATION 34994a238c70SJohn Marino 35004a238c70SJohn Marino Translation is considered a kind of modification, so you may 35014a238c70SJohn Marino distribute translations of the Document under the terms of section 35024a238c70SJohn Marino 4. Replacing Invariant Sections with translations requires special 35034a238c70SJohn Marino permission from their copyright holders, but you may include 35044a238c70SJohn Marino translations of some or all Invariant Sections in addition to the 35054a238c70SJohn Marino original versions of these Invariant Sections. You may include a 35064a238c70SJohn Marino translation of this License, and all the license notices in the 35074a238c70SJohn Marino Document, and any Warranty Disclaimers, provided that you also 35084a238c70SJohn Marino include the original English version of this License and the 35094a238c70SJohn Marino original versions of those notices and disclaimers. In case of a 35104a238c70SJohn Marino disagreement between the translation and the original version of 35114a238c70SJohn Marino this License or a notice or disclaimer, the original version will 35124a238c70SJohn Marino prevail. 35134a238c70SJohn Marino 35144a238c70SJohn Marino If a section in the Document is Entitled "Acknowledgements", 35154a238c70SJohn Marino "Dedications", or "History", the requirement (section 4) to 35164a238c70SJohn Marino Preserve its Title (section 1) will typically require changing the 35174a238c70SJohn Marino actual title. 35184a238c70SJohn Marino 35194a238c70SJohn Marino 9. TERMINATION 35204a238c70SJohn Marino 35214a238c70SJohn Marino You may not copy, modify, sublicense, or distribute the Document 35224a238c70SJohn Marino except as expressly provided for under this License. Any other 35234a238c70SJohn Marino attempt to copy, modify, sublicense or distribute the Document is 35244a238c70SJohn Marino void, and will automatically terminate your rights under this 35254a238c70SJohn Marino License. However, parties who have received copies, or rights, 35264a238c70SJohn Marino from you under this License will not have their licenses 35274a238c70SJohn Marino terminated so long as such parties remain in full compliance. 35284a238c70SJohn Marino 35294a238c70SJohn Marino 10. FUTURE REVISIONS OF THIS LICENSE 35304a238c70SJohn Marino 35314a238c70SJohn Marino The Free Software Foundation may publish new, revised versions of 35324a238c70SJohn Marino the GNU Free Documentation License from time to time. Such new 35334a238c70SJohn Marino versions will be similar in spirit to the present version, but may 35344a238c70SJohn Marino differ in detail to address new problems or concerns. See 35354a238c70SJohn Marino `http://www.gnu.org/copyleft/'. 35364a238c70SJohn Marino 35374a238c70SJohn Marino Each version of the License is given a distinguishing version 35384a238c70SJohn Marino number. If the Document specifies that a particular numbered 35394a238c70SJohn Marino version of this License "or any later version" applies to it, you 35404a238c70SJohn Marino have the option of following the terms and conditions either of 35414a238c70SJohn Marino that specified version or of any later version that has been 35424a238c70SJohn Marino published (not as a draft) by the Free Software Foundation. If 35434a238c70SJohn Marino the Document does not specify a version number of this License, 35444a238c70SJohn Marino you may choose any version ever published (not as a draft) by the 35454a238c70SJohn Marino Free Software Foundation. 35464a238c70SJohn Marino 35474a238c70SJohn MarinoA.1 ADDENDUM: How to Use This License For Your Documents 35484a238c70SJohn Marino======================================================== 35494a238c70SJohn Marino 35504a238c70SJohn MarinoTo use this License in a document you have written, include a copy of 35514a238c70SJohn Marinothe License in the document and put the following copyright and license 35524a238c70SJohn Marinonotices just after the title page: 35534a238c70SJohn Marino 35544a238c70SJohn Marino Copyright (C) YEAR YOUR NAME. 35554a238c70SJohn Marino Permission is granted to copy, distribute and/or modify this document 35564a238c70SJohn Marino under the terms of the GNU Free Documentation License, Version 1.2 35574a238c70SJohn Marino or any later version published by the Free Software Foundation; 35584a238c70SJohn Marino with no Invariant Sections, no Front-Cover Texts, and no Back-Cover 35594a238c70SJohn Marino Texts. A copy of the license is included in the section entitled ``GNU 35604a238c70SJohn Marino Free Documentation License''. 35614a238c70SJohn Marino 35624a238c70SJohn Marino If you have Invariant Sections, Front-Cover Texts and Back-Cover 35634a238c70SJohn MarinoTexts, replace the "with...Texts." line with this: 35644a238c70SJohn Marino 35654a238c70SJohn Marino with the Invariant Sections being LIST THEIR TITLES, with 35664a238c70SJohn Marino the Front-Cover Texts being LIST, and with the Back-Cover Texts 35674a238c70SJohn Marino being LIST. 35684a238c70SJohn Marino 35694a238c70SJohn Marino If you have Invariant Sections without Cover Texts, or some other 35704a238c70SJohn Marinocombination of the three, merge those two alternatives to suit the 35714a238c70SJohn Marinosituation. 35724a238c70SJohn Marino 35734a238c70SJohn Marino If your document contains nontrivial examples of program code, we 35744a238c70SJohn Marinorecommend releasing these examples in parallel under your choice of 35754a238c70SJohn Marinofree software license, such as the GNU General Public License, to 35764a238c70SJohn Marinopermit their use in free software. 35774a238c70SJohn Marino 35784a238c70SJohn Marino 35794a238c70SJohn MarinoFile: mpfr.info, Node: Concept Index, Next: Function and Type Index, Prev: GNU Free Documentation License, Up: Top 35804a238c70SJohn Marino 35814a238c70SJohn MarinoConcept Index 35824a238c70SJohn Marino************* 35834a238c70SJohn Marino 35844a238c70SJohn Marino[index] 35854a238c70SJohn Marino* Menu: 35864a238c70SJohn Marino 35874a238c70SJohn Marino* Accuracy: MPFR Interface. (line 25) 35884a238c70SJohn Marino* Arithmetic functions: Basic Arithmetic Functions. 35894a238c70SJohn Marino (line 3) 35904a238c70SJohn Marino* Assignment functions: Assignment Functions. (line 3) 35914a238c70SJohn Marino* Basic arithmetic functions: Basic Arithmetic Functions. 35924a238c70SJohn Marino (line 3) 35934a238c70SJohn Marino* Combined initialization and assignment functions: Combined Initialization and Assignment Functions. 35944a238c70SJohn Marino (line 3) 35954a238c70SJohn Marino* Comparison functions: Comparison Functions. (line 3) 35964a238c70SJohn Marino* Compatibility with MPF: Compatibility with MPF. 35974a238c70SJohn Marino (line 3) 35984a238c70SJohn Marino* Conditions for copying MPFR: Copying. (line 6) 35994a238c70SJohn Marino* Conversion functions: Conversion Functions. (line 3) 36004a238c70SJohn Marino* Copying conditions: Copying. (line 6) 36014a238c70SJohn Marino* Custom interface: Custom Interface. (line 3) 36024a238c70SJohn Marino* Exception related functions: Exception Related Functions. 36034a238c70SJohn Marino (line 3) 36044a238c70SJohn Marino* Float arithmetic functions: Basic Arithmetic Functions. 36054a238c70SJohn Marino (line 3) 36064a238c70SJohn Marino* Float comparisons functions: Comparison Functions. (line 3) 36074a238c70SJohn Marino* Float functions: MPFR Interface. (line 6) 36084a238c70SJohn Marino* Float input and output functions: Input and Output Functions. 36094a238c70SJohn Marino (line 3) 36104a238c70SJohn Marino* Float output functions: Formatted Output Functions. 36114a238c70SJohn Marino (line 3) 36124a238c70SJohn Marino* Floating-point functions: MPFR Interface. (line 6) 36134a238c70SJohn Marino* Floating-point number: Nomenclature and Types. 36144a238c70SJohn Marino (line 6) 36154a238c70SJohn Marino* GNU Free Documentation License: GNU Free Documentation License. 36164a238c70SJohn Marino (line 6) 36174a238c70SJohn Marino* I/O functions <1>: Formatted Output Functions. 36184a238c70SJohn Marino (line 3) 36194a238c70SJohn Marino* I/O functions: Input and Output Functions. 36204a238c70SJohn Marino (line 3) 36214a238c70SJohn Marino* Initialization functions: Initialization Functions. 36224a238c70SJohn Marino (line 3) 36234a238c70SJohn Marino* Input functions: Input and Output Functions. 36244a238c70SJohn Marino (line 3) 36254a238c70SJohn Marino* Installation: Installing MPFR. (line 6) 36264a238c70SJohn Marino* Integer related functions: Integer Related Functions. 36274a238c70SJohn Marino (line 3) 36284a238c70SJohn Marino* Internals: Internals. (line 3) 36294a238c70SJohn Marino* intmax_t: Headers and Libraries. 36304a238c70SJohn Marino (line 22) 36314a238c70SJohn Marino* inttypes.h: Headers and Libraries. 36324a238c70SJohn Marino (line 22) 36334a238c70SJohn Marino* libmpfr: Headers and Libraries. 36344a238c70SJohn Marino (line 50) 36354a238c70SJohn Marino* Libraries: Headers and Libraries. 36364a238c70SJohn Marino (line 50) 36374a238c70SJohn Marino* Libtool: Headers and Libraries. 36384a238c70SJohn Marino (line 56) 36394a238c70SJohn Marino* Limb: Internals. (line 6) 36404a238c70SJohn Marino* Linking: Headers and Libraries. 36414a238c70SJohn Marino (line 50) 36424a238c70SJohn Marino* Miscellaneous float functions: Miscellaneous Functions. 36434a238c70SJohn Marino (line 3) 36444a238c70SJohn Marino* mpfr.h: Headers and Libraries. 36454a238c70SJohn Marino (line 6) 36464a238c70SJohn Marino* Output functions <1>: Formatted Output Functions. 36474a238c70SJohn Marino (line 3) 36484a238c70SJohn Marino* Output functions: Input and Output Functions. 36494a238c70SJohn Marino (line 3) 36504a238c70SJohn Marino* Precision <1>: MPFR Interface. (line 17) 36514a238c70SJohn Marino* Precision: Nomenclature and Types. 36524a238c70SJohn Marino (line 20) 36534a238c70SJohn Marino* Reporting bugs: Reporting Bugs. (line 6) 36544a238c70SJohn Marino* Rounding mode related functions: Rounding Related Functions. 36554a238c70SJohn Marino (line 3) 36564a238c70SJohn Marino* Rounding Modes: Nomenclature and Types. 36574a238c70SJohn Marino (line 34) 36584a238c70SJohn Marino* Special functions: Special Functions. (line 3) 36594a238c70SJohn Marino* stdarg.h: Headers and Libraries. 36604a238c70SJohn Marino (line 19) 36614a238c70SJohn Marino* stdint.h: Headers and Libraries. 36624a238c70SJohn Marino (line 22) 36634a238c70SJohn Marino* stdio.h: Headers and Libraries. 36644a238c70SJohn Marino (line 12) 36654a238c70SJohn Marino* Ternary value: Rounding Modes. (line 29) 36664a238c70SJohn Marino* uintmax_t: Headers and Libraries. 36674a238c70SJohn Marino (line 22) 36684a238c70SJohn Marino 36694a238c70SJohn Marino 36704a238c70SJohn MarinoFile: mpfr.info, Node: Function and Type Index, Prev: Concept Index, Up: Top 36714a238c70SJohn Marino 36724a238c70SJohn MarinoFunction and Type Index 36734a238c70SJohn Marino*********************** 36744a238c70SJohn Marino 36754a238c70SJohn Marino[index] 36764a238c70SJohn Marino* Menu: 36774a238c70SJohn Marino 36784a238c70SJohn Marino* mpfr_abs: Basic Arithmetic Functions. 36794a238c70SJohn Marino (line 175) 36804a238c70SJohn Marino* mpfr_acos: Special Functions. (line 52) 36814a238c70SJohn Marino* mpfr_acosh: Special Functions. (line 136) 36824a238c70SJohn Marino* mpfr_add: Basic Arithmetic Functions. 36834a238c70SJohn Marino (line 8) 36844a238c70SJohn Marino* mpfr_add_d: Basic Arithmetic Functions. 36854a238c70SJohn Marino (line 14) 36864a238c70SJohn Marino* mpfr_add_q: Basic Arithmetic Functions. 36874a238c70SJohn Marino (line 18) 36884a238c70SJohn Marino* mpfr_add_si: Basic Arithmetic Functions. 36894a238c70SJohn Marino (line 12) 36904a238c70SJohn Marino* mpfr_add_ui: Basic Arithmetic Functions. 36914a238c70SJohn Marino (line 10) 36924a238c70SJohn Marino* mpfr_add_z: Basic Arithmetic Functions. 36934a238c70SJohn Marino (line 16) 36944a238c70SJohn Marino* mpfr_agm: Special Functions. (line 232) 36954a238c70SJohn Marino* mpfr_ai: Special Functions. (line 248) 36964a238c70SJohn Marino* mpfr_asin: Special Functions. (line 53) 36974a238c70SJohn Marino* mpfr_asinh: Special Functions. (line 137) 36984a238c70SJohn Marino* mpfr_asprintf: Formatted Output Functions. 36994a238c70SJohn Marino (line 194) 37004a238c70SJohn Marino* mpfr_atan: Special Functions. (line 54) 37014a238c70SJohn Marino* mpfr_atan2: Special Functions. (line 65) 37024a238c70SJohn Marino* mpfr_atanh: Special Functions. (line 138) 37034a238c70SJohn Marino* mpfr_buildopt_decimal_p: Miscellaneous Functions. 3704*ab6d115fSJohn Marino (line 163) 37054a238c70SJohn Marino* mpfr_buildopt_gmpinternals_p: Miscellaneous Functions. 3706*ab6d115fSJohn Marino (line 168) 37074a238c70SJohn Marino* mpfr_buildopt_tls_p: Miscellaneous Functions. 3708*ab6d115fSJohn Marino (line 157) 37094a238c70SJohn Marino* mpfr_buildopt_tune_case: Miscellaneous Functions. 3710*ab6d115fSJohn Marino (line 173) 37114a238c70SJohn Marino* mpfr_can_round: Rounding Related Functions. 37124a238c70SJohn Marino (line 37) 37134a238c70SJohn Marino* mpfr_cbrt: Basic Arithmetic Functions. 37144a238c70SJohn Marino (line 109) 37154a238c70SJohn Marino* mpfr_ceil: Integer Related Functions. 37164a238c70SJohn Marino (line 8) 37174a238c70SJohn Marino* mpfr_check_range: Exception Related Functions. 37184a238c70SJohn Marino (line 38) 37194a238c70SJohn Marino* mpfr_clear: Initialization Functions. 37204a238c70SJohn Marino (line 31) 37214a238c70SJohn Marino* mpfr_clear_divby0: Exception Related Functions. 37224a238c70SJohn Marino (line 113) 37234a238c70SJohn Marino* mpfr_clear_erangeflag: Exception Related Functions. 37244a238c70SJohn Marino (line 116) 37254a238c70SJohn Marino* mpfr_clear_flags: Exception Related Functions. 37264a238c70SJohn Marino (line 129) 37274a238c70SJohn Marino* mpfr_clear_inexflag: Exception Related Functions. 37284a238c70SJohn Marino (line 115) 37294a238c70SJohn Marino* mpfr_clear_nanflag: Exception Related Functions. 37304a238c70SJohn Marino (line 114) 37314a238c70SJohn Marino* mpfr_clear_overflow: Exception Related Functions. 37324a238c70SJohn Marino (line 112) 37334a238c70SJohn Marino* mpfr_clear_underflow: Exception Related Functions. 37344a238c70SJohn Marino (line 111) 37354a238c70SJohn Marino* mpfr_clears: Initialization Functions. 37364a238c70SJohn Marino (line 36) 37374a238c70SJohn Marino* mpfr_cmp: Comparison Functions. 37384a238c70SJohn Marino (line 7) 37394a238c70SJohn Marino* mpfr_cmp_d: Comparison Functions. 37404a238c70SJohn Marino (line 10) 37414a238c70SJohn Marino* mpfr_cmp_f: Comparison Functions. 37424a238c70SJohn Marino (line 14) 37434a238c70SJohn Marino* mpfr_cmp_ld: Comparison Functions. 37444a238c70SJohn Marino (line 11) 37454a238c70SJohn Marino* mpfr_cmp_q: Comparison Functions. 37464a238c70SJohn Marino (line 13) 37474a238c70SJohn Marino* mpfr_cmp_si: Comparison Functions. 37484a238c70SJohn Marino (line 9) 37494a238c70SJohn Marino* mpfr_cmp_si_2exp: Comparison Functions. 37504a238c70SJohn Marino (line 31) 37514a238c70SJohn Marino* mpfr_cmp_ui: Comparison Functions. 37524a238c70SJohn Marino (line 8) 37534a238c70SJohn Marino* mpfr_cmp_ui_2exp: Comparison Functions. 37544a238c70SJohn Marino (line 29) 37554a238c70SJohn Marino* mpfr_cmp_z: Comparison Functions. 37564a238c70SJohn Marino (line 12) 37574a238c70SJohn Marino* mpfr_cmpabs: Comparison Functions. 37584a238c70SJohn Marino (line 35) 37594a238c70SJohn Marino* mpfr_const_catalan: Special Functions. (line 259) 37604a238c70SJohn Marino* mpfr_const_euler: Special Functions. (line 258) 37614a238c70SJohn Marino* mpfr_const_log2: Special Functions. (line 256) 37624a238c70SJohn Marino* mpfr_const_pi: Special Functions. (line 257) 37634a238c70SJohn Marino* mpfr_copysign: Miscellaneous Functions. 3764*ab6d115fSJohn Marino (line 111) 37654a238c70SJohn Marino* mpfr_cos: Special Functions. (line 30) 37664a238c70SJohn Marino* mpfr_cosh: Special Functions. (line 115) 37674a238c70SJohn Marino* mpfr_cot: Special Functions. (line 48) 37684a238c70SJohn Marino* mpfr_coth: Special Functions. (line 132) 37694a238c70SJohn Marino* mpfr_csc: Special Functions. (line 47) 37704a238c70SJohn Marino* mpfr_csch: Special Functions. (line 131) 37714a238c70SJohn Marino* mpfr_custom_get_exp: Custom Interface. (line 78) 37724a238c70SJohn Marino* mpfr_custom_get_kind: Custom Interface. (line 67) 37734a238c70SJohn Marino* mpfr_custom_get_significand: Custom Interface. (line 72) 37744a238c70SJohn Marino* mpfr_custom_get_size: Custom Interface. (line 36) 37754a238c70SJohn Marino* mpfr_custom_init: Custom Interface. (line 41) 37764a238c70SJohn Marino* mpfr_custom_init_set: Custom Interface. (line 48) 37774a238c70SJohn Marino* mpfr_custom_move: Custom Interface. (line 85) 37784a238c70SJohn Marino* mpfr_d_div: Basic Arithmetic Functions. 37794a238c70SJohn Marino (line 84) 37804a238c70SJohn Marino* mpfr_d_sub: Basic Arithmetic Functions. 37814a238c70SJohn Marino (line 37) 37824a238c70SJohn Marino* MPFR_DECL_INIT: Initialization Functions. 37834a238c70SJohn Marino (line 75) 37844a238c70SJohn Marino* mpfr_digamma: Special Functions. (line 187) 37854a238c70SJohn Marino* mpfr_dim: Basic Arithmetic Functions. 37864a238c70SJohn Marino (line 182) 37874a238c70SJohn Marino* mpfr_div: Basic Arithmetic Functions. 37884a238c70SJohn Marino (line 74) 37894a238c70SJohn Marino* mpfr_div_2exp: Compatibility with MPF. 37904a238c70SJohn Marino (line 51) 37914a238c70SJohn Marino* mpfr_div_2si: Basic Arithmetic Functions. 37924a238c70SJohn Marino (line 197) 37934a238c70SJohn Marino* mpfr_div_2ui: Basic Arithmetic Functions. 37944a238c70SJohn Marino (line 195) 37954a238c70SJohn Marino* mpfr_div_d: Basic Arithmetic Functions. 37964a238c70SJohn Marino (line 86) 37974a238c70SJohn Marino* mpfr_div_q: Basic Arithmetic Functions. 37984a238c70SJohn Marino (line 90) 37994a238c70SJohn Marino* mpfr_div_si: Basic Arithmetic Functions. 38004a238c70SJohn Marino (line 82) 38014a238c70SJohn Marino* mpfr_div_ui: Basic Arithmetic Functions. 38024a238c70SJohn Marino (line 78) 38034a238c70SJohn Marino* mpfr_div_z: Basic Arithmetic Functions. 38044a238c70SJohn Marino (line 88) 38054a238c70SJohn Marino* mpfr_divby0_p: Exception Related Functions. 38064a238c70SJohn Marino (line 135) 38074a238c70SJohn Marino* mpfr_eint: Special Functions. (line 154) 38084a238c70SJohn Marino* mpfr_eq: Compatibility with MPF. 38094a238c70SJohn Marino (line 30) 38104a238c70SJohn Marino* mpfr_equal_p: Comparison Functions. 38114a238c70SJohn Marino (line 61) 38124a238c70SJohn Marino* mpfr_erangeflag_p: Exception Related Functions. 38134a238c70SJohn Marino (line 138) 38144a238c70SJohn Marino* mpfr_erf: Special Functions. (line 198) 38154a238c70SJohn Marino* mpfr_erfc: Special Functions. (line 199) 38164a238c70SJohn Marino* mpfr_exp: Special Functions. (line 24) 38174a238c70SJohn Marino* mpfr_exp10: Special Functions. (line 26) 38184a238c70SJohn Marino* mpfr_exp2: Special Functions. (line 25) 38194a238c70SJohn Marino* mpfr_expm1: Special Functions. (line 150) 38204a238c70SJohn Marino* mpfr_fac_ui: Special Functions. (line 143) 38214a238c70SJohn Marino* mpfr_fits_intmax_p: Conversion Functions. 38224a238c70SJohn Marino (line 146) 38234a238c70SJohn Marino* mpfr_fits_sint_p: Conversion Functions. 38244a238c70SJohn Marino (line 142) 38254a238c70SJohn Marino* mpfr_fits_slong_p: Conversion Functions. 38264a238c70SJohn Marino (line 140) 38274a238c70SJohn Marino* mpfr_fits_sshort_p: Conversion Functions. 38284a238c70SJohn Marino (line 144) 38294a238c70SJohn Marino* mpfr_fits_uint_p: Conversion Functions. 38304a238c70SJohn Marino (line 141) 38314a238c70SJohn Marino* mpfr_fits_uintmax_p: Conversion Functions. 38324a238c70SJohn Marino (line 145) 38334a238c70SJohn Marino* mpfr_fits_ulong_p: Conversion Functions. 38344a238c70SJohn Marino (line 139) 38354a238c70SJohn Marino* mpfr_fits_ushort_p: Conversion Functions. 38364a238c70SJohn Marino (line 143) 38374a238c70SJohn Marino* mpfr_floor: Integer Related Functions. 38384a238c70SJohn Marino (line 9) 38394a238c70SJohn Marino* mpfr_fma: Special Functions. (line 225) 38404a238c70SJohn Marino* mpfr_fmod: Integer Related Functions. 38414a238c70SJohn Marino (line 79) 38424a238c70SJohn Marino* mpfr_fms: Special Functions. (line 227) 38434a238c70SJohn Marino* mpfr_fprintf: Formatted Output Functions. 38444a238c70SJohn Marino (line 158) 38454a238c70SJohn Marino* mpfr_frac: Integer Related Functions. 38464a238c70SJohn Marino (line 62) 38474a238c70SJohn Marino* mpfr_free_cache: Special Functions. (line 266) 38484a238c70SJohn Marino* mpfr_free_str: Conversion Functions. 38494a238c70SJohn Marino (line 133) 38504a238c70SJohn Marino* mpfr_frexp: Conversion Functions. 38514a238c70SJohn Marino (line 47) 38524a238c70SJohn Marino* mpfr_gamma: Special Functions. (line 169) 38534a238c70SJohn Marino* mpfr_get_d: Conversion Functions. 38544a238c70SJohn Marino (line 8) 38554a238c70SJohn Marino* mpfr_get_d_2exp: Conversion Functions. 38564a238c70SJohn Marino (line 34) 38574a238c70SJohn Marino* mpfr_get_decimal64: Conversion Functions. 38584a238c70SJohn Marino (line 10) 38594a238c70SJohn Marino* mpfr_get_default_prec: Initialization Functions. 38604a238c70SJohn Marino (line 114) 38614a238c70SJohn Marino* mpfr_get_default_rounding_mode: Rounding Related Functions. 38624a238c70SJohn Marino (line 11) 38634a238c70SJohn Marino* mpfr_get_emax: Exception Related Functions. 38644a238c70SJohn Marino (line 8) 38654a238c70SJohn Marino* mpfr_get_emax_max: Exception Related Functions. 38664a238c70SJohn Marino (line 31) 38674a238c70SJohn Marino* mpfr_get_emax_min: Exception Related Functions. 38684a238c70SJohn Marino (line 30) 38694a238c70SJohn Marino* mpfr_get_emin: Exception Related Functions. 38704a238c70SJohn Marino (line 7) 38714a238c70SJohn Marino* mpfr_get_emin_max: Exception Related Functions. 38724a238c70SJohn Marino (line 29) 38734a238c70SJohn Marino* mpfr_get_emin_min: Exception Related Functions. 38744a238c70SJohn Marino (line 28) 38754a238c70SJohn Marino* mpfr_get_exp: Miscellaneous Functions. 3876*ab6d115fSJohn Marino (line 89) 38774a238c70SJohn Marino* mpfr_get_f: Conversion Functions. 38784a238c70SJohn Marino (line 73) 38794a238c70SJohn Marino* mpfr_get_flt: Conversion Functions. 38804a238c70SJohn Marino (line 7) 38814a238c70SJohn Marino* mpfr_get_ld: Conversion Functions. 38824a238c70SJohn Marino (line 9) 38834a238c70SJohn Marino* mpfr_get_ld_2exp: Conversion Functions. 38844a238c70SJohn Marino (line 36) 38854a238c70SJohn Marino* mpfr_get_patches: Miscellaneous Functions. 3886*ab6d115fSJohn Marino (line 148) 38874a238c70SJohn Marino* mpfr_get_prec: Initialization Functions. 38884a238c70SJohn Marino (line 147) 38894a238c70SJohn Marino* mpfr_get_si: Conversion Functions. 38904a238c70SJohn Marino (line 20) 38914a238c70SJohn Marino* mpfr_get_sj: Conversion Functions. 38924a238c70SJohn Marino (line 22) 38934a238c70SJohn Marino* mpfr_get_str: Conversion Functions. 38944a238c70SJohn Marino (line 87) 38954a238c70SJohn Marino* mpfr_get_ui: Conversion Functions. 38964a238c70SJohn Marino (line 21) 38974a238c70SJohn Marino* mpfr_get_uj: Conversion Functions. 38984a238c70SJohn Marino (line 23) 38994a238c70SJohn Marino* mpfr_get_version: Miscellaneous Functions. 3900*ab6d115fSJohn Marino (line 117) 39014a238c70SJohn Marino* mpfr_get_z: Conversion Functions. 39024a238c70SJohn Marino (line 68) 39034a238c70SJohn Marino* mpfr_get_z_2exp: Conversion Functions. 39044a238c70SJohn Marino (line 55) 39054a238c70SJohn Marino* mpfr_grandom: Miscellaneous Functions. 39064a238c70SJohn Marino (line 65) 39074a238c70SJohn Marino* mpfr_greater_p: Comparison Functions. 39084a238c70SJohn Marino (line 57) 39094a238c70SJohn Marino* mpfr_greaterequal_p: Comparison Functions. 39104a238c70SJohn Marino (line 58) 39114a238c70SJohn Marino* mpfr_hypot: Special Functions. (line 241) 39124a238c70SJohn Marino* mpfr_inexflag_p: Exception Related Functions. 39134a238c70SJohn Marino (line 137) 39144a238c70SJohn Marino* mpfr_inf_p: Comparison Functions. 39154a238c70SJohn Marino (line 42) 39164a238c70SJohn Marino* mpfr_init: Initialization Functions. 39174a238c70SJohn Marino (line 54) 39184a238c70SJohn Marino* mpfr_init2: Initialization Functions. 39194a238c70SJohn Marino (line 11) 39204a238c70SJohn Marino* mpfr_init_set: Combined Initialization and Assignment Functions. 39214a238c70SJohn Marino (line 7) 39224a238c70SJohn Marino* mpfr_init_set_d: Combined Initialization and Assignment Functions. 39234a238c70SJohn Marino (line 12) 39244a238c70SJohn Marino* mpfr_init_set_f: Combined Initialization and Assignment Functions. 39254a238c70SJohn Marino (line 17) 39264a238c70SJohn Marino* mpfr_init_set_ld: Combined Initialization and Assignment Functions. 39274a238c70SJohn Marino (line 14) 39284a238c70SJohn Marino* mpfr_init_set_q: Combined Initialization and Assignment Functions. 39294a238c70SJohn Marino (line 16) 39304a238c70SJohn Marino* mpfr_init_set_si: Combined Initialization and Assignment Functions. 39314a238c70SJohn Marino (line 11) 39324a238c70SJohn Marino* mpfr_init_set_str: Combined Initialization and Assignment Functions. 39334a238c70SJohn Marino (line 23) 39344a238c70SJohn Marino* mpfr_init_set_ui: Combined Initialization and Assignment Functions. 39354a238c70SJohn Marino (line 9) 39364a238c70SJohn Marino* mpfr_init_set_z: Combined Initialization and Assignment Functions. 39374a238c70SJohn Marino (line 15) 39384a238c70SJohn Marino* mpfr_inits: Initialization Functions. 39394a238c70SJohn Marino (line 63) 39404a238c70SJohn Marino* mpfr_inits2: Initialization Functions. 39414a238c70SJohn Marino (line 23) 39424a238c70SJohn Marino* mpfr_inp_str: Input and Output Functions. 39434a238c70SJohn Marino (line 33) 39444a238c70SJohn Marino* mpfr_integer_p: Integer Related Functions. 39454a238c70SJohn Marino (line 105) 39464a238c70SJohn Marino* mpfr_j0: Special Functions. (line 203) 39474a238c70SJohn Marino* mpfr_j1: Special Functions. (line 204) 39484a238c70SJohn Marino* mpfr_jn: Special Functions. (line 206) 39494a238c70SJohn Marino* mpfr_less_p: Comparison Functions. 39504a238c70SJohn Marino (line 59) 39514a238c70SJohn Marino* mpfr_lessequal_p: Comparison Functions. 39524a238c70SJohn Marino (line 60) 39534a238c70SJohn Marino* mpfr_lessgreater_p: Comparison Functions. 39544a238c70SJohn Marino (line 66) 39554a238c70SJohn Marino* mpfr_lgamma: Special Functions. (line 179) 39564a238c70SJohn Marino* mpfr_li2: Special Functions. (line 164) 39574a238c70SJohn Marino* mpfr_lngamma: Special Functions. (line 173) 39584a238c70SJohn Marino* mpfr_log: Special Functions. (line 17) 39594a238c70SJohn Marino* mpfr_log10: Special Functions. (line 19) 39604a238c70SJohn Marino* mpfr_log1p: Special Functions. (line 146) 39614a238c70SJohn Marino* mpfr_log2: Special Functions. (line 18) 39624a238c70SJohn Marino* mpfr_max: Miscellaneous Functions. 39634a238c70SJohn Marino (line 24) 39644a238c70SJohn Marino* mpfr_min: Miscellaneous Functions. 39654a238c70SJohn Marino (line 22) 39664a238c70SJohn Marino* mpfr_min_prec: Rounding Related Functions. 39674a238c70SJohn Marino (line 59) 39684a238c70SJohn Marino* mpfr_modf: Integer Related Functions. 39694a238c70SJohn Marino (line 69) 39704a238c70SJohn Marino* mpfr_mul: Basic Arithmetic Functions. 39714a238c70SJohn Marino (line 53) 39724a238c70SJohn Marino* mpfr_mul_2exp: Compatibility with MPF. 39734a238c70SJohn Marino (line 49) 39744a238c70SJohn Marino* mpfr_mul_2si: Basic Arithmetic Functions. 39754a238c70SJohn Marino (line 190) 39764a238c70SJohn Marino* mpfr_mul_2ui: Basic Arithmetic Functions. 39774a238c70SJohn Marino (line 188) 39784a238c70SJohn Marino* mpfr_mul_d: Basic Arithmetic Functions. 39794a238c70SJohn Marino (line 59) 39804a238c70SJohn Marino* mpfr_mul_q: Basic Arithmetic Functions. 39814a238c70SJohn Marino (line 63) 39824a238c70SJohn Marino* mpfr_mul_si: Basic Arithmetic Functions. 39834a238c70SJohn Marino (line 57) 39844a238c70SJohn Marino* mpfr_mul_ui: Basic Arithmetic Functions. 39854a238c70SJohn Marino (line 55) 39864a238c70SJohn Marino* mpfr_mul_z: Basic Arithmetic Functions. 39874a238c70SJohn Marino (line 61) 39884a238c70SJohn Marino* mpfr_nan_p: Comparison Functions. 39894a238c70SJohn Marino (line 41) 39904a238c70SJohn Marino* mpfr_nanflag_p: Exception Related Functions. 39914a238c70SJohn Marino (line 136) 39924a238c70SJohn Marino* mpfr_neg: Basic Arithmetic Functions. 39934a238c70SJohn Marino (line 174) 39944a238c70SJohn Marino* mpfr_nextabove: Miscellaneous Functions. 39954a238c70SJohn Marino (line 16) 39964a238c70SJohn Marino* mpfr_nextbelow: Miscellaneous Functions. 39974a238c70SJohn Marino (line 17) 39984a238c70SJohn Marino* mpfr_nexttoward: Miscellaneous Functions. 39994a238c70SJohn Marino (line 7) 40004a238c70SJohn Marino* mpfr_number_p: Comparison Functions. 40014a238c70SJohn Marino (line 43) 40024a238c70SJohn Marino* mpfr_out_str: Input and Output Functions. 40034a238c70SJohn Marino (line 17) 40044a238c70SJohn Marino* mpfr_overflow_p: Exception Related Functions. 40054a238c70SJohn Marino (line 134) 40064a238c70SJohn Marino* mpfr_pow: Basic Arithmetic Functions. 40074a238c70SJohn Marino (line 118) 40084a238c70SJohn Marino* mpfr_pow_si: Basic Arithmetic Functions. 40094a238c70SJohn Marino (line 122) 40104a238c70SJohn Marino* mpfr_pow_ui: Basic Arithmetic Functions. 40114a238c70SJohn Marino (line 120) 40124a238c70SJohn Marino* mpfr_pow_z: Basic Arithmetic Functions. 40134a238c70SJohn Marino (line 124) 40144a238c70SJohn Marino* mpfr_prec_round: Rounding Related Functions. 40154a238c70SJohn Marino (line 15) 40164a238c70SJohn Marino* mpfr_prec_t: Nomenclature and Types. 40174a238c70SJohn Marino (line 20) 40184a238c70SJohn Marino* mpfr_print_rnd_mode: Rounding Related Functions. 40194a238c70SJohn Marino (line 66) 40204a238c70SJohn Marino* mpfr_printf: Formatted Output Functions. 40214a238c70SJohn Marino (line 165) 40224a238c70SJohn Marino* mpfr_rec_sqrt: Basic Arithmetic Functions. 40234a238c70SJohn Marino (line 104) 40244a238c70SJohn Marino* mpfr_regular_p: Comparison Functions. 40254a238c70SJohn Marino (line 45) 40264a238c70SJohn Marino* mpfr_reldiff: Compatibility with MPF. 40274a238c70SJohn Marino (line 41) 40284a238c70SJohn Marino* mpfr_remainder: Integer Related Functions. 40294a238c70SJohn Marino (line 81) 40304a238c70SJohn Marino* mpfr_remquo: Integer Related Functions. 40314a238c70SJohn Marino (line 83) 40324a238c70SJohn Marino* mpfr_rint: Integer Related Functions. 40334a238c70SJohn Marino (line 7) 40344a238c70SJohn Marino* mpfr_rint_ceil: Integer Related Functions. 40354a238c70SJohn Marino (line 38) 40364a238c70SJohn Marino* mpfr_rint_floor: Integer Related Functions. 40374a238c70SJohn Marino (line 40) 40384a238c70SJohn Marino* mpfr_rint_round: Integer Related Functions. 40394a238c70SJohn Marino (line 42) 40404a238c70SJohn Marino* mpfr_rint_trunc: Integer Related Functions. 40414a238c70SJohn Marino (line 44) 40424a238c70SJohn Marino* mpfr_rnd_t: Nomenclature and Types. 40434a238c70SJohn Marino (line 34) 40444a238c70SJohn Marino* mpfr_root: Basic Arithmetic Functions. 40454a238c70SJohn Marino (line 111) 40464a238c70SJohn Marino* mpfr_round: Integer Related Functions. 40474a238c70SJohn Marino (line 10) 40484a238c70SJohn Marino* mpfr_sec: Special Functions. (line 46) 40494a238c70SJohn Marino* mpfr_sech: Special Functions. (line 130) 40504a238c70SJohn Marino* mpfr_set: Assignment Functions. 40514a238c70SJohn Marino (line 10) 40524a238c70SJohn Marino* mpfr_set_d: Assignment Functions. 40534a238c70SJohn Marino (line 17) 40544a238c70SJohn Marino* mpfr_set_decimal64: Assignment Functions. 40554a238c70SJohn Marino (line 21) 40564a238c70SJohn Marino* mpfr_set_default_prec: Initialization Functions. 40574a238c70SJohn Marino (line 101) 40584a238c70SJohn Marino* mpfr_set_default_rounding_mode: Rounding Related Functions. 40594a238c70SJohn Marino (line 7) 40604a238c70SJohn Marino* mpfr_set_divby0: Exception Related Functions. 40614a238c70SJohn Marino (line 122) 40624a238c70SJohn Marino* mpfr_set_emax: Exception Related Functions. 40634a238c70SJohn Marino (line 17) 40644a238c70SJohn Marino* mpfr_set_emin: Exception Related Functions. 40654a238c70SJohn Marino (line 16) 40664a238c70SJohn Marino* mpfr_set_erangeflag: Exception Related Functions. 40674a238c70SJohn Marino (line 125) 40684a238c70SJohn Marino* mpfr_set_exp: Miscellaneous Functions. 4069*ab6d115fSJohn Marino (line 94) 40704a238c70SJohn Marino* mpfr_set_f: Assignment Functions. 40714a238c70SJohn Marino (line 24) 40724a238c70SJohn Marino* mpfr_set_flt: Assignment Functions. 40734a238c70SJohn Marino (line 16) 40744a238c70SJohn Marino* mpfr_set_inexflag: Exception Related Functions. 40754a238c70SJohn Marino (line 124) 40764a238c70SJohn Marino* mpfr_set_inf: Assignment Functions. 4077*ab6d115fSJohn Marino (line 147) 40784a238c70SJohn Marino* mpfr_set_ld: Assignment Functions. 40794a238c70SJohn Marino (line 19) 40804a238c70SJohn Marino* mpfr_set_nan: Assignment Functions. 4081*ab6d115fSJohn Marino (line 146) 40824a238c70SJohn Marino* mpfr_set_nanflag: Exception Related Functions. 40834a238c70SJohn Marino (line 123) 40844a238c70SJohn Marino* mpfr_set_overflow: Exception Related Functions. 40854a238c70SJohn Marino (line 121) 40864a238c70SJohn Marino* mpfr_set_prec: Initialization Functions. 40874a238c70SJohn Marino (line 137) 40884a238c70SJohn Marino* mpfr_set_prec_raw: Compatibility with MPF. 40894a238c70SJohn Marino (line 23) 40904a238c70SJohn Marino* mpfr_set_q: Assignment Functions. 40914a238c70SJohn Marino (line 23) 40924a238c70SJohn Marino* mpfr_set_si: Assignment Functions. 40934a238c70SJohn Marino (line 13) 40944a238c70SJohn Marino* mpfr_set_si_2exp: Assignment Functions. 4095*ab6d115fSJohn Marino (line 53) 40964a238c70SJohn Marino* mpfr_set_sj: Assignment Functions. 40974a238c70SJohn Marino (line 15) 40984a238c70SJohn Marino* mpfr_set_sj_2exp: Assignment Functions. 4099*ab6d115fSJohn Marino (line 57) 41004a238c70SJohn Marino* mpfr_set_str: Assignment Functions. 4101*ab6d115fSJohn Marino (line 65) 41024a238c70SJohn Marino* mpfr_set_ui: Assignment Functions. 41034a238c70SJohn Marino (line 12) 41044a238c70SJohn Marino* mpfr_set_ui_2exp: Assignment Functions. 4105*ab6d115fSJohn Marino (line 51) 41064a238c70SJohn Marino* mpfr_set_uj: Assignment Functions. 41074a238c70SJohn Marino (line 14) 41084a238c70SJohn Marino* mpfr_set_uj_2exp: Assignment Functions. 4109*ab6d115fSJohn Marino (line 55) 41104a238c70SJohn Marino* mpfr_set_underflow: Exception Related Functions. 41114a238c70SJohn Marino (line 120) 41124a238c70SJohn Marino* mpfr_set_z: Assignment Functions. 41134a238c70SJohn Marino (line 22) 41144a238c70SJohn Marino* mpfr_set_z_2exp: Assignment Functions. 4115*ab6d115fSJohn Marino (line 59) 41164a238c70SJohn Marino* mpfr_set_zero: Assignment Functions. 4117*ab6d115fSJohn Marino (line 148) 41184a238c70SJohn Marino* mpfr_setsign: Miscellaneous Functions. 4119*ab6d115fSJohn Marino (line 105) 41204a238c70SJohn Marino* mpfr_sgn: Comparison Functions. 41214a238c70SJohn Marino (line 51) 41224a238c70SJohn Marino* mpfr_si_div: Basic Arithmetic Functions. 41234a238c70SJohn Marino (line 80) 41244a238c70SJohn Marino* mpfr_si_sub: Basic Arithmetic Functions. 41254a238c70SJohn Marino (line 33) 41264a238c70SJohn Marino* mpfr_signbit: Miscellaneous Functions. 4127*ab6d115fSJohn Marino (line 100) 41284a238c70SJohn Marino* mpfr_sin: Special Functions. (line 31) 41294a238c70SJohn Marino* mpfr_sin_cos: Special Functions. (line 37) 41304a238c70SJohn Marino* mpfr_sinh: Special Functions. (line 116) 41314a238c70SJohn Marino* mpfr_sinh_cosh: Special Functions. (line 122) 41324a238c70SJohn Marino* mpfr_snprintf: Formatted Output Functions. 41334a238c70SJohn Marino (line 182) 41344a238c70SJohn Marino* mpfr_sprintf: Formatted Output Functions. 41354a238c70SJohn Marino (line 171) 41364a238c70SJohn Marino* mpfr_sqr: Basic Arithmetic Functions. 41374a238c70SJohn Marino (line 70) 41384a238c70SJohn Marino* mpfr_sqrt: Basic Arithmetic Functions. 41394a238c70SJohn Marino (line 97) 41404a238c70SJohn Marino* mpfr_sqrt_ui: Basic Arithmetic Functions. 41414a238c70SJohn Marino (line 99) 41424a238c70SJohn Marino* mpfr_strtofr: Assignment Functions. 4143*ab6d115fSJohn Marino (line 83) 41444a238c70SJohn Marino* mpfr_sub: Basic Arithmetic Functions. 41454a238c70SJohn Marino (line 27) 41464a238c70SJohn Marino* mpfr_sub_d: Basic Arithmetic Functions. 41474a238c70SJohn Marino (line 39) 41484a238c70SJohn Marino* mpfr_sub_q: Basic Arithmetic Functions. 41494a238c70SJohn Marino (line 45) 41504a238c70SJohn Marino* mpfr_sub_si: Basic Arithmetic Functions. 41514a238c70SJohn Marino (line 35) 41524a238c70SJohn Marino* mpfr_sub_ui: Basic Arithmetic Functions. 41534a238c70SJohn Marino (line 31) 41544a238c70SJohn Marino* mpfr_sub_z: Basic Arithmetic Functions. 41554a238c70SJohn Marino (line 43) 41564a238c70SJohn Marino* mpfr_subnormalize: Exception Related Functions. 41574a238c70SJohn Marino (line 61) 41584a238c70SJohn Marino* mpfr_sum: Special Functions. (line 275) 41594a238c70SJohn Marino* mpfr_swap: Assignment Functions. 4160*ab6d115fSJohn Marino (line 154) 41614a238c70SJohn Marino* mpfr_t: Nomenclature and Types. 41624a238c70SJohn Marino (line 6) 41634a238c70SJohn Marino* mpfr_tan: Special Functions. (line 32) 41644a238c70SJohn Marino* mpfr_tanh: Special Functions. (line 117) 41654a238c70SJohn Marino* mpfr_trunc: Integer Related Functions. 41664a238c70SJohn Marino (line 11) 41674a238c70SJohn Marino* mpfr_ui_div: Basic Arithmetic Functions. 41684a238c70SJohn Marino (line 76) 41694a238c70SJohn Marino* mpfr_ui_pow: Basic Arithmetic Functions. 41704a238c70SJohn Marino (line 128) 41714a238c70SJohn Marino* mpfr_ui_pow_ui: Basic Arithmetic Functions. 41724a238c70SJohn Marino (line 126) 41734a238c70SJohn Marino* mpfr_ui_sub: Basic Arithmetic Functions. 41744a238c70SJohn Marino (line 29) 41754a238c70SJohn Marino* mpfr_underflow_p: Exception Related Functions. 41764a238c70SJohn Marino (line 133) 41774a238c70SJohn Marino* mpfr_unordered_p: Comparison Functions. 41784a238c70SJohn Marino (line 71) 41794a238c70SJohn Marino* mpfr_urandom: Miscellaneous Functions. 41804a238c70SJohn Marino (line 50) 41814a238c70SJohn Marino* mpfr_urandomb: Miscellaneous Functions. 41824a238c70SJohn Marino (line 30) 41834a238c70SJohn Marino* mpfr_vasprintf: Formatted Output Functions. 41844a238c70SJohn Marino (line 196) 41854a238c70SJohn Marino* MPFR_VERSION: Miscellaneous Functions. 4186*ab6d115fSJohn Marino (line 120) 41874a238c70SJohn Marino* MPFR_VERSION_MAJOR: Miscellaneous Functions. 4188*ab6d115fSJohn Marino (line 121) 41894a238c70SJohn Marino* MPFR_VERSION_MINOR: Miscellaneous Functions. 4190*ab6d115fSJohn Marino (line 122) 41914a238c70SJohn Marino* MPFR_VERSION_NUM: Miscellaneous Functions. 4192*ab6d115fSJohn Marino (line 140) 41934a238c70SJohn Marino* MPFR_VERSION_PATCHLEVEL: Miscellaneous Functions. 4194*ab6d115fSJohn Marino (line 123) 41954a238c70SJohn Marino* MPFR_VERSION_STRING: Miscellaneous Functions. 4196*ab6d115fSJohn Marino (line 124) 41974a238c70SJohn Marino* mpfr_vfprintf: Formatted Output Functions. 41984a238c70SJohn Marino (line 160) 41994a238c70SJohn Marino* mpfr_vprintf: Formatted Output Functions. 42004a238c70SJohn Marino (line 166) 42014a238c70SJohn Marino* mpfr_vsnprintf: Formatted Output Functions. 42024a238c70SJohn Marino (line 184) 42034a238c70SJohn Marino* mpfr_vsprintf: Formatted Output Functions. 42044a238c70SJohn Marino (line 173) 42054a238c70SJohn Marino* mpfr_y0: Special Functions. (line 214) 42064a238c70SJohn Marino* mpfr_y1: Special Functions. (line 215) 42074a238c70SJohn Marino* mpfr_yn: Special Functions. (line 217) 42084a238c70SJohn Marino* mpfr_z_sub: Basic Arithmetic Functions. 42094a238c70SJohn Marino (line 41) 42104a238c70SJohn Marino* mpfr_zero_p: Comparison Functions. 42114a238c70SJohn Marino (line 44) 42124a238c70SJohn Marino* mpfr_zeta: Special Functions. (line 192) 42134a238c70SJohn Marino* mpfr_zeta_ui: Special Functions. (line 194) 42144a238c70SJohn Marino 42154a238c70SJohn Marino 42164a238c70SJohn Marino 42174a238c70SJohn MarinoTag Table: 4218*ab6d115fSJohn MarinoNode: Top892 4219*ab6d115fSJohn MarinoNode: Copying2243 4220*ab6d115fSJohn MarinoNode: Introduction to MPFR4003 4221*ab6d115fSJohn MarinoNode: Installing MPFR6092 4222*ab6d115fSJohn MarinoNode: Reporting Bugs10914 4223*ab6d115fSJohn MarinoNode: MPFR Basics12843 4224*ab6d115fSJohn MarinoNode: Headers and Libraries13159 4225*ab6d115fSJohn MarinoNode: Nomenclature and Types16143 4226*ab6d115fSJohn MarinoNode: MPFR Variable Conventions18147 4227*ab6d115fSJohn MarinoNode: Rounding Modes19677 4228*ab6d115fSJohn MarinoRef: ternary value20774 4229*ab6d115fSJohn MarinoNode: Floating-Point Values on Special Numbers22727 4230*ab6d115fSJohn MarinoNode: Exceptions25703 4231*ab6d115fSJohn MarinoNode: Memory Handling28855 4232*ab6d115fSJohn MarinoNode: MPFR Interface29987 4233*ab6d115fSJohn MarinoNode: Initialization Functions32083 4234*ab6d115fSJohn MarinoNode: Assignment Functions38997 4235*ab6d115fSJohn MarinoNode: Combined Initialization and Assignment Functions47651 4236*ab6d115fSJohn MarinoNode: Conversion Functions48944 4237*ab6d115fSJohn MarinoNode: Basic Arithmetic Functions57496 4238*ab6d115fSJohn MarinoNode: Comparison Functions66504 4239*ab6d115fSJohn MarinoNode: Special Functions69986 4240*ab6d115fSJohn MarinoNode: Input and Output Functions83739 4241*ab6d115fSJohn MarinoNode: Formatted Output Functions85662 4242*ab6d115fSJohn MarinoNode: Integer Related Functions94781 4243*ab6d115fSJohn MarinoNode: Rounding Related Functions100543 4244*ab6d115fSJohn MarinoNode: Miscellaneous Functions104157 4245*ab6d115fSJohn MarinoNode: Exception Related Functions112724 4246*ab6d115fSJohn MarinoNode: Compatibility with MPF119478 4247*ab6d115fSJohn MarinoNode: Custom Interface122166 4248*ab6d115fSJohn MarinoNode: Internals126411 4249*ab6d115fSJohn MarinoNode: API Compatibility127895 4250*ab6d115fSJohn MarinoNode: Type and Macro Changes129825 4251*ab6d115fSJohn MarinoNode: Added Functions132546 4252*ab6d115fSJohn MarinoNode: Changed Functions135489 4253*ab6d115fSJohn MarinoNode: Removed Functions139770 4254*ab6d115fSJohn MarinoNode: Other Changes140182 4255*ab6d115fSJohn MarinoNode: Contributors141711 4256*ab6d115fSJohn MarinoNode: References144285 4257*ab6d115fSJohn MarinoNode: GNU Free Documentation License146026 4258*ab6d115fSJohn MarinoNode: Concept Index168469 4259*ab6d115fSJohn MarinoNode: Function and Type Index174388 42604a238c70SJohn Marino 42614a238c70SJohn MarinoEnd Tag Table 42624a238c70SJohn Marino 42634a238c70SJohn Marino 42644a238c70SJohn MarinoLocal Variables: 42654a238c70SJohn Marinocoding: utf-8 42664a238c70SJohn MarinoEnd: 4267