---
name: "BIS_fnc_clamp"
type: function
status: ok
groups: ["Math"]
arma3_since: "1.00"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/BIS_fnc_clamp
revid: 341317
updated: 2023-05-21T15:49:57Z
---

# BIS_fnc_clamp

*Function · Math · Arma 3 v1.00*

## Description

Clamps provided value within min..max range.

> [!NOTE]
> This function is for readability; for performance, directly use [min](../commands/min.md) and [max](../commands/max.md).

## Syntax

```sqf
[value, min, max] call BIS_fnc_clamp
```

**Parameters:**

- `value`: [Number](../topics/Number.md) - value to be clamped
- `min`: [Number](../topics/Number.md) - (Optional, default 0) lower limit
- `max`: [Number](../topics/Number.md) - (Optional, default 0) upper limit

**Returns:** [Number](../topics/Number.md) - the clamped value

## Examples

### Example 1

```sqf
 [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

```sqf
[5, 0, 10] call BIS_fnc_clamp;    // 0.0098 ms
0 max 5 min 10;                    // 0.0011 ms - about 10x faster
```

## See also

[min](../commands/min.md) · [max](../commands/max.md)

<sub>Source: [BI Community Wiki — BIS fnc clamp](https://community.bistudio.com/wiki/BIS_fnc_clamp) (revision 341317).</sub>
