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

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

if (value < y/2){

ret = value/(y/2);

}else{

ret = (y-value)/(y/2);

}