# Magnitude Comparator: Types, Applications, and Design

In this tutorial, we will learn about the magnitude comparators in Digital Electronics, the different types of comparators, the designing of 1-bit magnitude comparators, the designing of 2-bit magnitude comparators, and various applications of magnitude comparators. By Saurabh Gupta Last updated : May 11, 2023

## Magnitude Comparator

The word **comparator** itself means "**to compare**".

So, what does it **compare to**? In Digital Electronics, **comparators** are used to compare two digital and binary numbers to find out which number is greater, smaller, or equal to the other number. Basically, we design a logical circuit that has two inputs (*A* and *B*) and three outputs in order to give a result whether a number is equal to another number (*A=B*) or less than another number (*A<B*) or greater than another number (*A>B*).

## Types of Magnitude Comparator

There are basically four types of magnitude comparators which we study in digital electronics which are listed below:

- 1-bit magnitude comparator
- 2-bit magnitude comparator
- 4-bit magnitude comparator
- 8-bit magnitude comparator

In this article, we will be reading about the designing process of 1-bit and 2-bit magnitude comparators and later two can be designed following the same principles.

## Applications of Magnitude Comparators

Magnitude comparators are used at several places some of which are listed below:

- They are used in the Central Processing Unit (CPUs) and Microcontrollers (MCUs).
- They are used for authorization purposes (such as password management) and biometric applications.
- They are used to implement controllers and also in servo motors.
- They are used to address the decoding security of the computers.
- They are also used in data comparison of variables like temperature, pressure, etc.

## Magnitude Comparators Designing

### 1. Designing of 1-bit Magnitude Comparator

The comparator which is used to compare 2-bits is called a 1-bit magnitude comparator. In this comparator, two inputs are present for a 2-bit numbers and three outputs are present to check whether a number is equal to, less than or greater than the other number.

Now, let us take a look at the truth table of a 1-bit comparator.

From the above truth table, we can see logical expression for each output

expressed as below:

A > B: AB'

A < B: A'B

A = B: A'B' + AB

The expression for A=B is similar to the equation of an EX-NOR Gate. Therefore, A= B can also be represented as A ⨀ B.

**Circuit diagram of 1-bit comparator**

### 2. Designing of 2-bit Magnitude Comparator

The comparator which is used to compare to binary number each of 2-bits is called 2-bit magnitude comparator. In these comparators, four inputs and three output are present to check whether a number is equal to, less than or greater than the other number

The truth table for 2-bit comparator can be designed as:

By seeing the above truth table K-mapping for following outputs are:

Logical expression as derived from the K-Map for A>B can be given as:

**A>B = A _{1}B_{1}' + A_{0}B_{1}'B_{0}' + A_{1}A_{0}B_{0}'**

Logical expression as derived from the K-Map for A<B can be given as:

**A<B = A _{1}'B_{1 }+ A_{0}'B_{1}B_{0} + A_{1}'A_{0}'B_{0}**

Logical expression as derived from the K-Map for A>B can be given as:

**A=B: A _{1}'A_{0}'B_{1}'B_{0}' + A_{1}'A_{0}B_{1}'B_{0} + A_{1}A_{0}B_{1}B_{0 }+ A_{1}A_{0}'B_{1}B_{0}'**

**: A**

_{1}'B_{1}' (A_{0}'B_{0}' + A_{0}B_{0}) + A_{1}B_{1}(A_{0}B_{0 }+ A_{0}'B_{0}')**: (A**

_{0}B_{0}+ A_{0}'B_{0}') (A_{1}B_{1}+ A_{1}'B_{1}')**A=B: (A**

_{0 }⨀ B_{0}) (A_{1}⨀ B_{1)}**Circuit diagram of 2bit comparator**

Related Tutorials

- Sequential Circuits in Digital Electronics
- Concept of Read Only Memory (ROM)
- Concept of Random Access Memory (RAM)
- Conversion of Flip-Flops
- Solved Examples on Conversion of Flip-Flops
- Programmable Array Logic (PAL)
- Programmable Logic Array (PLA)
- Magnetic Memories: Types, Advantages, and Disadvantages
- The JK Flip Flop in Digital Electronics
- Race Around Condition in JK Flip Flop and T Flip Flop
- Master-Slave JK Flip Flop and Its Working
- Programmable Logic Devices in Digital Electronics
- How to Design Asynchronous Counters?
- How to Design Synchronous Counters?
- Examples of Designing of Synchronous Mod-N Counters

Comments and Discussions!