Data Representation (8hrs) · Computer Fundamentals & Emerging Technologies

Signed number representation (1's complement)

Watch lectures

Signed number representation (1's complement)

1. Why Signed Representation is Needed

A binary pattern has no inherent sign — 1111 0110 means 246 as an unsigned number. To handle negative values, three schemes were developed:

Scheme Idea Status
Sign-magnitude MSB = sign, rest = magnitude Simple, obsolete (two zeros)
1's complement Negative = bitwise inversion of the positive Historic (needs end-around carry)
2's complement Negative = inversion + 1 Universal in modern CPUs

In all three, the MSB acts as the sign bit — 0 means positive, 1 means negative.

2. The Problem with Sign-Magnitude (for comparison)

+9=0 0001001+9 = 0\ 0001001, −9=1 0001001-9 = 1\ 0001001 in 8 bits. Range for nn bits is

−(2n−1−1)to+(2n−1−1)-(2^{n-1} - 1) to +(2^{n-1} - 1)

(8 bits → −127 to +127). Drawbacks: two representations of zero (+0 = 0000 0000, −0 = 1000 0000) and addition/subtraction need extra logic to compare magnitudes and signs.

3. 1's Complement — Definition

The 1's complement of a binary number is obtained by inverting every bit (each 0 → 1, each 1 → 0). For an nn-bit negative number:

−Xisstoredas(2n−1)−X-X is stored as (2^{n} - 1) - X

So 1's complement is the bitwise NOT of the magnitude in exactly nn bits.

Decimal Magnitude (8-bit) 1's complement (negative form)
+9 0000 1001 —
−9 0000 1001 → invert 1111 0110
+45 0010 1101 —
−45 invert 1101 0010
+0 0000 0000 —
−0 invert 1111 1111

4. Range and the Dual-Zero Problem

Same as sign-magnitude: −(2n−1−1)-(2^{n-1} - 1) to +(2n−1−1)+(2^{n-1} - 1), i.e. −127…+127 for 8 bits.
Both +0 (0000 0000) and −0 (1111 1111) exist, so only 2n−12^{n} - 1 distinct values are representable out of 2n2^{n} patterns.

5. Arithmetic with 1's Complement — Addition

Add the two 8-bit patterns as ordinary binary, and then handle the carry out of the MSB by end-around carry: if a carry is generated, add it back to the LSB (wrap around).

Example 1: 9 + (−4)

   0000 1001     (+9)
 + 1111 1011     (−4 in 1's complement)
 ───────────
 1 0000 0100     carry out → add it back to the LSB
   0000 0100
 + 0000 0001
 ───────────
   0000 0101  = +5   ✓

Example 2: (−5) + 2

   1111 1010     (−5)
 + 0000 0010     (+2)
 ───────────
   1111 1100     no carry out → result is negative;
   magnitude = 1's complement of 1111 1100 = 0000 0011 = 3   → answer −3   ✓

Example 3: (−5) + (−2)

   1111 1010 + 1111 1101 = 1 1111 0111 → end-around carry
   → 1111 1000 → negative → magnitude = 0000 0111 = 7 → answer −7   ✓

6. Subtraction with 1's Complement

Use the identity A − B = A + (1's complement of B), then apply the same carry rule.

Example: 7 − 3

   0000 0111     (+7)
 + 1111 1100     (1's comp of +3)
 ───────────
 1 0000 0011 → end-around carry → 0000 0100 = +4   ✓

Example: 3 − 7

   0000 0011 + 1111 1000 = 1111 1011 → no carry → negative
   magnitude = 0000 0100 = 4 → answer −4   ✓

7. Advantages and Limitations

Advantages Limitations
Toggling a number's sign needs only an inverter (no adder) Two zeros (+0, −0) complicate comparisons and equality tests
Subtraction reduces to addition with the complement Needs the extra end-around carry step — an extra clock cycle in hardware
Easy to implement for small, teaching-oriented circuits Range is one value smaller than 2's complement (−127 vs −128 in 8 bits)
Forms the first step in finding the 2's complement Not used in modern CPUs (all use 2's complement)

8. Exam Points

  • Explain sign-magnitude, 1's complement and 2's complement representation with the same example — 5-7 marks, very frequent.
  • Find the 1's complement of a given positive/negative number — 3 marks.
  • Add/subtract two signed 8-bit numbers using 1's complement; explain the end-around carry — 5 marks, frequent.
  • What is the dual-zero problem? Which scheme solves it and how? — 3-5 marks.
  • State the range of numbers representable in 1's complement for nn bits — 3 marks.
AI LearningWeb Platform

Coursify — Personal AI Course Generator

Struggling with a difficult subject or concept? Turn any engineering topic into a structured course with interactive lessons, quizzes, and research-backed explanations.

← All Computer Fundamentals & Emerging Technologies modules