Multiplying two -digit numbers is the same problem as multiplying two degree- polynomials, plus carry propagation.

The ladder

MethodTimeCrossover (limbs)
Schoolbook< ~30
Karatsuba30 – 300
Toom-Cook 3/4 / 300 – 3000
FFT / NTT> ~3000
Schönhage-Strassenvery large
Fürernever (galactic)
Harvey-van der Hoevennever (galactic)

Every serious library (GMP, Java’s BigInteger, Python’s int) implements the first four with tuned thresholds.

The unifying idea

All of Karatsuba, Toom-Cook and FFT are evaluate → multiply pointwise → interpolate:

MethodEvaluation points
Karatsuba (3 points)
Toom-3 (5 points)
Toom- small integers
FFTthe roots of unity

At small sizes, evaluating at a few integers is cheap and interpolation is a fixed formula. At large sizes, roots of unity make both evaluation and interpolation cost instead of -with-a-huge-constant — which is why FFT eventually wins.

FFT-based multiplication

vector<long long> multiplyBig(const string& s, const string& t) {
    // digits little-endian, base 10 (or pack 3-4 digits per limb)
    vector<long long> a, b;
    for (int i = s.size() - 1; i >= 0; i--) a.push_back(s[i] - '0');
    for (int i = t.size() - 1; i >= 0; i--) b.push_back(t[i] - '0');
 
    vector<long long> c = convolution(a, b);          // FFT or NTT
 
    long long carry = 0;                              // propagate carries
    for (size_t i = 0; i < c.size(); i++) {
        c[i] += carry;
        carry = c[i] / 10;
        c[i] %= 10;
    }
    while (carry) { c.push_back(carry % 10); carry /= 10; }
    while (c.size() > 1 && c.back() == 0) c.pop_back();
    return c;
}

Base choice matters. With base and length , the convolution values reach ; double FFT holds about 53 bits, so constrains . For , is safe and is marginal. NTT has no such limit.

Other big-integer operations

OperationMethodCost
Addition, subtractionschoolbook
Multiplicationas above
DivisionNewton on the reciprocal
Modulodivision
Square rootNewton
Base conversiondivide and conquer
GCDbinary GCD, or half-GCD /
Modular exponentiationsquare and multiply + Montgomery

Division by Newton: compute as a fixed-point reciprocal with , doubling the correct bits each step, then multiply. Total cost is — the same order as one multiplication.

In competitive programming

Usually you should not need big integers:

InsteadUse
Huge exact countsthe answer modulo a prime
Comparing vs __int128
fast exponentiation
Exact factorialsmod p, or Legendre’s formula
Values up to __int128
Genuinely arbitrary precisionPython, if the judge allows it

See Big Integer Arithmetic for a minimal hand-rolled implementation.

When it does appear

Problems that genuinely require it: exact Fibonacci or factorial values, cryptography-flavoured tasks, and “print the exact answer” problems with -digit outputs. In those, a base- schoolbook implementation is nearly always sufficient — FFT-based multiplication is needed only above a few thousand digits.

See also: Karatsuba · Toom-Cook · Big Integer Arithmetic