
Last update(s): Sat Oct 22 17:17:26 2005 Thu Mar 23 14:04:08 2017
What is multipleprecision arithmetic?
It is arithmetic carried out in software at higher precision than provided by hardware.
Since the mid1980s, essentially all new desktop and smaller computers have implemented arithmetic as defined by the ANSI/IEEE 7541985 Standard for Binary FloatingPoint Arithmetic, usually abbreviated to IEEE 754. This provides for 32bit, 64bit, and optionally, either 80bit or 128bit formats. These encode a 1bit sign, a biased poweroftwo exponent (8, 11, 15, and 15 bits respectively), and a significand (24, 53, 64, and 113 bits respectively) capable of representing approximately 7, 15, 19, and 34 decimal digits respectively.
Although the IEEE 754 hardware precisions suffice for many practical purposes, there are many areas of computation where higher precision is required.
Who/what needs multipleprecision arithmetic?
Three simple examples where higherprecision arithmetic is required are in the conversion between decimal and binary number bases, the computation of exactly rounded elementary functions, and the computation of vector dot products:
Two recent books, Experimentation in mathematics: computational paths to discovery (ISBN 1568811365) and Mathematics by Experiment: Plausible Reasoning in the 21st Century (ISBN 1568812116), show how highprecision computation can lead to fundamental new discoveries in mathematics, and be essential for the solution of some important physical problems.
What programming languages provide native multipleprecision arithmetic?
The Axiom, Maple, Mathematica, Maxima, MuPAD, PARI/GP, and Reduce symbolicalgebra languages, the Unix bc and dc calculators, and the python and rexx scripting languages, all provide such a facility and make it easy to use. There are separate BigFloat packages available for the perl and ruby scripting languages.
For example, in Maple, you can change the decimal precision at any time by a simple assignment to a global variable, Digits := 100;, without making any other changes to your program. All subsequent arithmetic, and all of the builtin functions, are then computed to the specified precision.
If you need multipleprecision arithmetic for experimental code that you are developing, these languages are likely to prove most convenient. However, because the arithmetic is performed in software, and code is interpreted, rather than compiled, run times can be hundreds, or even thousands, of times slower than they would be in a compiled language using hardware arithmetic.
Java and C# provide a BigDecimal data type, but it supports only fixedpoint arithmetic, not floatingpoint arithmetic, and library support beyond the basic operations (add, subtract, multiply, and divide) is nonexistent. Its utility is limited, and it is primarily useful only for simple computations in business accounting.
What programming languages provide nonnative multipleprecision arithmetic?
If you need highprecision arithmetic in a traditional programming language, such as Fortran, C, or C++, life can be much more difficult. The Brent MP package (ACM Trans. Math. Software 4(1), 5770 (1978), the Bailey mpfun77 package, the GNU gmp package, the French LORIA mpfr package, and the Moshier extended double package, all provide libraries of routines, but you must use function calls for coding of all numerical and I/O operations that involve multipleprecision data.
The Ada, C++, and Fortran 90/95 languages support userdefinable data types and operator overloading. This makes it possible to define libraries that allow you to code numerical expressions in the conventional way, such as a = b * c + d / sqrt(e). Two such libraries for Fortran 90/95 are the Bailey mpfun90 package, and the Schonfelder vpa package. The Bailey arprec package offers similar support for C++.
Regrettably, none of these packages provides the standard elementary functions, and that deficiency remains a great weakness, because those functions are very likely to be required.
If you need these libraries, please consult with systems staff for advice and instruction.
Where can I learn more about floatingpoint arithmetic in general, and multipleprecision arithmetic in particular?
Consult some of the recent books listed in the extensive fparith floatingpoint arithmetic bibliography. The author of this FAQ has written a draft of a book on the subject; consult systems staff for its prepublication availability.