Complements: 1’s complement, 2’s complement

  

Complements

·       Methods used to simplify arithmetic operations (especially subtraction) and represent negative numbers in binary systems.

·       Helpful when working with signed binary numbers.

 

Importance of Complements

  1. Representing Negative Numbers: Negative numbers are represented in binary systems without separate "negative markers."
  2. Simplifying Arithmetic: Operations like subtraction can be performed as addition by adding complements.
  3. Efficient Hardware Design: use for simpler and faster arithmetic circuits.

Types of Complements

  1. Radix Complement (2's Complement for binary numbers)
  2. Diminished Radix Complement (1's Complement for binary numbers)

 

Note:- These complements are named based on the base (radix) of the number system. For binary numbers, the base is 2.


1.    1's Complement (Diminished Radix Complement)

Obtained by inverting all the bits (changing 1 to 0 and 0 to 1) of binary number.

  • Representation:
    • Positive numbers remain unchanged.
    • Negative numbers are represented as the 1's complement of their absolute value.

Steps to Find 1's Complement:

  1. Write the binary representation of the number.
  2. Invert all bits (flip 1 to 0 and 0 to 1).

Example:

For a 4-bit representation:

  • +5 = 0101
  • -5 = 1's complement of 0101 = 1010

Advantages:

  • Simple to compute.

Disadvantages:

  • There are two representations for 0:
    • Positive 0: 0000
    • Negative 0: 1111

2's Complement (Radix Complement)

Obtained by inverting all the bits (1's complement) of a binary number and then adding 1 to the least significant bit (LSB).

  • Representation:
    • Positive numbers remain unchanged.
    • Negative numbers are represented as the 2's complement of their absolute value.

Steps to Find 2's Complement:

  1. Write the binary representation of the number.
  2. Invert all bits (1's complement).
  3. Add 1 to the result.

Example:

For a 4-bit representation:

  • +5 = 0101
  • -5:
    1. Take 1's complement of 0101: 1010
    2. Add 1: 1010 + 1 = 1011

 

Use 2's Complement

  1. Single Representation for Zero: Only one representation (0000).
  2. Simplified Arithmetic: Subtraction is performed by adding the 2's complement of a number.
  3. Sign Bit: The most significant bit (MSB) serves as the sign bit (0 for positive, 1 for negative).

Comparison Table:- Key Differences Between 1's Complement and 2's Complement

Feature

1's Complement

2's Complement

Definition

Base - 1 Complement

Base Complement

Representation

Invert all bits

Invert all bits, then add 1

Zero Representation

Two (positive and negative)

Single representation

Use in Modern Systems

Rarely used

Widely used


Example of Signed Numbers (4-bit)

Decimal

Binary (1's Complement)

Binary (2's Complement)

+5

0101

0101

-5

1010

1011

In modern computing systems, 2's complement is the preferred representation because it simplifies hardware design and arithmetic operations.

------------------------------------------------------------------------------------------- 

Post a Comment

0 Comments