BIS fnc nearestNum: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Page filling)
m (template:command argument fix)
Line 7: Line 7:
____________________________________________________________________________________________
____________________________________________________________________________________________


| 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=


|p1= values: [[Array]] of [[Number|Numbers]] - values to choose from |= Parameter 1
|p1= values: [[Array]] of [[Number|Numbers]] - values to choose from |PARAMETER1=


|p2= value: [[Number]] - the reference value |= Parameter 2
|p2= value: [[Number]] - the reference value |PARAMETER2=


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


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


| [[BIS fnc randomNum]], [[random]] |= See also
| [[BIS fnc randomNum]], [[random]] |SEEALSO=
}}
}}



Revision as of 15:32, 7 April 2019

Hover & click on the images for description

Description

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

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