KEVOS
ArticlesServicesCase studiesAboutContact
ArticlesServicesCase studiesAboutContact
← ArticlesMultiprecision Integer RepresentationEngineering · Engineering MathematicsLesson 706/884← PrevNext →
ArticlePublished 7 Aug 20262 min readBy Kevin Joginmultiprecisionbignumarbitrary precisionrepresentation
On this page

Ask about this page

KEVOS AIMultiprecision Integer Representation

KEVOS knowledge first · trusted web sources when needed

Multiprecision Arithmetic

Multiprecision Integer Representation

How arbitrary-precision integers are stored, why the base is chosen to match the machine word, and the consequences for every algorithm above.

Engineering / MathematicsMultiprecision Arithmetic2 min readKV-MATH-0505

Every algorithm in this collection operates on integers far larger than a machine word. The representation chosen for those integers sets the cost of every operation performed on them, so it is worth understanding before anything else.

Positional representation in base B

A multiprecision integer is stored as a sign together with an array of digits in some base B, least significant first. The digits are conventionally called limbs or words.

x = sign sum from i=0 to k-1 of a_i B^i, 0 <= a_i < BThe a_i are the limbs; k is the length.

Choosing the base

The base is chosen to be a power of two matching the machine word — typically B = 2^32 or B = 2^64. Two reasons dominate.

Hardware alignment

Addition, multiplication and division of single limbs map directly onto machine instructions. A non-power-of-two base would require explicit reduction after every operation.

Carry handling

With a power-of-two base, extracting the carry from a sum is a shift and a mask rather than a division.

Pitfall

A multiplication of two full-width limbs produces a double-width result. If the language does not expose a double-width integer type, the base must be halved — using 2^32 limbs on a 64-bit machine — which roughly doubles the limb count and the work.

Normalisation

Two invariants are maintained by every well-behaved implementation, and violating either produces bugs that surface far from their cause.

  • The most significant limb is non-zero, so the length is unique.
  • Zero has a canonical representation, usually length zero, and its sign is not consulted.

Cost consequences

Costs relative to limb count k
OperationCost in limbsNotes
Addition, subtractionO(k)Linear, carry propagation only
ComparisonO(k) worst caseLength check first, usually O(1)
MultiplicationO(k^2) schoolbookSee Karatsuba
DivisionO(k^2)Larger constant than multiplication
Shift by whole limbsO(k) or freeOften just an offset

Key point

Addition is linear, multiplication is quadratic. Any algorithm that can trade a multiplication for several additions is usually worth restructuring — this is the principle behind both Karatsuba and the binary GCD.

Frequently Asked Questions

Should I write my own multiprecision library?
Almost never. The arithmetic is subtle, the performance gap against a mature library is large, and the bugs are hard to find. Write one only as a learning exercise.
Why store limbs least significant first?
Because carries propagate upward. Storing them in that order lets addition and multiplication walk the array forward, which is friendlier to memory prefetching and simplifies growing the array.

Source. Henri Cohen, A Course in Computational Algebraic Number Theory, Springer GTM 138 — 1.2.1. Structural reference unverified: the source file was not available during authoring; chapter and section numbers are taken from the published edition and have not been checked against a physical copy.

Related pages

  • Algorithm Notation and Complexity Conventions
  • Multiprecision Addition and Subtraction

Continue learning

The Four Core Computational Tasks of Number FieldsArticle · Engineering MathematicsNEXT LESSON →Multiprecision Addition and SubtractionArticle · Engineering MathematicsLearning Pathways Through Computational Number TheoryArticle · Engineering MathematicsSchoolbook and Karatsuba MultiplicationArticle · Engineering Mathematics
KEVOS · Engineering, manufacturing and project improvement
ArticlesServicesCase studiesAboutContact
© 2026 KEVOS®