If I have the equation: $$y= \frac{(d-x)}{a}-1$$ and I want to limit the possible values of $y$ (between 0 and 1 in this example), would I have to use something like: $$y= max(0,min(\frac{(d-x)}{a}-1,0))$$ or if I could just add a restriction on the range of values $y$ can be by saying: $$\{y\in \Bbb{R} | max(0,min(y,0))\}$$ I would prefer to write the restriction after as it is neater and easier to read but I don't know if it makes perfect sense. When programming this I use a Clamp function to restrict the return value but I am unsure of the correct syntax when writing out the same operation mathematically.
I read here that:
Range restrictions usually occur due to the nature of the function or the relation… they are not usually imposed by the author.
I'm not 100% sure if this means that I am going about this in the wrong way or not. Which of these methods is correct and if neither, could you help me find something more appropriate?