Sign-magnitude and one's-complement arithmetic
Start with a representation contract
The bits alone do not determine a signed value. This lesson compares three n-bit integer encodings for n≥2. There are no fractional bits. A prime on a Boolean variable still means NOT; “one's complement” here names an integer representation as well as the bitwise inversion operation used to form its negatives.
Prerequisites: unsigned binary and two's complement. Goals: decode alternate signed encodings, preserve values when widening, and use the correct arithmetic rule rather than applying two's-complement addition indiscriminately. We specify how zero results are reported because two encodings here have two zero patterns.
For sign-magnitude, the top bit s is a sign and the remaining n−1 bits form unsigned magnitude m. Its value is (−1)^s m. At width five, 10110 means −6, not −10. Negative zero is 10000; positive zero is 00000. Both denote numerical zero although their bits differ. Range is −(2^(n−1)−1) through +(2^(n−1)−1).
For one's complement, a nonnegative number has its ordinary zero-leading binary pattern. A negative −m is formed by inverting every bit of the n-bit positive pattern for m. For a top-bit-one pattern with unsigned reading U, value=U−(2^n−1). Thus width-five 11001 has U=25 and means 25−31=−6. Its all-ones pattern 11111 denotes negative zero. Its range matches sign-magnitude.
Compare width-five two's complement: negative −6 is 11010, there is only zero 00000, and the range is −16…15. The extra negative value comes from using the former second-zero pattern for a distinct number, not from adding a storage bit.
| Five-bit representation | −6 | Zero patterns | Least value |
|---|---|---|---|
| Sign-magnitude | 10110 | 00000, 10000 | −15 |
| One's complement | 11001 | 00000, 11111 | −15 |
| Two's complement | 11010 | 00000 | −16 |
Encoding, negation and widening
Worked example 1: encode −19 at width eight. The positive pattern is 00010011. Sign-magnitude replaces only the sign: 10010011. One's complement inverts all eight bits: 11101100. Two's complement adds one to that inverted pattern: 11101101. Check all three by their separate decoding rules.
Negation in sign-magnitude flips just the sign bit. In one's complement it flips all bits. Either operation exchanges the two zeros. In two's complement invert-and-add-one has the special most-negative boundary already studied. The symmetric alternate encodings have no analogous nonzero negation overflow, because every representable nonzero magnitude has both signs.
To widen sign-magnitude, preserve the sign at the new top and insert zeros before the magnitude. Width-five 10110 (−6) becomes width-eight 10000110. Simply copying the sign bit to obtain 11110110 would instead mean −118. To widen one's complement, repeat the sign bit: 11001 becomes 11111001. Check 249−255=−6. Sign extension works for one's and two's complement, but it does not mean their negative encodings are identical. Preserve either zero's encoding if asked to preserve its sign; otherwise numerical zero may be canonicalized to positive zero.
Sign-magnitude addition uses magnitudes
For equal signs, add magnitudes, keep the common sign, and check whether the magnitude exceeds 2^(n−1)−1. For opposite signs, subtract the smaller magnitude from the larger and take the larger magnitude's sign. If magnitudes are equal, the numerical result is zero; our worked sign-magnitude algorithm returns positive zero.
Worked example 2: at width five, −9+6 uses magnitudes 9 and 6. Subtract to get 3 and retain the negative sign: 10011. Blindly adding patterns 11001+00110 produces 11111, which sign-magnitude decodes as −15, not −3. This failure explains why the representation needs sign-aware control.
For −11+(−7), magnitude 18 exceeds 15, so exact signed overflow occurs. Do not treat a truncated magnitude as an exact answer. If only numerical addition is requested, report overflow rather than inventing a wraparound convention.
One's-complement addition and end-around carry
Add the two n-bit patterns as unsigned bit strings. If a carry emerges beyond bit n−1, add it back to the low n-bit result. This is end-around carry, not two's-complement carry discard. After this correction, decode using one's complement and separately check whether the exact signed sum is in range. We show raw zero patterns first and canonicalize to positive zero only when explicitly requested.
Why does the carry return? For this encoding, an upper carry has weight 2^n, and 2^n is congruent to 1 modulo 2^n−1. Folding that carry therefore preserves the required residue. The two zero patterns both represent the zero residue. With two n-bit operands and no carry-in, one fold suffices: their sum is at most 2^(n+1)−2, so low bits plus the single carry cannot exceed 2^n−1. This is arithmetic explanation, not an instruction to ignore signed range limits.
Worked example 3: width-five 7+(−3). Encode as 00111+11100=1 00011. Fold the carry: 00011+1=00100, giving +4. Discarding the carry would give +3 and be wrong. For −7+3, use 11000+00011=11011, no outer carry; 27−31=−4. For 7+(−7), 00111+11000=11111, the raw negative-zero encoding; the numerical result is zero.
Worked example 4: 12+7 gives 01100+00111=10011, which decodes as −12. Exact 19 is outside −15…15, so this is overflow despite there being no outer carry. End-around carry is part of encoding arithmetic, not a signed-overflow test. In subtraction a−b, invert all bits of one's-complement b and perform this same addition; do not add an extra initial 1. For width-five 9−4, 01001+11011=1 00100, then fold to 00101=5.
Key points and error checks
- Write width and encoding before interpreting a sign bit. Pattern 10000 means negative zero, −15 or −16 in the three respective encodings.
- Sign-magnitude and one's complement have 2^n patterns but only 2^n−1 distinct numerical values. A bitwise equality test is not automatically numerical equality for their two zeros.
- Sign-magnitude addition needs sign/magnitude cases. One's complement needs end-around carry. Two's complement discards outer carry for the retained result.
- Decode operands, compute exact mathematics, check the declared range, then decode the algorithm's result. This catches overflow independently of the hardware steps.
- Widening and negation rules belong to a representation; do not transfer them by analogy. Normalize a zero only under a stated output convention.
Original practice
These six single-correct MCQs are original learning questions, not previous-year questions. Choose exactly one option.
C01. Decode 5-bit 10000 respectively as sign-magnitude, one's complement and two's complement.
A. −16, −16, −16 B. Negative zero, −15, −16 C. Negative zero, −16, −15 D. −8, −15, −16
Answer: B
A is incorrect: only two's complement assigns −16 here.
B is correct: sign-magnitude has zero magnitude; one's complement is 16−31=−15; two's complement is 16−32=−16.
C is incorrect: the two complement ranges have been interchanged.
D is incorrect: sign-magnitude uses all four low bits, which are zero.
C02. Which 8-bit sign-magnitude pattern preserves the value of 5-bit 10110?
A. 11110110 B. 00010110 C. 10000110 D. 10010110
Answer: C
A is incorrect: copying the sign into magnitude positions gives −118.
B is incorrect: this is +22 in sign-magnitude.
C is correct: retain sign 1 and encode magnitude 6 in seven bits.
D is incorrect: its seven-bit magnitude is 22, giving −22.
C03. Using 5-bit one's-complement addition with end-around carry, what pattern represents 9+(−5)?
A. 00100 B. 00011 C. 00101 D. 11100
Answer: A
A is correct: 01001+11010=1 00011; folding carry gives 00100=4.
B is incorrect: it discards the carry rather than folding it.
C is incorrect: it adds two instead of one after the raw sum.
D is incorrect: 11100 decodes as −3 in this representation.
C04. Without zero canonicalization, what is the raw 5-bit one's-complement result of 6+(−6)?
A. 10000 B. 00001 C. 00000 D. 11111
Answer: D
A is incorrect: this is sign-magnitude negative zero, not the specified raw addition.
B is incorrect: no carry is produced to fold or increment.
C is incorrect: that is numerical zero's canonical pattern, not the raw sum requested.
D is correct: 00110+11001=11111, the negative-zero pattern.
C05. How many distinct numerical integer values can 6-bit one's complement represent?
A. 64 B. 63 C. 62 D. 32
Answer: B
A is incorrect: 64 counts patterns, including two for zero.
B is correct: values −31…31 give 31+1+31=63.
C is incorrect: it excludes numerical zero altogether.
D is incorrect: both positive and negative nonzero values are available.
C06. In 5-bit sign-magnitude arithmetic, what is the exact outcome of −11+(−7)?
A. −2 because only low magnitude bits matter B. +18, representable C. Overflow: −18 is outside the representable range. D. Negative zero because the signs match
Answer: C
A is incorrect: truncating magnitude does not yield the exact sum.
B is incorrect: the sign is negative and magnitude 18 exceeds 15.
C is correct: the exact sum is −18, but the range is −15…15.
D is incorrect: equal negative signs require adding magnitudes, not cancellation.
Scope and sources
This is one bounded Digital Logic lesson, not complete GATE CS coverage. The official syllabus establishes relevance only; the derivations, examples and practice are original. Technical references were used to check representation and circuit conventions, not to reproduce their exercises.
- Official GATE 2027 CS syllabus Section 2
- IISc NPTEL Digital Systems: representation conventions
- CUNY one's-complement end-around carry
Sources checked 14 October 2026.
Sign in to keep your progress. Sign in