Skip to content
myAudience.
← Explore the library

Unsigned addition, multiplication and discarded carries

By UK A Level Computer Science · independent study · myAudience

Nine aligned columns add 187(010111011) and 92(001011100) to 279(100010111). The corrected bracket spans all eight teal low bits 00010111, which store 23; the amber high carry has value 256. A separate multiplication equation 13×11=13+26+104=143 accompanies 10001111. The panel does not display partial-product rows. All numbers are stipulated teaching examples; see exact text and worked answer. No measured processor or instrument performance is depicted.

Original generated teaching illustration, built-in imagegen,2026-10-04; mathematical model,not documentary photograph. · Original generated artwork; operator provenance/rights and independent scientific acceptance pending.

Unsigned addition, multiplication and discarded carries

Unsigned binary assigns nonnegative place weights to every bit. In an n-bit field, the smallest value is zero and the largest is the sum 1+2+…+2^(n −1)=2^n −1. This range follows from the representation, not from a particular programming language. Python integers can grow beyond a chosen width, so an eight-bit teaching model must explicitly enforce or simulate that width. A language successfully producing 279 does not show that an eight-bit register can store 279 as an unsigned value.

Binary addition uses the same place-value principle as decimal addition, with carries when a column total reaches two. Zero plus zero is zero; one plus zero is one; one plus one is binary 10, writing zero and carrying one. Two one-bits plus an incoming carry give binary 11, writing one and carrying one. A trace should record the carry entering or leaving each column consistently. Losing a carry between columns is an algorithm error; discarding a correct final carry at the field boundary is a representation decision that may cause overflow.

For 187+92, the eight-bit operands are 10111011 and 01011100. Their mathematical sum is 279, represented as 100010111 using nine bits. Keeping only the lower eight gives 00010111, or 23. The modular relation is 279=256+23. That low-byte value is not an approximate version of 279 suitable for an ordinary count: it differs by 256 and can silently violate an allocation or capacity postcondition. Return a defined overflow outcome or use a sufficient width when the application requires the full value.

Carry out is a useful unsigned addition overflow indicator when the operands and result width are fixed consistently. In signed arithmetic it has a different meaning, addressed in the next lesson. Do not use a hardware flag's name without stating its interpretation. If inputs can themselves exceed the field, validating only the final sum is inadequate: a negative or oversized input may already have been converted incorrectly. Boundary validation should check each operand and the operation's promised result domain.

Binary multiplication forms shifted partial products. Multiplying 13, binary 1101, by 11, binary 1011, includes 13×1,13×2 and 13×8 because those multiplier bits are one. The contributions 13+26+104=143 give 10001111, which fits eight unsigned bits. The zero multiplier bit contributes no partial product. The shift weights are mathematical powers of two; if each shifted intermediate is prematurely truncated to an inadequate width, a correct final sum is no longer guaranteed.

The product of two n-bit unsigned values may need 2 n bits, since the largest product is(2^n −1)^2, less than 2^(2 n). This is a sufficient worst-case width, not a claim that every product uses all 2 n positions. For n=8,255×255=65,025 requires sixteen bits, while 13×11 needs eight. When a specification promises an eight-bit result, the accepted operand combinations must ensure the product is at most 255, or overflow must be an explicit outcome. Assuming operands individually fit is insufficient.

A saturating representation clamps an excessive result to the maximum; a modular one wraps; an exact representation can increase width; and a checked operation can reject. These are different behavioural contracts. Saturation may suit a bounded display but destroys the exact count; wrapping may suit some deliberate modular algorithms but not an inventory total. There is no universally correct choice detached from the application. Tests at zero, maximum, just-over-maximum and mixed-sized operands should accompany an argument about the selected contract.

Reading the diagram: The plate's highlighted ninth column is outside the eight-bit storage bracket. Reading only the bracket gives 23 while including the carry gives 279; the visual separates these rather than presenting them as equal. The multiplication panel's summed contributions correspond to the multiplier's 1,2 and 8 place values and sum to 143. Use the drawing to check a hand trace, not to infer actual processor timing. A rigorous answer proves width sufficiency, identifies any discarded information and states a meaningful failure or alternative representation.

Worked example: Add 187 and 92 in eight-bit unsigned form, then multiply 13 by 11 and compare their representability.

10111011+01011100=100010111, or 279; nine bits are needed.

The low eight bits 00010111 represent 23; the carry accounts for 256.

1101×1011 has partial contributions 13,26,104; total 143=10001111 fits 8 bits.

Answer: The addition overflows eight unsigned bits; the multiplication result fits. A low-byte result is not the full addition result.

Check your understanding: A system multiplies two eight-bit quantities into an eight-bit output. Give a failing pair, derive a sufficient general output width, and compare wrap, saturation and rejection for 250+10 in an inventory application.

Answer: 255×255=65,025 exceeds 255 and needs sixteen bits. Since each operand is below 2^8, the product is below 2^16, so sixteen bits suffice for every accepted pair. For 250+10, the exact result 260 becomes 4 under eight-bit wrapping or 255 under saturation; both lose units. Rejection preserves the distinction between a valid quantity and failure but requires the caller to handle it. A wider exact field stores 260. For a promised exact inventory count, widening or a checked failure is defensible; silent wrap or saturation violates that promise.

Why: Individual operand validity does not imply result validity. Require derivation of the worst-case width and connect the chosen overflow policy to the postcondition, not a claim that a language or hardware convention is automatically suitable.