Most physical measurements are analog in nature. When we engineer a system to produce or measure a signal like the voltage on a wire, we can’t expect to get a perfect value. There will always be some noise in the system. Instead of 3.00000 volts, we might get 3.00001 volts or 2.99999 volts.
This makes producing exact results difficult when computing with analog data. Precision is important in computing. We generally expect computers to be deterministic, meaning they should produce the same output for a given input. If a slight variation in an analog signal can change the outcome, it is difficult (if not impossible) to achieve consistent results. Is the 3.00001 volts we are seeing really 3.00000 volts with some noise? Or is it “really” 3.00001?
Rather than trying to capture the exact analog value, we can turn an analog signal into a simple digital one with two possible states by interpreting it against a threshold. Any time we measure the value of the signal, if the value is below the threshold we call it “off”; if it is above the threshold we call it “on”. In the image below, we could say at T1, the signal is off and at T2, it is on.
Even if the electrical circuit that is trying to represent this pattern has a lot of noise, we should be able to distinguish the intended values. In the image below, the red line indicates the signal we are trying to represent, and the grey line indicates the electrical signal that is measured.
Even though there is a lot of noise - the signal is bouncing above and below the voltage we are trying to use, it is very much clear what the value should be at T1 and T2. We can ignore the noise and confidently say the signal at T1 is “off” and at T2 is “on”.
To convert an analog signal to either 0 or 1, we need one threshold. If we wanted to convert the signal to one of four values, how many thresholds would be needed?