Arbitrary-precision integer arithmetic performs exact addition, subtraction, multiplication, and integer division using as many machine words as the value requires. A typical representation stores a sign and digits in base , with each digit occupying one machine word. Carries propagate between words just as in written decimal arithmetic.
For example, can be stored exactly even when a single machine integer has only bits. The attainable size is limited by memory and execution time, rather than a fixed numeric range. The cost grows with the number of bits, so an arithmetic operation on a large value cannot automatically be counted as constant time.
Big-integer multiplication multiplies arbitrary-precision integers represented by arrays of digits. For and , first compute the coefficient sums , then propagate carries in base . Thus the main step is a convolution followed by carry handling.
The school method needs digit multiplications for two -digit inputs. Karatsuba multiplication splits each input into two halves and uses three recursive products instead of four, giving arithmetic work under the usual digit model. For larger inputs, transform-based methods accelerate the convolution. Which method is fastest depends on input size and implementation overhead.
Articles by others on the same topic
There are currently no matching articles.