Core Function Clamp
From Sputnik Wiki
Clamp( <value>, <min>, <max> )
Contents |
Description
Clamps the specified value.
Parameters
value
Number to check.
min
The minimum allowed value if <value> is lower than <min> then <min> will be returned.
max
The maximum allowed value if <value> is higher than <max> then <max> will be returned.
Return Value
The result of clamping a value between min and max.
Remarks
If any of the 3 values are a floating point then the Clamp() will compare as a floating point otherwise it will compare as an integer.
Example
say Clamp(4, 5, 20); // 5 say Clamp(5, 5, 20); // 5 say Clamp(6, 5, 20); // 6 say Clamp(18, 5, 20); // 18 say Clamp(20, 5, 20); // 20 say Clamp(21, 5, 20); // 20 say Clamp(22, 5, 20); // 20