BIS_fnc_clamp

From Bohemia Interactive Community
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Hover & click on the images for description

Description

Description:
Clamps provided value within min..max range.
This function is for readability; for performance, directly use min and max.
Execution:
call
Groups:
Math

Syntax

Syntax:
[value, min, max] call BIS_fnc_clamp
Parameters:
value: Number - value to be clamped
min: Number - (Optional, default 0) lower limit
max: Number - (Optional, default 0) upper limit
Return Value:
Number - the clamped value

Examples

Example 1:
[5, 0, 10] call BIS_fnc_clamp; // returns 5 [0, 0, 10] call BIS_fnc_clamp; // returns 0 [10, 0, 10] call BIS_fnc_clamp; // returns 10 [-5, 0, 10] call BIS_fnc_clamp; // returns 0 [15, 0, 10] call BIS_fnc_clamp; // returns 10 [5, 10, 3] call BIS_fnc_clamp; // returns 10
Example 2:
[5, 0, 10] call BIS_fnc_clamp; // 0.0098 ms 0 max 5 min 10; // 0.0011 ms - about 10x faster

Additional Information

See also:
min max

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note