a comparator
A comparator is an electronic referee. Hand it two voltages and it answers one yes-or-no question: which one is bigger? Its output is not a faithful copy of anything — it is a verdict. If the + input is even a hair above the - input, the output snaps fully high; if it is below, the output snaps fully low. It is the doorway where the smooth analog world of in-between voltages turns into the crisp digital world of just-high-or-just-low.
Inside, a comparator looks like an op-amp with two inputs and enormous gain, but used wide open with no feedback. Because the gain is huge, the tiniest difference between the inputs drives the output all the way to one rail or the other. Say the - input sits at a fixed 2.5 V reference and you feed a slowly rising signal into the +: while the signal is under 2.5 V the output is low, and the instant it crosses 2.5 V the output flips high. That fixed reference is called the threshold. A real comparator chip differs from an op-amp in two ways that matter: it switches far faster (tens of nanoseconds), and its output stage is built to deliver a clean logic level a digital chip can read, often an open-collector output you tie up with a resistor.
Why not just use an op-amp? You can, but an op-amp is internally compensated to be slow and stable for feedback use, so it recovers sluggishly from being slammed to a rail, and its output does not naturally sit at clean logic levels. A purpose-built comparator (LM393, LM339) is the right tool when you need speed and a digital-friendly output. The honest pitfall lives at the threshold: when the input creeps slowly through it, or carries noise, the output can flutter back and forth many times instead of making one clean decision. That is chatter, and the cure is hysteresis.
A 2.5 V reference on the - input and a temperature sensor on the +: below 2.5 V the output reads low (cool), above it reads high (hot). The comparator turns an analog temperature into a single clean on/off bit for a fan.
One comparison, one bit out — the bridge from analog to digital.
An op-amp run open-loop is not a good comparator: it is slow to recover, may not reach clean logic levels, and some types can even latch up. Use a real comparator part for any speed or logic interfacing.