In electronics, a comparator is a device that compares two voltages or currents and outputs a digital signal indicating which is larger. It has two analog input terminals
V
+
{\displaystyle V_{+}\,}
and
V
−
{\displaystyle V_{-}\,}
and one binary digital output
V
o
{\displaystyle V_{\rm {o}}\,}
. The output is ideally
V
o
=
{
1
,
if
V
+
>
V
−
0
,
if
V
+
<
V
−
{\displaystyle V_{\rm {o}}={\begin{cases}1,&{\mbox{if }}V_{+}>V_{-}\\0,&{\mbox{if }}V_{+}<V_{-}\end{cases}}}
A comparator consists of a specialized high-gain differential amplifier. They are commonly used in devices that measure and digitize analog signals, such as successive-approximation ADCs, as well as relaxation oscillators.