BigNum

BigNum, also commonly referred to BigInt or BigInteger, allows the use of very large numbers -- greater than the primitives allow in a basic programming language.

Versions of BigNum can be found, such as GMP for C, and Java comes with its own version of BigInteger.

Implementation
There are many similarities between working with BigNums and polynomials. This is because any integer $$a_na_{n-1}\ldots a_1a_0$$ in base $$B$$ can be viewed as the polynomial $$a_nx^n+a_{n-1}x^{n-1}+\ldots+a_1x+a_0$$, evaluated at $$B$$. The following will use base-10 for simplicity.

Addition
A "grade school" algorithm, addition is an operation that can be broken up into two cases:

Addition of like signs
Use the "grade school" algorithm of lining the digits up, and adding them one by one, with a carry: 1        1         0  1 2 3 4     1 2 3 4     1 2 3 4     1 2 3 4     1 2 3 4 + 4 5 6 8   + 4 5 6 8   + 4 5 6 8   + 4 5 6 8   + 4 5 6 8 -   -   -   -   -                    2         0 2       8 0 2     5 8 0 2 The final sign will simply be what the like sign was to begin with.

Addition of opposite signs
Use the subtraction algorithm for equal signs.

Subtraction
Another straightforward implementation, with two cases:

Subtraction of equal signs
Another "grade school" algorithm of lining the digits up, and subtract them one by one, borrowing when needed: 6      5   6       5   6  6 3 7 5     6 3  15      13  15      13  15 - 1 7 2 6   - 1 7 2 6   - 1 7 2 6   - 1 7 2 6 -   -   -   -                  4 9       6 4 9     4 6 4 9 The final sign will depend on which number is bigger.

Subtraction of opposite signs
Can be converted into addition of equal signs.

Multiplication
The simple algorithm for multiplication is to shift, multiply, and add. This takes $$O(n^2)$$ time. 1 9 4    1 9 4     1 9 4       1 9 4 x 5 2 6   x 5 2 6   x 5 2 6     x 5 2 6 ---  ---   ---     ---          1 1 6 4   1 1 6 4     1 1 6 4                    3 8 8       3 8 8                              9 7 0                            ---                            1 0 2 0 4 4

Multiplication of BigNums can also be done faster in $$O(n (\log n)^{2+\epsilon})$$, with Fast Fourier Transform, or, with relative ease, the Karatsuba Multiplication, which is $$o( n^2 )$$, depending on the constants and method chosen.

BigNum in Programming Languages
Each of the following examples prints the result of 314159265358979 * 271828182845904 (which is 85397342226735418150399772016), followed by a newline.

C
/* make sure to invoke gcc with -lgmp */ int main(int argc, char *argv[]) { mpz_t a, b, r;  mpz_init(a); mpz_init(b); mpz_init(r); mpz_set_str(a, "314159265358979", 10); /* the 10 represents the radix */ mpz_set_str(b, "271828182845904", 10); /* gmp can do 2 to 36 */ mpz_mul(r, a, b); mpz_out_str(stdout, 10, r); putchar('\n'); return 0; }
 * 1) include 
 * 2) include 

Java
import java.math.BigInteger; public class BigIntExample { public static void main(String[] args) {   BigInteger a = new BigInteger("314159265358979"); BigInteger b = new BigInteger("271828182845904"); a = a.multiply(b); System.out.println(a); } }

Perl
use bignum; print 314159265358979 * 271828182845904, "\n";
 * 1) !/usr/bin/perl