A magnitude comparator is a combinational logic circuit that compares two binary numbers and determines their relative magnitude. It generates one of three outputs to indicate whether the first number is greater than (A > B), less than (A < B), or equal to (A = B) the second number.
- Magnitude comparators compare binary numbers without performing arithmetic operations.
- They are commonly used in processors, digital controllers, sorting circuits, and decision-making systems.

Working
A magnitude comparator compares two binary numbers by checking their bits from the most significant bit (MSB) to the least significant bit (LSB).
- If a bit of A is greater than the corresponding bit of B, the A > B output becomes HIGH.
- If a bit of A is less than the corresponding bit of B, the A < B output becomes HIGH.
- If the corresponding bits are equal, the comparator checks the next lower bit.
- If all corresponding bits are equal, the A = B output becomes HIGH.
A magnitude comparator can be implemented using logic gates such as XOR, AND, OR, and NOT, or by cascading multiple comparators to compare larger binary numbers.
Types of Magnitude Comparator
1-Bit Magnitude Comparator
A 1-bit magnitude comparator compares two single-bit binary numbers (A and B) and generates one of three outputs to indicate whether A > B, A < B, or A = B.
Truth Table:
| A | B | A < B | A = B | A > B |
|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 |
| 1 | 1 | 0 | 1 | 0 |
The Boolean expressions for each output are:
A > B = AB'
A < B = A'B
A = B = A'B' + AB

2-Bit Magnitude Comparator
A 2-bit magnitude comparator compares two 2-bit binary numbers (A1A0 and B1B0) and generates one of three outputs to indicate whether A > B, A < B, or A = B.
Truth Table:
| INPUT | OUTPUT | |||||
|---|---|---|---|---|---|---|
| A1 | A0 | B1 | B0 | A<B | A=B | A>B |
| 0 | 0 | 0 | 0 | 0 | 1 | 0 |
| 0 | 0 | 0 | 1 | 1 | 0 | 0 |
| 0 | 0 | 1 | 0 | 1 | 0 | 0 |
| 0 | 0 | 1 | 1 | 1 | 0 | 0 |
| 0 | 1 | 0 | 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 | 1 | 0 | 0 |
| 1 | 0 | 0 | 0 | 0 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 | 0 | 1 |
| 1 | 0 | 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 1 | 1 | 0 | 0 |
| 1 | 1 | 0 | 0 | 0 | 0 | 1 |
| 1 | 1 | 0 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 0 | 1 | 0 |
The following logic circuit implements a 2-bit magnitude comparator.

4-Bit Magnitude Comparator
A 4-bit magnitude comparator compares two 4-bit binary numbers (A3A2A1A0 and B3B2B1B0) and generates one of three outputs to indicate whether A > B, A < B, or A = B.
Comparison Conditions
A > B when:
- A3 > B3
- A3 = B3 and A2 > B2
- A3 = B3, A2 = B2 and A1 > B1
- A3 = B3, A2 = B2, A1 = B1 and A0 > B0
A < B when:
- A3 < B3
- A3 = B3 and A2 < B2
- A3 = B3, A2 = B2 and A1 < B1
- A3 = B3, A2 = B2, A1 = B1 and A0 < B0
A = B only when all corresponding bits are equal:
A3 = B3, A2 = B2, A1 = B1, and A0 = B0
The following logic circuit implements a 4-bit magnitude comparator.

Cascading Comparator
A cascading comparator is formed by connecting two or more smaller magnitude comparators to compare larger binary numbers. The outputs (A > B, A = B, and A < B) of the lower-order comparator are connected to the cascade inputs of the higher-order comparator, allowing comparisons of numbers with more than four bits.

Advantage
- Fast Comparison: Produces comparison results quickly, making it suitable for high-speed digital systems.
- Simple Design: Can be implemented using basic logic gates, making the circuit easy to design and understand.
- Easy Integration: Easily interfaces with processors, ALUs, and other digital components for comparison tasks.
- Scalable: Multiple comparators can be cascaded to compare binary numbers with larger bit widths.
Disadvantages
- Limited Bit Width: A single comparator can compare only a fixed number of bits, requiring cascading for larger numbers.
- Higher Circuit Complexity: Comparing larger binary numbers requires additional logic gates and interconnections.
- Increased Power Consumption: Larger comparator circuits consume more power due to the increased number of logic components.
Applications
- Processors and Microcontrollers: Compare binary data during arithmetic operations, address checking, and instruction execution.
- Control Systems: Compare sensor or input values with reference values to trigger specific control actions.
- Password Verification: Check whether the entered binary data matches the stored value in security and authentication systems.
- Sorting Circuits: Compare two binary numbers to determine their order in digital sorting applications.