GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Main page
  • Contents
  • Current events
  • Random article
  • About Wikipedia
  • Contact us
  • Help
  • Learn to edit
  • Community portal
  • Recent changes
  • Upload file
  • Special pages
  • Search
  • Donate

This view

  • Original page
  • New address

GeezerVison is showing en.wikipedia.org — Digital comparator - Wikipedia

icon
This article needs more citations. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Digital comparator" – news · newspapers · books · scholar · JSTOR
(February 2026) (Learn how and when to remove this message)
For other uses, see Comparator (disambiguation).

A digital comparator or magnitude comparator is a hardware electronic device that takes two numbers as input in binary form and determines whether one number is greater than, less than or equal to the other number. Comparators are used in central processing units (CPUs) and microcontrollers (MCUs). Examples of digital comparator include the CMOS 4063 and 4585 and the TTL 7485 and 74682.

An XNOR gate is a basic comparator, because its output is "1" only if its two input bits are equal.

The analog equivalent of digital comparator is the voltage comparator. Many microcontrollers have analog comparators on some of their inputs that can be read or trigger an interrupt.

Implementation

Digital comparator using multiplexers

Consider two 4-bit binary numbers A and B so

One-bit binary comparator, with outputs for equality, greater than, and less than.

A=A3A2A1A0

B=B3B2B1B0

Here each subscript represents one of the digits in the numbers.

Equality

The binary numbers A and B will be equal if all the pairs of significant digits of both numbers are equal, i.e.,

A3=B3, A2=B2, A1=B1 and A0=B0

Since the numbers are binary, the digits are either 0 or 1 and the boolean function for equality of any two digits Ai and Bi can be expressed as

xi=Ai⋅Bi+Ai‾⋅Bi‾ we can also replace it by XNOR gate in digital electronics.

xi is 1 only if Ai and Bi are equal.

For the equality of A and B, all xi variables (for i=0,1,2,3) must be 1.

So the equality condition of A and B can be implemented using the AND operation as

(A=B)=x3⋅x2⋅x1⋅x0

The binary variable (A=B) is 1 only if all pairs of digits of the two numbers are equal.

Inequality

In order to manually determine the greater of two binary numbers, we inspect the relative magnitudes of pairs of significant digits, starting from the most significant bit, gradually proceeding towards lower significant bits until an inequality is found. When an inequality is found, if the corresponding bit of A is 1 and that of B is 0 then we conclude that A>B.[1]

This sequential comparison can be expressed logically as:

(A>B)=A3⋅B3‾+x3⋅A2⋅B2‾+x3⋅x2⋅A1⋅B1‾+x3⋅x2⋅x1⋅A0⋅B0‾

(A<B)=A3‾⋅B3+x3⋅A2‾⋅B2+x3⋅x2⋅A1‾⋅B1+x3⋅x2⋅x1⋅A0‾⋅B0

(A > B) and (A < B) are output binary variables, which are equal to 1 when A > B or A < B respectively.

One-bit binary full comparator, equality, inequality, greater than, less than at gate level. Created using CircuitLab
alternative comparator without using XNOR (using NOR gate)

See also

  • List of LM-series integrated circuits
  • 4000 series, List of 4000 series integrated circuits
  • 7400 series, List of 7400 series integrated circuits
  • Sorting network

References

  1. ↑ Kosako, Hideo; Oshima, Katsuya; Kojima, Yoshiaki (1967). "Digital Comparator" (PDF). Transactions of the Institute of Electronics and Communication Engineers of Japan. 50 (6): 452–458. doi:10.1109/T-ECJ.1967.12345 (inactive 9 July 2026).{{cite journal}}: CS1 maint: DOI inactive as of July 2026 (link)


External links

  • Digital Comparators by Texas Instruments
  • Mano, M. Morris; Ciletti, Michael D. (2023). Digital Design (6 ed.). Pearson. pp. 188–190. ISBN 9789353062019.
Retrieved from "https://en.wikipedia.org/w/index.php?title=Digital_comparator&oldid=1363265594"
Category:
  • Digital circuits
Hidden categories:
  • Articles with short description
  • Short description matches Wikidata
  • Articles needing additional references from February 2026
  • All articles needing additional references
  • CS1 maint: DOI inactive as of July 2026
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.