Understanding Binary Complements: r’s and (r–1)’s Complement Made Easy

What Are Complements in Binary?

Definition:

A complement is an alternative way to represent a number—especially negative numbers—in digital systems using binary. They help us simplify subtraction and perform signed arithmetic using only addition circuits in hardware.

Why Are Complements Required?

  • Simplify Subtraction:

Converts subtraction into addition, making computation faster and more efficient.

  • Used in Digital Circuits:
Computers commonly use 2’s complement to represent both positive and negative numbers seamlessly
  • Hardware Simplicity:

Eliminates the need for separate subtraction circuits—only adder circuits are required.
  • Avoid Ambiguity:

Ensures unique representation of zero and negative numbers (especially with 2’s complement).

Types of Complements in Base-r (Eg. Binary = Base 2)

  • (r–1)’s Complement

    • Formula:

    • Shortcut (Binary): Invert all bits (flip 1 ↔ 0)

    • Example: 0101 → 1010

  • r’s Complement

    • Formula:

    • Shortcut (Binary): Invert all bits + add 1 → This is 2’s complement

    • Example:                
                    

Where:

  • r = Base of the number system (binary → 2)

  • n = Number of digits (bits)

  • N = Original number

Shortcut Methods for other bases:

  • (r–1)’s Complement:
                Obtained by subtracting each digit from a largest symbol used in that particular number of system.

  • r’s Complement (2’s complement in binary):
                (r-1)'s complement + 1 (to LSB)

Range of Binary Representations

  • 1’s Complement

    • Positive Range: 

    • Negative Range:

    • Note: Has two representations of zero (positive and negative 0)

    • Total Values Represented:

  • 2’s Complement

    • Positive Range:

    • Negative Range:

    • Note: Has only one representation of zero

    • Total Values Represented:

Comparison of 1’s and 2’s Complement Representations

  • Simple to Compute:

    In 1’s complement, you simply invert all the bits (flip 0 to 1 and 1 to 0).
    In 2’s complement, you invert all bits and then add 1—slightly more effort, but still straightforward.

  • Arithmetic Simplification:
    Both systems use complements for subtraction, but 2’s complement simplifies the process since there's no need to detect the sign separately during operations.

  • Double Zero Issue:
    1’s complement suffers from ambiguity due to the presence of both +0 and –0.
    2’s complement avoids this problem by having only one representation of zero.

  • Hardware Implementation:

    1’s complement requires end-around carry handling, making hardware design slightly complex.
    2’s complement is more efficient in hardware, as standard binary adders can be used directly without special rules.

Subtraction Using Complements

Convert: ABA + (complement of B)

Using (r–1)’s Complement (1’s complement)

Steps:

  1. Find 1’s complement of B

  2. Add to A

  3. If carry, add it back to LSB (end-around carry)

  4. If no carry, result is negative → re-complement the result and add negative sign

Example: 5 – 3 in 4-bit

5  = 0101  
3  = 0011 → 1’s comp = 1100  
Sum = 0101 + 1100 = 10001 → carry → add to LSB: 0001 + 1 = 0010 

Example: 3 – 5

3  = 0011  
5  = 0101 → 1’s comp = 1010  
Sum = 0011 + 1010 = 1101 → No carry → take 1’s comp of result: 0010 → –2

Using r’s Complement (2’s complement)

Steps:

  1. Find 2’s complement of B

  2. Add to A

  3. If carry, discard it (positive result)

  4. If no carry, result is negative → already in 2’s complement

Example: 5 – 3

5  = 0101  
3  = 0011 → 2’s comp = 1101  
Sum = 0101 + 1101 = 10010 → discard overflow → 0010 

Example: 3 – 5

3  = 0011  
5  = 0101 → 2’s comp = 1011  
Sum = 0011 + 1011 = 1110 → No carry → result is –2 (already in 2’s complement)

Comparison of (r–1)’s and r’s Complement:

  • Carry Handling:

       (r–1)’s Complement (1’s): Requires end-around carry (add carry-out back to

LSB).

     r’s Complement (2’s): No special handling needed—simply discard the extra

carry.

  • Zero Representation:
        1’s Complement: Has two representations of zero (+0 and –0).
        2’s Complement: Has only one unique zero, which avoids ambiguity.
  • Negative Number Range:

        1’s Complement: Represents from –(2ⁿ⁻¹ – 1) to –0.

        2’s Complement: Represents from –2ⁿ⁻¹ to –1, covering an extra negative
value
  • Use in Computers:

        1’s Complement: Not used in modern processors (due to ambiguity and

complexity).

        2’s Complement: Widely used because it's efficient and simple to implement
in hardware.

Complements are the unsung heroes of binary arithmetic, enabling computers to perform subtraction using only addition hardware. Among them, 2’s complement stands out as the most practical and widely used due to its simplicity, unambiguous zero, and seamless integration into digital circuits. Whether you’re working on embedded systems, CPUs, or digital logic, mastering complements will sharpen your understanding of how machines handle negative numbers behind the scenes. Keep exploring, and you’ll uncover how this fundamental concept powers modern computing at its core.

Stay tuned to hobitronics.blog

To know more about Binary Data Representation - Click here!

Comments

Popular posts from this blog

Why Does My Old Phone Charge Slowly But Heat Up More?

Why Do Phone Chargers Get Hot While Charging?

Pulse Code Modulation (PCM): The Digital Backbone of Modern Communication

Why Does Tea Taste Weird on an Induction Stove?

Delta Modulation and Adaptive Delta Modulation: Simplifying Digital Voice Communication

🎧 Sampling and Quantization Explained

Semiconductor Behavior at 0K vs. 300K:Energy Band Gap

Controlling RGB LEDs with PWM Using Arduino