---
name: "BIS_fnc_nearestNum"
type: function
status: ok
groups: ["Arrays", "Math"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/BIS_fnc_nearestNum
revid: 328545
updated: 2022-07-13T17:02:17Z
---

# BIS_fnc_nearestNum

*Function · Arrays, Math · Arma 3 v0.50 · introduced in Arma 2 v1.00*

## Description

Returns the provided set closest number to the target number.

## Syntax

```sqf
[values, value] call BIS_fnc_nearestNum
```

**Parameters:**

- `values`: [Array](../topics/Array.md) of [Number](../topics/Number.md)s - values to choose from
- `value`: [Number](../topics/Number.md) - the reference value

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

## Examples

### Example 1

```sqf
private _closestValueTo4 = [[1,5,10], 4] call BIS_fnc_nearestNum; // returns 5
```

## See also

[BIS_fnc_randomNum](../functions/BIS_fnc_randomNum.md) · [random](../commands/random.md)

<sub>Source: [BI Community Wiki — BIS fnc nearestNum](https://community.bistudio.com/wiki/BIS_fnc_nearestNum) (revision 328545).</sub>
