Core Function Clamp

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> Clamp( <value>, <min>, <max> ) </pre> === Description === Clamps the specified value. === Parameters === ==== value ==== Number to check. ==== min ==== The minimum a...")
 
m (1 revision)
 
(2 intermediate revisions by one user not shown)
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 ===  

Latest revision as of 12:37, 14 June 2015

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
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox