TOPICS
Search

Arbitrary Precision


Arbitrary precision is a form of computer arithmetic in which the number of digits available for a computation is determined by available resources rather than by a fixed machine format (Brent and Zimmermann 2010). Integer and rational operations can be exact, whereas floating-point operations use a finite working precision and generally incur roundoff error.

An arbitrary-precision integer is represented exactly and can grow as needed, subject to available memory. A nonzero integer N can be stored using a sign epsilon in {-1,1} and a variable-length array of base-B digits d_i, where 0<=d_i<B, according to

 N=epsilonsum_(i=0)^(n-1)d_iB^i.

The digits are commonly grouped into machine-word chunks. Arbitrary-precision rational numbers can similarly be stored as pairs of arbitrary-precision integers. Subject to resource exhaustion, operations on these integer and rational representations are exact.

The algorithms used for arithmetic depend on the operand size. Small operands can use machine arithmetic, while larger ones use methods such as long multiplication, Karatsuba multiplication, and the fast Fourier transform. Division can use long division or multiplication by an approximate reciprocal (Brent and Zimmermann 2010). A whole shifted inverse allows multiplication-based division to remain in the integer domain (Watt 2023).

For arbitrary-precision floating-point arithmetic, the working precision is selectable. Extra working digits and termination criteria are needed when a result does not have a finite expansion in the chosen radix. For example, the binary expansion

 1/3=0.01010101..._2

never terminates, although the rational number 1/3 itself is represented exactly by a numerator and denominator.


See also

Floating-Point Arithmetic, Integer Division, Precision, Significance Arithmetic, Whole Shifted Inverse

Portions of this entry contributed by Dan Uznanski

Explore with Wolfram|Alpha

References

Brent, R. P. and Zimmermann, P. Modern Computer Arithmetic. Cambridge, England: Cambridge University Press, 2010. https://doi.org/10.1017/CBO9780511921698.Knuth, D. E. The Art of Computer Programming, Vol. 2: Seminumerical Algorithms, 3rd ed. Reading, MA: Addison-Wesley, 1998.Watt, S. M. "Efficient Generic Quotients Using Exact Arithmetic." In International Symposium on Symbolic and Algebraic Computation 2023 (ISSAC 2023). New York: ACM, pp. 535-544, 2023. https://doi.org/10.1145/3597066.3597076.

Referenced on Wolfram|Alpha

Arbitrary Precision

Cite this as:

Weisstein, Eric W., with contributions by Dan Uznanski. "Arbitrary Precision." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/ArbitraryPrecision.html

Subject classifications