round: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Text replacement - "\|x([0-9])= *<code>([^<]*)<\/code>" to "|x$1= <sqf>$2</sqf>")
 
(44 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma |= Game name
|game1= arma1
|version1= 1.00


|1.00|= Game version
|game2= arma2
____________________________________________________________________________________________
|version2= 1.00


| Rounds up or down to the closest integer.  |= Description
|game3= arma2oa
____________________________________________________________________________________________
|version3= 1.50


| [[Number]] <nowiki>=</nowiki> '''round''' x |= Syntax
|game4= tkoh
|version4= 1.00


|p1= x: [[Number]] |= Parameter 1
|game5= arma3
|version5= 0.50


| [[Number]] |= Return value
|gr1= Math
____________________________________________________________________________________________
| x1 =<pre>_val= round 5.25, result is 5</pre> | = Example 1
| x2 =<pre>_val= round 5.55, result is 6</pre> | = Example 2
____________________________________________________________________________________________


|[[Math Commands]] : [[ceil]], [[floor]]|= See also
|descr= Rounds the provided value to the closest integer.


}}
|s1= [[round]] value


<h3 style="display:none">Notes</h3>
|p1= value: [[Number]]
<dl class="command_description">
<!-- Note Section BEGIN -->


<!-- Note Section END -->
|r1= [[Number]]
</dl>


<h3 style="display:none">Bottom Section</h3>
|x1= <sqf>round 5.25; // returns 5</sqf>
[[Category:Scripting Commands|ROUND]]
[[Category:Scripting Commands ArmA|ROUND]]
[[Category:Command_Group:_Math|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]


<!-- CONTINUE Notes -->
|x2= <sqf>round -5.25; // returns -5</sqf>
<dl class="command_description">
<dd class="notedate">Posted on August 28, 2015 - 13:59 (UTC)</dd>
<dt class="note">[[User:Moerderhoschi|Moerderhoschi]]</dt>
<dd class="note">


please note when using the round command that the first and the last digit of the range occur only the half of the time then the other digits. Tested with ArmA 2 v1.62
|seealso= [[floor]] [[ceil]] [[linearConversion]]
<code>countArray = [0,0,0,0,0];
}}
for "_i" from 1 to 10000 do {
number = (round random 4);
countArray set [number,(countArray select number) + 1];
};
<br>
// countArray example result -> [1287,2517,2495,2460,1241]</code>
 
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 10:24, 13 May 2022

Hover & click on the images for description

Description

Description:
Rounds the provided value to the closest integer.
Groups:
Math

Syntax

Syntax:
round value
Parameters:
value: Number
Return Value:
Number

Examples

Example 1:
round 5.25; // returns 5
Example 2:
round -5.25; // returns -5

Additional Information

See also:
floor ceil linearConversion

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