A comparator is one of the simplest op amp subsystems. It simply compares two voltages, and the output either goes high or low depending on which input is the higher voltage.
Generally, one of the inputs is fixed to a set voltage (a reference voltage), whilst the other varies depending on an analogue input. Here’s an example:
Using a potential divider calculation, the voltage at the non-inverting input can be calculated as 3v. Because of this, when the voltage at Vin is above 3v, the output will be low. When the Voltage at Vin drops below 3v, the output will be high.