round: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
(note deleted. The observed by the poster phenomenon is normal "random" command distribution, nothing to do with round)
Line 38: Line 38:
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
<!-- CONTINUE Notes -->
<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
<br>This is a normal behaviour because of the roundrange for the digit.
<br> 0 -> 0.00 - 0.49 -> roundrange is  ~0.5
<br> 1 -> 0.50 - 1.49 -> roundrange is  ~1
<br> 2 -> 1.50 - 2.49 -> roundrange is  ~1
<br> 3 -> 2.50 - 3.49 -> roundrange is  ~1
<br> 4 -> 3.50 - 4.00 -> roundrange is  ~0.5
<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];
};
//                                0    1    2    3    4
// countArray example result -> [1287,2517,2495,2460,1241]</code>
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Revision as of 16:19, 28 August 2015

-wrong parameter ("Arma") defined!-1.00
Hover & click on the images for description

Description

Description:
Rounds up or down to the closest integer.
Groups:
Uncategorised

Syntax

Syntax:
Number = round x
Parameters:
x: Number
Return Value:
Number

Examples

Example 1:
_val= round 5.25, result is 5
Example 2:
_val= round 5.55, result is 6

Additional Information

See also:
Math Commands : ceilfloor

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