//Title: "Clip"
//Credit to: Xx Dark Wizard xX
//Contributed by: Xx Dark Wizard xX
/*
Returns a value between the mininum and maximum values.
*/
proc
Clip(value,min,max)
if(!value || !isnum(value)) return
return min(max(value,min),max)
ID:257765
Mar 7 2007, 9:57 am (Edited by moderator on Mar 13 2007, 2:07 pm)
|
|
Mar 13 2007, 2:08 pm
|
|
See also [link] for the Bound Constraint snippet, which is an inline version of the same procedure that uses the ternary operator "?:" instead of the built-in procedures min() and max().
|