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
- Representing
Negative Numbers:
Negative numbers are represented in binary systems without separate
"negative markers."
- Simplifying
Arithmetic:
Operations like subtraction can be performed as addition by adding
complements.
- Efficient
Hardware Design:
use for simpler and faster arithmetic circuits.
Types of
Complements
- Radix
Complement (2's Complement for binary numbers)
- 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:
- Write
the binary representation of the number.
- 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:
- Write
the binary representation of the number.
- Invert
all bits (1's complement).
- Add
1 to the result.
Example:
For a 4-bit representation:
- +5 = 0101
- -5:
- Take
1's complement of 0101: 1010
- Add
1: 1010 + 1 = 1011
Use 2's Complement
- Single
Representation for Zero:
Only one representation (0000).
- Simplified
Arithmetic:
Subtraction is performed by adding the 2's complement of a number.
- 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.
-------------------------------------------------------------------------------------------
0 Comments