Skip to content

carry / partial [terminology]

Terminology

Usage

  • Use carry for bits or digits propagated to the next position.
  • Use partial for an incomplete intermediate result.
  • Neither is a final answer or additive total in the usual sense.
a &= mask
b &= mask
while b:
    partial = (a ^ b) & mask # Sum without carry.
    carry = ((a & b) << 1) & mask # Carry, shifted to the next bit.
    a, b = partial, carry

See 371. Sum of Two Integers.