Thus instead of having to use IF statements to repeat the value of a calculation I've been trying to find a clamp function. But from what I can tell, there is no such thing.
The function I'm trying to find would allow me to input a number and then I should be able to pick the lowest allowed and highest allowed number. Or, just limit the number to 0.
Example:
=Clamp(5,0,4) returns 4
=Clamp(-341,0,4) returns 0
=Clamp(3,0,4) returns 3
codish example:
Code: Select all
clamp(in,min,max) {
if (in > max return max)
if (in < min return min)
return in
}
Have a great one