Home

Comparator

A comparator is a device or algorithm that compares two inputs and indicates their relative magnitude. In electronics, a comparator is an electronic circuit that compares two voltages or currents and outputs a digital signal showing which input is larger. They are used for level detection, waveform slicing, zero-crossing detection, and similar tasks. Analog comparators typically provide a binary output and may include features such as open-collector or push-pull outputs and input hysteresis to prevent chatter around the threshold. Key specifications include input range, common-mode range, propagation delay, and output type.

In hardware, common examples include voltage comparators such as the LM311 and LM393. Window comparators use

In software and computing, a comparator is a function or object that defines an ordering relationship between

two
references
to
determine
whether
an
input
lies
within
a
given
range.
Real-world
applications
include
pulse-width
modulation
control,
analog-to-digital
conversion
front
ends,
and
safety
or
fault-detection
circuits.
two
elements.
It
enables
sorting,
searching,
and
ordered
data
structures
by
returning
a
negative,
zero,
or
positive
value
to
indicate
the
relative
order.
Language
examples
include
Java’s
Comparator
interface,
Python’s
key
functions
and
rich
comparison
methods,
and
C/C++
comparison
functions
used
by
qsort
and
sort.
Important
properties
of
a
software
comparator
include
a
consistent,
antisymmetric,
and
transitive
ordering,
and,
depending
on
the
context,
whether
the
sort
should
be
stable.
The
term
thus
covers
both
physical
devices
that
compare
signals
and
software
routines
that
establish
ordering
among
data.