A rail-to-rail comparator, comprising: a first stage differential amplifier having differential inputs and differential outputs, the first stage differential amplifier having differential input offset voltage calibration means (228, 230); a second stage differential amplifier having differential inputs coupled to the differential outputs of the first stage differential amplifier, wherein the second stage differential amplifier comprises an input pair N-channel transistors (378, 380) having their outputs connected to the inputs of two P-channel transistors (374, 376) adapted to generate a digital output signal, which is single ended, and for supplying first and second logic levels dependent on a value of a differential voltage at the differential inputs of the first stage differential amplifier; a common mode voltage tracking circuit coupled to the first stage differential amplifier and generating a control current dependent on a common mode voltage at the differential inputs of the first stage differential amplifier; and a hysteresis control circuit coupled to the second stage differential amplifier and the common mode voltage tracking circuit, wherein the hysteresis control circuit controls hysteresis of the second stage differential amplifier by injecting, dependent on the digital output signal and by means of a multiplexer, a hysteresis current either to an output of the first or to an output of the second N-channel transistor (378, 380) of the second stage differential amplifier wherein the hysteresis current is a fraction of the control current generated by the common mode voltage tracking circuit. a first stage differential amplifier having differential inputs and differential outputs, the first stage differential amplifier having differential input offset voltage calibration means (228, 230); a second stage differential amplifier having differential inputs coupled to the differential outputs of the first stage differential amplifier, wherein the second stage differential amplifier comprises an input pair N-channel transistors (378, 380) having their outputs connected to the inputs of two P-channel transistors (374, 376) adapted to generate a digital output signal, which is single ended, and for supplying first and second logic levels dependent on a value of a differential voltage at the differential inputs of the first stage differential amplifier; a common mode voltage tracking circuit coupled to the first stage differential amplifier and generating a control current dependent on a common mode voltage at the differential inputs of the first stage differential amplifier; and a hysteresis control circuit coupled to the second stage differential amplifier and the common mode voltage tracking circuit, wherein the hysteresis control circuit controls hysteresis of the second stage differential amplifier by injecting, dependent on the digital output signal and by means of a multiplexer, a hysteresis current either to an output of the first or to an output of the second N-channel transistor (378, 380) of the second stage differential amplifier wherein the hysteresis current is a fraction of the control current generated by the common mode voltage tracking circuit.