- Home /
Return 0 to 1 to 0 based on range?
I've run into a situation where I need to return a value based on x's position in a range of y.
0 of y return 0,
y/2 of y returns 1,
y of y returns 0
and all possibilities between, does anyone know some solutions to a problem like this?
Thanks
Comment
Best Answer
Answer by FL · Feb 03, 2013 at 12:51 AM
if (value < y/2){
ret = value/(y/2);
}else{
ret = (y-value)/(y/2);
}
Both of your solutions would have worked. The first one just needed to return the $$anonymous$$athf.Abs(ret).
But this new one a little more simple and elegant. Thanks, not sure how I missed such a simple equation.