round: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "[[Category:Scripting Commands ArmA|" to "[[Category:Scripting Commands Armed Assault|")
m (Text replacement - "\|x([0-9])= *<code>([^<]*)<\/code>" to "|x$1= <sqf>$2</sqf>")
 
(27 intermediate revisions by 2 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]] |PARAMETER1=
|game5= arma3
|version5= 0.50


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


| [[ceil]], [[floor]], [[linearConversion]], [[Math Commands]]|SEEALSO=
|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 Armed Assault|ROUND]]
[[Category:Command_Group:_Math|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 2|{{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 February 23, 2018 - 05:21 (UTC)</dd>
<dt class="note">[[User:feint|feint]]</dt>
<dd class="note"> If you want to round to a specific place past the decimal point, use [[toFixed]] and [[parseNumber]] together.<br><br>For example:
<code>[[parseNumber]] (3.16666 [[toFixed]] 1); // 3.2</code>
</dd>
</dl>
<!-- DISCONTINUE Notes -->


<!-- CONTINUE Notes -->
|seealso= [[floor]] [[ceil]] [[linearConversion]]
<dl class="command_description">
}}
<dd class="notedate">Posted on April 3, 2018 - 21:33 (UTC)</dd>
<dt class="note">[[User:Lou Montana|Lou Montana]]</dt>
<dd class="note">
Before [[toFixed]] {{GVI|arma3|1.66}} and [[parseNumber]] {{GVI|arma|1.00}}, you could round with decimals with a dirty little "hack":
([[round]] (([[getDir]] [[player]]) * 100)) / 100
</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