BIS fnc nearestNum: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[Category\:Function Group\: Numbers(\|\{\{[a-zA-Z0-9_:]+\}\})?\]\] " to "")
m (Text replacement - "_{10,} " to "")
Line 1: Line 1:
{{Function|Comments=
{{Function|Comments=
____________________________________________________________________________________________


| arma2 |Game name=
| arma2 |Game name=
Line 9: Line 8:


|gr2 = Math |GROUP2=
|gr2 = Math |GROUP2=
____________________________________________________________________________________________


| Returns the provided set closest number to the target number. |DESCRIPTION=
| Returns the provided set closest number to the target number. |DESCRIPTION=
____________________________________________________________________________________________


| [values, value] call [[BIS_fnc_nearestNum]] |SYNTAX=
| [values, value] call [[BIS_fnc_nearestNum]] |SYNTAX=
Line 21: Line 18:


| [[Number]] - the closest value |RETURNVALUE=
| [[Number]] - the closest value |RETURNVALUE=
____________________________________________________________________________________________


|x1= <code>_closestValueTo4 = [<nowiki/>[1,5,10], 4] [[call]] [[BIS_fnc_nearestNum]]; {{codecomment|// returns 5}}</code> |EXAMPLE1=
|x1= <code>_closestValueTo4 = [<nowiki/>[1,5,10], 4] [[call]] [[BIS_fnc_nearestNum]]; {{codecomment|// returns 5}}</code> |EXAMPLE1=
____________________________________________________________________________________________


| [[BIS fnc randomNum]], [[random]] |SEEALSO=
| [[BIS fnc randomNum]], [[random]] |SEEALSO=

Revision as of 23:20, 16 January 2021

Hover & click on the images for description

Description

Description:
Returns the provided set closest number to the target number.
Execution:
call
Groups:
ArraysMath

Syntax

Syntax:
[values, value] call BIS_fnc_nearestNum
Parameters:
values: Array of Numbers - values to choose from
value: Number - the reference value
Return Value:
Number - the closest value

Examples

Example 1:
_closestValueTo4 = [[1,5,10], 4] call BIS_fnc_nearestNum; // returns 5

Additional Information

See also:
BIS fnc randomNumrandom

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

Notes

Bottom Section