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

GNU MPFR

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

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

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



Next: , Previous: Top, Up: Top

MPFR Copying Conditions

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

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

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

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

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


Next: , Previous: Copying, Up: Top

1 Introduction to MPFR

MPFR is a portable library written in C for arbitrary precision arithmetic on floating-point numbers. It is based on the GNU MP library. It aims to extend the class of floating-point numbers provided by the GNU MP library by a precise semantics. The main differences with the mpf class from GNU MP are:

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

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

1.1 How to Use This Manual

Everyone should read MPFR Basics. If you need to install the library yourself, you need to read Installing MPFR, too.

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


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

2 Installing MPFR

2.1 How to Install

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

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

    This will prepare the build and setup the options according to your system. If you get error messages, you might check that you use the same compiler and compile options as for GNU MP (see the INSTALL file).

  3. make

    This will compile MPFR, and create a library archive file libmpfr.a. A dynamic library may be produced too (see configure).

  4. make check

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

  5. make install

    This will copy the files mpfr.h and mpf2mpfr.h to the directory /usr/local/include, the file libmpfr.a to the directory /usr/local/lib, and the file mpfr.info to the directory /usr/local/share/info (or if you passed the ‘--prefix’ option to configure, using the prefix directory given as argument to ‘--prefix’ instead of d> (or if you passed the ‘--prefix<. h it ise inTf>Here are the steps neede2 O migh`ll c' TixIn the class="ll cotix’. (See /usr/loure’ option to /usr/loureCle">libd in boou.

    Sp it is p,Free the directory /usr/loheck

    This will n clpdf"file">/usr/loure’ option to /usr/loureCle">lib PDFoou.

    Sp it is p,Free the directory /usr/loheck

    This will n cldvi"file">/usr/loure’ option to /usr/loureCle">lib DVIoou.

    Sp it is p,Free the directory /usr/loheck

    This will n clps"file">/usr/loure’ option to /usr/loureCle">lib PostR, a loou.

    Sp it is p,Free the directory /usr/loheck

    This will n clrs a"file">/usr/loure’ option to /usr/loureCle">lib HTMLoou.

    Sp it is p,Freeshe Gag tss="amp> file/info (or if you pas n clrs a"file">/usr/lo;or use piece

    This wil#Top"> (or if youheck’

    This willcp">n"file">/usr/loureDeletloatinobjns o> and y is an>.s,-- Give ee GNU given .sheck’

    This will to cp">n"file">/usr/loureDeletloatin> and ere ar">GNU Free file/ permit evheck’

    This willunpy the files Deletloatin> and {info,tby>’ program, plus some other staopy the files mpa>, to file).

  6. make< carPFR-Ba befotrictde in usa"sam,Freecommends putting a>&rd claan cae copiour rep&rd cla 53Si>Inour reputeratiur combadNU given mPp">mpa>,loriaour reputspan>’. (See Reporting Bugs for information on what to include in useful bug 53Si>Insampre/euteratacan be usoot, e content=" web tss= informatior-home" ti n cl"Tex n c-ent="/sprs-home" ti n cl"Tex n c-ent="/er witsse are the steps neede4 Getink with Ler std to linkublic L library oTsedea tstGeneral Public Licenacan be use thainformatif-homef-hitle="Textlex n c/spf-homef-hitle="Textlex n c/er wanrsinformatior-home" ti n cl"Texsprs-home" ti n cl"Texer witss"> Next: , Previous: all the library yourself, yoref="#Introduction-to-MPFR">Introduction to MPFR, Up:&;

    2 Installing MPFR

    2.1 How n on what FR B-4nc#Repos="chWarnpyg! Do ere spry, "es, p... @url{...}noderosseshe Gag ly tofo manual rsa.frm d, sn,Freewhich cae c compayPFR lf it i aailaba/ul> ALLmpainvtstig">libdda>,loriait. Wse righlog{}ams, and thatacan be usght ch/span>ifurther sry ssk cla ed ( parti ch/sry ssk xample,r@loria.fInsamo, receive FR lter referenc restria fewh righteive . If y rigkrabrar meanprefixutt checsamp">make toifupossie use you ple,r@line flo&lsqufr.hrong;or use psampa crashlableifhould not) clai MPFRstriar"t this followc rececae ,Freewh by ay and/or mop">mpainmp>make.="#MPFcan sed xtracMPFRsquo;’

    This willcc -V"file">/usr/loureInactly tolabl, you mu'reRsquo;

    This wilgcc -vugs">Reporting Bugs that inmp>

    This willune th-a"file">/usr/louremake docuoodhave iSp iand tha;eifhouldsamp">make docpobl, ve itlyou mixample,shblee">

    samp">make he GNU LesSess="saecsamp">make to:an>’. (See Reporting BugsIo do. owc rtiple Prectipuncp">rlabled sn receiar"t thislableifVersieta uss= p">mmpashblea tp-eqal/sharee thadd nositss"> Next: , Previous: all tfunctions and macros.

  7. Introduction to MPFR, Up;

    2 Installing MPFR

    Tble3, 199ieu library oction">2.1 How g_t_0040ake<_007 clas_002eh_007d-5ra#RepA/spdere ponent re details NU Mry yostricollhisedFree filinmp> (or if you pas n clr too (see configtend thing citizen ilabass="s < peu ay="/span>

  8. the r_ptrr arithmcents fC data/span,r@liescc gh af wit Inser referction">2.1 How 2.4.0. -14"> This library ig_t_0040ibra_007 cl_005f."> _005ft_007d-15ra#Repss fio us."> C data/span,r m
  9. the_."> _tr arith 53MPFR libra setwftop
  10. tic L_PREC_MINr arithmmp>pa
  11. tic L_PREC_MAXr arith 5an clascuror T the ISO C99 st,p
  12. tic L_PREC_MINr arithrts/ hre="cl 2ser referWarnpyg! ic Lip">m ). Do ere at clptple,sht P (svalue for ry small puy n arp
  13. tic L_PREC_MAXr arith, ifferent ges, plInaem"samlild bly GCC, pe t.) ,Freewhich cae cP (svae &ls oa sabake, crasher, pthaton 2piePFRme thipo (ode>mpigh"fy GCC, f the ISO C99 st)ser referction">2.1 How Rul> -Mp>In-16"> This library ig_t_0040ibra_007 cl_005frnd_005ft_007d-17ra#Repss fio us/ul>

    I and fase righstandarex and /ul> Aould not) on th type in C, withachine wo,Freecae cP (scisiod not) ocan;mb C data/span,r m

  14. the_rnd_tMPFR coter referction">2.1 How 3,mb-18"> tml (al How @FR c{he_reci_tence tA to usrecisind faredistriecld b --> doublee sema tsjree < ry on ma>, Wne sos{}ams, on mo-eca-InP olilb

    Sp ihuspan> Nenr matalogou ple,a dig of lile lixthe_reci_tMPFR coterse are the steps nee4.3 ex or @maCe thes library oTse reisthe r_r arith 5pyrigMP oriag as pan,r m

  15. the r_tr arith h it ise inTf>Here are the steps nee4.4 ry yoV provideConvcc s library oALia grsion. rulhrougl/ref="#Contribut arns ofar an ix th cispan> in infoter referry yos_CONTRxample,NU MP (see thR provide TCut any IPur &lsm (ack-Cov 4.2.2)ser referMg thref="#ContributtstaoSTAL) on ix variloessagree fild by tgoo nd).

    pan>

    2 Installing MPFR

    2.1 How

    Cop_002d wit-#Contribu-19"> This library i

    -#Contribu-20 that eveejtype in C, with#Contribut arns osxthe r_tr arithter referenceified#ype in C, with#Contributyour an asos. mContribu frT/samContribtpMPFR provid clang-point num/s ING.th cissa R providelly reproduce Sel> th ciy Al provid;icul U althoughatng-point num/_per_limbmp_darticul ly reproduce R providrea gooasjre ans(odube Gage)ser referction">2.1 How 2.4.0. -21ra#Repss f corp>aa="scul Cut anyhoul nquesthe exponentucision m(ss="samd clain ied ejde-n cy&rd cla),ubdda>ul> aP (s not) al/sharly reproduce Seiletstin p">--p>ul>

    I 53MPFRified#ype in C, with#Contributstriarty tgoo2.1 How Ae-n cy-22">ic Lid size e-n cyorp>aa=-point num.ems for mlef al/sharuInteorzen ahprefer liyy reaALia eonseque throie Swe,R providrestria goole,snfoU lile a fewhg ciight mtbh vs/span>t>, Up:& foaliz -FContribu">:& foaliz PFContribui>, UpAth cispan-FContribu">Ath cispanPFContribui>" mbty :& foaliz Ppan>Ath cispanPFContribui>" nvc. FContribui>ursel A content= FContribui>" m risnt FContribui>Se rialPFContribui>, Up:&oin-spa-Oar an-FContribu">:& anss="fOar anPFContribui>, UpF) r t-Oar an-FContribu">F) r tfOar anPFContribui>, Up:&neg:&neg

    , UpRul> -Reder t-FContribu">Rul> Reder tPFContribui>, UpMiscellaneMiscellane, UpE>subn -Reder t-FContribu">E>subn Reder tPFContribui>, UpAdvecc t-FContribu">Advecc tPFContribui>, Up" m tibory, -l" m tibory, el, Up"ustfmtfunctions a"ustfmacros.

  16. , Up:&nern tu">:&nern tui> Next: , Previous: Ath cispan-FContribu">Ath cispanPFContribui>Introduction to MPFR, Upall tfunctions and macros.
  17. eftoppy foaliz/s, -In
  18. the r_qet_ly rly rt>e isby athatieg

    setwftop

  19. tic L_PREC_MINr arithmmp>pa
  20. tic L_PREC_MAXr ariths(o migent otulame thipoetipuninpiePF). be/erc/block clte>yh2 class"> NextdemCosp;—PFContrib: voidtrr b>t(cR p>he r_t x)cR p>ction">2.1 How clas_005frp">r-25"> /R p>y oFrmp> filspaceAFccunfo,tby> R p>xt Mor messagto che ptpfr.#Contribdenerall
  21. the r_tr arithmR providremeanprefiareRdyh2 class"> NextdemCosp;—PFContrib: voidtt(cR p>he r_t x)cR p>ction">2.1 How clas_005fiy f-26"> /R p>y oan foaliz/>cR p>x f you g>ifsPisionc ohNaN.stall pted)no,easl providens with doiy foaliz/sal thmtaly cp">re"otsquo;<
  22. the r_rp">rr arith,rsetwftoppy foaliz extrT/s ly reproduce cR p>x s, e GNetumberjode>doublrowhich caably c progd by>aa="s="cl
  23. the r_qet_etumber_ly rWarnpyg! Ieeasp">--pgrams. li>In the l, 199ieumpile optprogramehetumber ly reprodubddae the r_iy f2r arith. be/erc/block clte>yh2 class"> NextdemCosp;—PFContrib: voidtt(cR p>he_."> _thly r)cR p>ction">2.1 How clas_005fqet_005fetumber_005f."> -27"> /R p>y oSet e GNetumberjode>doublocision < R p>ly rth vacopyri ly reproduce asl provideredistriece semathe r_iy fr arithmldoublrobv c MPFRdoublotip_cation53th variy foally 53MPFR libra setwftop
  24. tic L_PREC_MINr arithmmp>pa
  25. tic L_PREC_MAXr arith 5be/erc/block clte>yh2 class"> NextdemCosp;—PFContrib: he_."> _tht(cR p>void)cR p>ction">2.1 How clas_005fget_005fetumber_005f."> -28"> /R p>y oRuturnle GNetumberjnd maode>doublotnth vacobe/erc/block clte>yh2 clas/spap>HG reiodano > riece semasitss"> NextdemCosp;—PFContrib: voidtt(cR p>he r_t x, he_."> _thly r)cR p>ction">2.1 How clas_005fqet_005f."> -29"> /R p>y oRusht P (svalue for ce cR p>x cision < R p>ly rth va, f you g>ifsPisionc ohNaN.53MPFR liFRx s, loet 5ansisFequil ppan>the r_ip">r(x)r arithma iy foaliz/saary bs (sor informatio:& foaliz -FContribu">:& foaliz PFContribui>tecimax_ir arith,r compe isinmp>)<stdintlr>r arithmp">code>)<intr-- ulr>r arith befotrian> (or if you pas n clr too (see conf/sry s!-- ian> (or if you pas n clr too (see confmle,dnpiePods oospanTALL< ts ssamContrib itss"> NextdemCosp;—PFContrib: ecist(cR p>he r_t rop,>he r_t op,>he_rnd_t rnd)cR p>ction">2.1 How clas_005fqet-32"> /R p>t(cR p>he r_t rop,>unh ciy Aloo. owt op,>he_rnd_t rnd)cR p>ction">2.1 How clas_005fqet_005fui-33"> /R p>t(cR p>he r_t rop,>loo. owt op,>he_rnd_t rnd)cR p>ction">2.1 How clas_005fqet_005fsi-34"> /R p>t(cR p>he r_t rop,>uecimax_i op,>he_rnd_t rnd)cR p>ction">2.1 How clas_005fqet_005fuj-35"> /R p>t(cR p>he r_t rop,>ecimax_i op,>he_rnd_t rnd)cR p>ction">2.1 How clas_005fqet_005fsj-36"> /R p>t(cR p>he r_t rop,>doue usop,>he_rnd_t rnd)cR p>ction">2.1 How clas_005fqet_005fd-37"> /R p>t(cR p>he r_t rop,>loo. doue usop,>he_rnd_t rnd)cR p>ction">2.1 How clas_005fqet_005fld-38"> /R p>t(cR p>he r_t rop,>_D remal64sop,>he_rnd_t rnd)cR p>ction">2.1 How clas_005fqet_005fd remal64-39"> /R p>t(cR p>he r_t rop,>hez_i op,>he_rnd_t rnd)cR p>ction">2.1 How clas_005fqet_005fz-40"> /R p>t(cR p>he r_t rop,>heq_i op,>he_rnd_t rnd)cR p>ction">2.1 How clas_005fqet_005fq-41"> /R p>t(cR p>he r_t rop,>he _i op,>he_rnd_t rnd)cR p>ction">2.1 How clas_005fqet_005ff-42"> /R p>y oSet e GNl puy ce cR p>r up R p>tparticR p> up R p>, /ul> go oown>p">--pconfig < R p>rndreaNp-eqributts fre ans0distrinvekehe cl +0tby>
  26. the r_qet_uifrarith,n
  27. the r_qet_sithe r_qet_sjthe r_qet_ujfrarith,n
  28. the r_qet_zthe r_qet_qr arithmmp>pa
  29. the r_qet_f

    I 53lsq filk thatid size <,

  30. the r_qet_efrarith,n
  31. the r_qet_ldr arithmmp>pa
  32. the r_qet_d remal64the r_qet_d remal64rinfiguoU lbn amp>’ instead of d>’ option to . ales meana filct‘fr k thatispan>’ option to (GCC;eneral P4.2.0distd, snole,supmake catipdata/span, iv clile eanabunfiguoUdbss="samp>’ instead of d>the r_qet_qriece sn infommp">tfi etnomieeror)ocan;mbthe r_tr arithter re p-e:elsquo;yiecethe r_tr arith, ive . If y-In
  33. the r_qet_strr arithmmp">Sp is="sacinrtecethe r_rinrt_pifrarithtd idPi)mcif you ce c
  34. the r_qet_efrarith,n
  35. the r_qet_ldr arithmp">code>)he r_qet_d remal64doublelementa53-mi=)ch nhatce semayh2 class"> NextdemCosp;—PFContrib: ecist(cR p>he r_t rop,>unh ciy Aloo. owt op,>he_exp_t e,>he_rnd_t rnd)cR p>ction">2.1 How clas_005fqet_005fui_005f2exp-43"> /R p>t(cR p>he r_t rop,>loo. owt op,>he_exp_t e,>he_rnd_t rnd)cR p>ction">2.1 How clas_005fqet_005fsi_005f2exp-44"> /R p>t(cR p>he r_t rop,>uecimax_i op,>ecimax_i e,>he_rnd_t rnd)cR p>ction">2.1 How clas_005fqet_005fuj_005f2exp-45"> /R p>t(cR p>he r_t rop,>ecimax_i op,>ecimax_i e,>he_rnd_t rnd)cR p>ction">2.1 How clas_005fqet_005fsj_005f2exp-46"> /R p>y oSet e GNl puy ce cR p>r up R p>tparticR p> up R p>rion 2.4hhe ma nwohal/sharlingrnsR p>e,e/ul> gooalwn>p">--pconfig < R p>rndreaNp-eqributts fre ans0distrinvekehe cl +0xt e/erc/block clte>yh2 class"> NextdemCosp;—PFContrib: ecist(cR p>he r_t rop,>rinrtb-Inr *s,>ecihe cl,>he_rnd_t rnd)cR p>ction">2.1 How clas_005fqet_005fstr-47"> /R p>y oSet cR p>r up R p>tal/sharl puy ce Ss fs snhe clrcR p>e cl, /ul> gooiee filconfig < R p>rndreaSmp> fil!-- The )he r_qtrtofrfrarithtd idahinoasqud ets, a librlse can v prec)he r_qtrtofrfrarith,r
  36. the r_qet_strr arithmsequirgs>tfi em>wholee@FR c{-@@Inf@@},rms better"s="eae cinsy fouranss="rar l, tuo;ms betterifferPcInracMPrs/sprl> e-eptU Fclassy, uo;ptprog). ms bTpfr.#Contribdouturniz0 i->rieche dr f NextdemCosp;—PFContrib: ecist(cR p>he r_t rop,>rinrtb-Inr *npte tcInr **endpte tecihe cl,>he_rnd_t rnd)cR p>ction">2.1 How clas_005fqtrtofr-48"> /R p>r reRyou nptrr R p> snhe clrcR p>e cl, /ul> gooiee filconfig < R p>rnd;rcR p>e clt>e isby th oper0a(en ino s ooulde cl,>athingcribsd beryw)mes{}Pe sematparti2tion36s(o migent tulame thipoetipuninpiePF). IfrcR p>nptrr R p> all G v precdata,houl not) os, snfoU FreecR p>r up R p>tmp>m
  37. t*r arithsR p>endptep R p>tpreciizcl fi eInracMPr just aft endptep R p>tr mve ea. s=" wit <); ifferent gcR p>r up R p>ttip_cationze@M pan>nptep R p>tr msnfoU ree fileOcerubloreMP are:,tby> R p>endptep R p>t(isqsR p>endptep R p>tr mve ea. s= wit <)lass fusre="ctrn rall puy ts/ nturny ter reParst fr.)_CONTRSs ftqtrtodInd by s 53eae cisr cifoU .laft t+r arithmp">code>)-r arith),hbddach ope e sn iccdataaits_e rialPdatalass fgubjns seque th thinpiePFRss>tfi loo.e isin foal subseque cy ce Ss fre anslr (62whossie eAeInracMPrs)al
  38. tar arithm= 10,r
  39. tbr arithm= 11,n sp/a> Nextdots">...tzr arithm= 36;>ifsPisioncre isby s/etion madrTReran oulde cl 53MPFRd remal" wittcan; doeh operouldenet 2piePFRmycP (scuror T ss="sebrr tulapn iod>(shar#) on e-eptU Fenerpinristear sss="< pan> e-eptU Fry s!-- i filour &lsm mp_li>Sp curor T ss="se) 53MPFRcire not pt>r arithmp">code>)Efrarithtd idbae sRuptal/10,rrr code>)@r arithmcito mosae ;fifurndht dresrion 2.4ht tby>aalingrnrp>Sp e cl 5Indbae sR2 mp_16,/shar are not p)pfrarithtir code>)Pfrarith,rreewhich cae cifurnt"ey="dresrh nhatc are not:fifurndht dres ion 2.4ht tby>aalingrnrp>2>(sha reiodaGNU MP are:_lile d idbae _16) 53MPFRl puy ce ano are not isro/waysiwrit>ln snhe clr10reaIihe clr2,/share ciight mp_can;all Gl
  40. t0br arithmp">code>)0Bfrarith,rmp>psnhe clr16t s dcan;all Gl
  41. t0xr arithmp">code>)0Xr arith stallae Sel> me cltisr0rot0br arithmp">code>)0Bfrarith,re clr2 istaosumU .llsq file ciight mp_all G
  42. t0xr arithmp">code>)0Xr arith,he clr16 istaosumU .lO migent p-e:eMPFRcire not re isionanty- t p">mtaa"dig o.lO migent riece sema (which e> s ss="t0br arith,>code>)0Bfrarith,r
  43. t0xr arithmp">code>)0Xr arith r mve ea