Core Function Clamp
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> Clamp( <value>, <min>, <max> ) </pre> === Description === Clamps the specified value. === Parameters === ==== value ==== Number to check. ==== min ==== The minimum a...") |
(→Return Value) |
||
Line 23: | Line 23: | ||
=== Return Value === | === Return Value === | ||
− | The result of clamping a value between min and max | + | The result of clamping a value between min and max. |
=== Remarks === | === Remarks === |
Revision as of 08:07, 10 August 2014
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