# Normalizing difference between two real values to [0,1] interval [duplicate]

If I have two positive real numbers that can take on any value between 0 and some finite real number, how do I normalized the difference between these two numbers to [0,1] interval where 0 indicates no similarity and 1 indicates that these two numbers are the same?

• Several more duplicates can be found by linking through the normalization tag. – whuber Dec 15 '13 at 16:28

If $L$ is the maximum value that any of the two numbers can take, than you can use the expression $sim(a, b) = 1 - \frac{|a-b|}{L}$.