BIS fnc nearestNum: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (1 revision)
(Page filling)
Line 1: Line 1:
{{Function|= Comments
{{Function|= Comments
____________________________________________________________________________________________
____________________________________________________________________________________________
Line 8: Line 7:
____________________________________________________________________________________________
____________________________________________________________________________________________


| <pre>
| Returns the provided set closest number to the target number. |= Description
/************************************************************
____________________________________________________________________________________________
Find Nearest Number


Parameters: [[number set], target number]
| [values, value] call [[BIS_fnc_nearestNum]] |= Syntax
Returns: number


Returns the number out of the set which is closest to the target number
|p1= values: [[Array]] of [[Number|Numbers]] - values to choose from |= Parameter 1


Example: [[1,5,10], 4] call BIS_fnc_nearestNum
|p2= value: [[Number]] - the reference value |= Parameter 2
returns 5
************************************************************/


</pre><small>''(Placeholder description extracted from the function header by [[BIS_fnc_exportFunctionsToWiki]])''</small> |= Description
| [[Number]] - the closest value |= Return value
____________________________________________________________________________________________
____________________________________________________________________________________________


| <!-- [] call [[BIS_fnc_nearestNum]]; --> |= Syntax
|x1= <code>_closestValueTo4 = <nowiki>[</nowiki>[1,5,10], 4] [[call]] [[BIS_fnc_nearestNum]]; {{codecomment|// returns 5}}</code> |= Example 1
 
|p1= |= Parameter 1
 
| |= Return value
____________________________________________________________________________________________
____________________________________________________________________________________________


|x1= <code></code> |=
| [[BIS fnc randomNum]], [[random]] |= See also
____________________________________________________________________________________________
 
| |= See also
 
}}
}}



Revision as of 16:30, 27 April 2018

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