Remember, Adam, absolute values are always positive.
x - y for y in [0,x]
x is the maximum value
x is greater than or equal to y
x - y >= 0 so |x-y| = x-y
x - y for y in [x,1]
x is the minimum value
x is less than or equal to y
x - y <= 0 so |x-y| = -x+y
It looks to me like you just have it backwards. Give it another go.