A comparator does analog redstone logic: it compares or subtracts signal strengths and, unlike a repeater, preserves the exact 0–15 level instead of forcing it to 15.
Bedrock Edition · Block dictionary
Comparator — spec
Modes
Compare (front torch off) and Subtract (front torch lit)
Delay
2 game ticks (1 redstone tick)
Analog
Preserves the input signal strength (does not force 15)
Reads containers
Outputs a 0–15 level from container fullness behind it