A1.1 Introduction and Objectives
The goal of this appendix is to give an introduction to multiple-precision arithmetic (sometimes called arbitrary-precision arithmetic or bignum arithmetic) for calculations on numbers whose digits of precision are only limited by the available memory of the host system. In particular, we introduce the Boost C++ multiprecision library that supports high-precision decimal and integer types beyond the 64 bits of precision in C++11.
Multiple precision is useful in applications in which the speed of arithmetic is not a hard requirement. Multiple-precision computations are slower than computations using floating-point arithmetic. So, why and when would we choose a multiple-precision solution? Some scenarios are:
- Avoiding overflow in computations which can plague fixed-precision computations. Overflow can occur for many reasons, for example when the result of a computation is a large number that does not fit into a floating-point value or when dividing a number by a very small number.
- In arithmetic computations (using addition, for example) in which the input is floating point but the result exceeds the machine word size. In this case we could decide to define the result as a multiple-precision data type.
- Many mathematical and numerical methods use large numbers such as factorials and the result of computing the confluent hypergeometric function, to mention just two examples.
- Applications in which artificial ...