KEVOS
ArticlesServicesCase studiesAboutContact
ArticlesServicesCase studiesAboutContact
← ArticlesMultiprecision Addition and SubtractionEngineering · Engineering MathematicsLesson 707/884← PrevNext →
ArticlePublished 7 Aug 20262 min readBy Kevin Joginadditionsubtractioncarry propagationmultiprecision
On this page

Ask about this page

KEVOS AIMultiprecision Addition and Subtraction

KEVOS knowledge first · trusted web sources when needed

Multiprecision Arithmetic

Multiprecision Addition and Subtraction

Carry and borrow propagation, sign handling, and why addition sets the baseline cost against which every other operation is measured.

Engineering / MathematicsMultiprecision Arithmetic2 min readKV-MATH-0506

Addition is the cheapest non-trivial multiprecision operation and the reference point for all the others. Its structure is simple; the complications are entirely in sign handling.

Unsigned addition

Unsigned addition of k-limb integers

  1. AlignTreat the shorter operand as zero-padded to the length of the longer.
  2. Add limbwiseAdd corresponding limbs plus the incoming carry.
  3. Propagate carryThe carry out is 1 exactly when the sum exceeds the base; with a power-of-two base this is a shift.
  4. Extend if neededA final carry adds one limb to the result.

Note

The result of adding two k-limb numbers has at most k+1 limbs. Allocating for k+1 up front avoids a reallocation in the common case.

Sign handling

Signed addition dispatches on the signs of the operands. This is where implementations most often go wrong.

Dispatch table for signed addition
SignsActionResult sign
SameAdd magnitudesCommon sign
Different, |a| > |b|Subtract |b| from |a|Sign of a
Different, |a| < |b|Subtract |a| from |b|Sign of b
Different, |a| = |b|Result is zeroCanonical zero, no sign

Pitfall

The equal-magnitude case must produce the canonical zero. Leaving a signed zero in the representation breaks comparison and every downstream equality test.

Subtraction and borrow

Subtraction of magnitudes assumes the first operand is the larger, which the dispatch above guarantees. Borrow propagates exactly as carry does, and the result may have leading zero limbs that must be trimmed to restore normalisation.

Cost

Cost of addition = O(k) limb operationsk is the length of the longer operand.

This linear cost is the baseline. Algorithms are frequently designed to replace multiplications and divisions with additions and shifts for exactly this reason — see the binary GCD.

Source. Henri Cohen, A Course in Computational Algebraic Number Theory, Springer GTM 138 — 1.2.2. 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

  • Multiprecision Integer Representation
  • Schoolbook and Karatsuba Multiplication

Continue learning

Multiprecision Integer RepresentationArticle · Engineering MathematicsNEXT LESSON →Schoolbook and Karatsuba MultiplicationArticle · Engineering MathematicsThe Four Core Computational Tasks of Number FieldsArticle · Engineering MathematicsAsymptotic Cost of Integer MultiplicationArticle · Engineering Mathematics
KEVOS · Engineering, manufacturing and project improvement
ArticlesServicesCase studiesAboutContact
© 2026 KEVOS®