BIS fnc nearestNum: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[[cC]ategory:\{\{Name\|arma3\}\}: [fF]unctions\|\{\{uc:[a-z A-Z_]*\}\}\]\]" to "")
m (codecomment → cc)
Line 1: Line 1:
{{RV|type=function
{{RV|type=function


| arma2
|game1= arma2


|1.00
|version1= 1.00


|gr1 = Arrays
|gr1= Arrays


|gr2 = Math
|gr2= Math


| Returns the provided set closest number to the target number.
|descr= Returns the provided set closest number to the target number.


| [values, value] call [[BIS_fnc_nearestNum]]
|s1= [values, value] call [[BIS_fnc_nearestNum]]


|p1= values: [[Array]] of [[Number|Numbers]] - values to choose from
|p1= values: [[Array]] of [[Number|Numbers]] - values to choose from
Line 17: Line 17:
|p2= value: [[Number]] - the reference value
|p2= value: [[Number]] - the reference value


| [[Number]] - the closest value
|r1= [[Number]] - the closest value


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


| [[BIS fnc randomNum]], [[random]]
|seealso= [[BIS fnc randomNum]], [[random]]
}}
}}


[[Category:{{Name|arma2}}: Functions|{{uc:nearestNum}}]]
[[Category:{{Name|arma2oa}}: Functions|{{uc:nearestNum}}]]
[[Category:{{Name|arma2oa}}: Functions|{{uc:nearestNum}}]]
[[Category:{{Name|tkoh}}: Functions|{{uc:nearestNum}}]]
[[Category:{{Name|tkoh}}: Functions|{{uc:nearestNum}}]]

Revision as of 17:57, 7 February 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