so I have some range, let's say $ [a,b]$ for $a,b > 0 $. Now I'm given some number $c \in [a,b]$, to act as some 'target' number. My question is, if I have another number, $x \in [a,b]$, how can I find a percentage of how close $x$ is to $c$. Where if $x=c$, closeness = 100%, and the further $x$ is from $c$, the lower the percentage, regardless if $x$ is greater or less than $c$.
Eg: For $a=0, b=10, c=5$
If $x=4$, closeness = 80%
If $x = 6$, closeness = 80% (not 120%)
I know I could do it with two functions, depending if x is < or > c, simple fractions, but we don't always know this.