article

MPFR: A multiple-precision binary floating-point library with correct rounding

Abstract

This article presents a multiple-precision binary floating-point library, written in the ISO C language, and based on the GNU MP library. Its particularity is to extend to arbitrary-precision, ideas from the IEEE 754 standard, by providing correct rounding and exceptions. We demonstrate how these strong semantics are achieved---with no significant slowdown with respect to other arbitrary-precision tools---and discuss a few applications where such a library can be useful.

References

  1. Batut, C., Belabas, K., Bernardi, D., Cohen, H., and Olivier, M. 2000. User's Guide to PARI/GP. http://pari.math.u-bordeaux.fr/pub/pari/manuals/2.1.6/users.pdf.Google ScholarGoogle Scholar
  2. Booker, A. R. 2005. Artin's conjecture, Turing's method and the Riemann hypothesis. http://www.arxiv.org/abs/math.NT/0507502. 37 pages.Google ScholarGoogle Scholar
  3. Booker, A. R., Strömbergsson, A., and Venkatesh, A. 2006. Effective computation of Maass cusp forms. http://www.math.uu.se/~astrombe/papers/papers.html. Preprint. 29 pages.Google ScholarGoogle Scholar
  4. Brent, R. P. 1978. A Fortran multiple-precision arithmetic package. ACM Trans. Math. Soft. 4, 1, 57--70. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Brent, R. P. 1981a. An idealist's view of semantics for integer and real types. Tech. Rep. TR-CS-81-14, Australian National University, 12 pp.Google ScholarGoogle Scholar
  6. Brent, R. P. 1981b. MP user's guide. Tech. Rep. TR-CS-81-08, Australian National University. 4th ed. 73 pp.Google ScholarGoogle Scholar
  7. Char, B. W., Geddes, K. O., Gonnet, G. H., Leong, B. L., Monagan, M. B., and Watt, S. M. 1991. Maple V: Language Reference Manual. Springer-Verlag.Google ScholarGoogle Scholar
  8. Clinger, W. D. 1990. How to read floating point numbers accurately. In Proceedings of the ACM SIGPLAN'90 Conference on Programming Language Design and Implementation. White Plains, NY, 92--101. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Collins, G. E. and Krandick, W. 2000. Multiprecision floating point addition. In Proceedings of the 2000 International Symposium on Symbolic and Algebraic Computation (ISSAC'2000), C. Traverso, Ed. ACM Press, 71--77. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Cowlishaw, M. 2005. The decNumber C library, 3.32 ed. IBM UK Laboratories. 55 pp.Google ScholarGoogle Scholar
  11. Cuyt, A., Kuterna, P., Verdonk, B., and Vervloet, J. 2001. Arithmos: a reliable integrated computational environment. http://www.cant.ua.ac.be/arithmos/index.html.Google ScholarGoogle Scholar
  12. de Dinechin, F., Ershov, A. V., and Gast, N. 2005. Towards the post-ultimate libm. In Proceedings of 17th IEEE Symposium on Computer Arithmetic. Cape Cod. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Defour, D., Hanrot, G., Lefèvre, V., Muller, J.-M., Revol, N., and Zimmermann, P. 2004. Proposal for a standardization of mathematical function implementation in floating-point arithmetic. Numerical Algorithms 37, 1--4, 367--375.Google ScholarGoogle ScholarCross RefCross Ref
  14. Gay, D. M. 1990. Correctly rounded binary-decimal and decimal-binary conversions. Numerical Analysis Manuscript 90-10, AT&T Bell Laboratories.Google ScholarGoogle Scholar
  15. Goubault, E. 2001. Static analyses of the precision of floating-point operations. In Proceedings of SAS'01. Lecture Notes in Computer Science, vol. 2126. Springer-Verlag, 234--259. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Granlund, T. 2004. GNU MP: The GNU Multiple Precision Arithmetic Library, 4.1.4 ed. http://gmplib.org/.Google ScholarGoogle Scholar
  17. Hack, M. 2004. On intermediate precision required for correctly-rounding decimal-to-binary floating-point conversion. In Proceedings of the 6th Conference Real Numbers and Computers (RNC'6). Schloss Dagstuhl, Germany.Google ScholarGoogle Scholar
  18. Haible, B. and Kreckel, R. 2005. CLN, a class library for numbers. http://www.ginac.de/CLN/. Version 1.1.11.Google ScholarGoogle Scholar
  19. Haible, B. and Papanikolaou, T. 1997. Fast multiprecision evaluation of series of rational numbers. Tech. Rep. TI-7/97, Darmstadt University of Technology.Google ScholarGoogle Scholar
  20. Hanrot, G., Lefèvre, V., Pélissier, P., and Zimmermann, P. 2005. The MPFR library. http://www.mpfr.org/. Version 2.2.0.Google ScholarGoogle Scholar
  21. Hull, T. E. 1978. Desirable floating-point arithmetic and elementary functions for numerical computation. In Proceedings of the 4th IEEE Symposium on Computer Arithmetic (Arith'4). 63--69.Google ScholarGoogle ScholarCross RefCross Ref
  22. IEEE. 1985. IEEE standard for binary floating-point arithmetic. ANSI/IEEE Std 754-1985.Google ScholarGoogle Scholar
  23. Kahan, W. 1996. Lecture notes on the status of IEEE standard 754 for binary floating-point arithmetic. http://http.cs.berkeley.edu/~wkahan/ieee754status/ieee754.ps. 30 pp.Google ScholarGoogle Scholar
  24. Krandick, W. and Johnson, J. R. 1993. Efficient multiprecision floating point multiplication with optimal directional rounding. In Proceedings of the 11th IEEE Symposium on Computer Arithmetic (Arith'11). Windsor, Ontario.Google ScholarGoogle Scholar
  25. Kreinovich, V. and Rump, S. 2006. Towards optimal use of multi-precision arithmetic: A remark. http://www.ti3.tu-harburg.de/~rump/. 4 pp.Google ScholarGoogle Scholar
  26. Lefèvre, V. 2004. The generic multiple-precision floating-point addition with exact rounding (as in the MPFR library). In Proceedings of 6th Conference on Real Numbers and Computers (RNC'6). Schloss Dagstuhl, Germany.Google ScholarGoogle Scholar
  27. Mulders, T. 2000. On short multiplications and divisions. AAECC 11, 1, 69--88.Google ScholarGoogle ScholarCross RefCross Ref
  28. Muller, J.-M. 2005. Elementary Functions. Algorithms and Implementation, 2nd ed. Birkhäuser. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Müller, N. T. 1997. Towards a real RealRAM: a prototype using C++. In Proceedings of the 6th International Conference on Numerical Analysis. Plovdiv.Google ScholarGoogle Scholar
  30. Nguyen, P. and Stehlé, D. 2005. Floating-point LLL revisited. In Proceedings of Eurocrypt 2005. Lecture Notes in Computer Science, vol. 3494. Springer-Verlag, 215--233. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Priest, D. M. 1991. Algorithms for arbitrary precision floating point arithmetic. In Proceedings of the 10th Symposium on Computer Arithmetic, P. Kornerup and D. Matula, Eds. IEEE Computer Society Press, Grenoble, France, 132--144.Google ScholarGoogle ScholarCross RefCross Ref
  32. Revol, N. and Rouillier, F. 2005. MPFI, a multiple precision interval arithmetic library based on MPFR. http://mpfi.gforge.inria.fr/.Google ScholarGoogle Scholar
  33. Shoup, V. 2005. NTL: A library for doing number theory. http://www.shoup.net/ntl/. Version 5.4.Google ScholarGoogle Scholar
  34. Smith, D. M. 1991. Algorithm 693: A Fortran package for floating-point multiple-precision arithmetic. ACM Trans. Math. Soft. 17, 2, 273--283. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Sofroniou, M. and Spaletta, G. 2005. Precise numerical computation. Journal of Logic and Algebraic Programming. Special Issue on Practical Development of Exact Real Number Computation 64, 1, 113--134.Google ScholarGoogle Scholar
  36. Steele, G. L. and White, J. L. 1990. How to print floating-point numbers accurately. In Proceedings of the ACM SIGPLAN'90 Conference on Programming Language Design and Implementation. White Plains, NY, 112--126. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Steele, G. L. and White, J. L. 2003. How to print floating-point numbers accurately. In 20 Years of the ACM/SIGPLAN Conference on Programming Language Design and Implementation (1979--1999): A Selection. Retrospective. 3 pp.Google ScholarGoogle Scholar
  38. Sun Microsystems. 2004. Libmcr 0.9 beta: A reference correctly-rounded library of basic double-precision transcendental elementary functions. http://www.sun.com/download/products.xml?id=41797765.Google ScholarGoogle Scholar
  39. The Arenaire project. 2005. CR-Libm, a library of correctly rounded elementary functions in double-precision. http://lipforge.ens-lyon.fr/projects/crlibm/. Version 0.8.Google ScholarGoogle Scholar
  40. Verdonk, B., Cuyt, A., and Verschaeren, D. 2001. A precision- and range-independent tool for testing floating-point arithmetic I: Basic operations, square root, and remainder. ACM Trans. Math. Soft. 27, 1, 92--118. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Wolfram, S. 1996. The Mathematica Book, 3rd ed. Cambridge University Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Ziv, A. 1991. Fast evaluation of elementary mathematical functions with correctly rounded last bit. ACM Trans. Math. Soft. 17, 3, 410--423. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. MPFR

                Reviews

                Wolfgang Schreiner

                Many computer programs in science and engineering depend on the accurate and efficient computation of continuous quantities represented as floating-point numbers. These numbers are stored as bit strings of fixed length that allow their implementation in hardware, and also put a limit to their precision. In 1985, the standard IEEE Standard for Binary Floating-Point Arithmetic (IEEE 754) specified two such floating-point representations together with the corresponding operations, paying special attention to critical issues such as correct rounding. This universally accepted standard has put an end to the compatibility problems caused by previous implementations. The software library MPFR presented in this paper generalizes IEEE 754 by providing floating-point numbers with arbitrary precision on the basis of the widely used GNU MP library. Each number has its own precision, and for each operation the expected target precision may be specified; the software pays attention to correct rounding, and handles exceptional situations in the spirit of IEEE 754. MPFR is freely available in open source, and is widely used by other mathematical applications and packages. The paper provides insight into the overall design principles of MPFR: its data representation and its implementation of the arithmetic operations. It also discusses the testing of the software and presents experimental results that demonstrate its superiority with respect to efficiency and accuracy over other similar packages. Although the correctness of MPFR is of major importance, a discussion of its formal specification and verification is lacking; this might be a subject for future work. Online Computing Reviews Service

                Access critical reviews of Computing literature here

                Become a reviewer for Computing Reviews.

                Comments

                Login options

                Check if you have access through your login credentials or your institution to get full access on this article.

                Sign in

                Full Access

                PDF Format

                View or Download as a PDF file.

                PDF

                eReader

                View online with eReader.

                eReader
                About Cookies On This Site

                We use cookies to ensure that we give you the best experience on our website.

                Learn more

                Got it!