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 their version of BigInteger.

Implementation
It is useful to understand how to implement the operations of an BigInt. The following will use a base-10 for simplicity.

Addition
An "grade school" algorithm, addition is an operator 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.