The comparator must have a power supply, 5V is good, positive to P5, ground to P2.
The inputs should not be outside the power supply range i.e. between 0V and 5V. If the inputs are outside this range, you may damage the device, depending how the input is designed. Sometimes exceeding the supply...