round: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "<h3 style="display:none">Bottom Section</h3> " to "")
m (Text replacement - "\|x([0-9])= *<code>([^<]*)<\/code>" to "|x$1= <sqf>$2</sqf>")
 
(16 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command


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


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


|gr1= Math |GROUP1=
|game3= arma2oa
|version3= 1.50


| Rounds up or down to the closest integer.  |DESCRIPTION=
|game4= tkoh
|version4= 1.00


| [[Number]] <nowiki>=</nowiki> '''round''' x |SYNTAX=
|game5= arma3
|version5= 0.50


|p1= x: [[Number]] |PARAMETER1=
|gr1= Math


| [[Number]] |RETURNVALUE=
|descr= Rounds the provided value to the closest integer.
| 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=
|s1= [[round]] value


}}
|p1= value: [[Number]]


[[Category:Scripting Commands|ROUND]]
|r1= [[Number]]
{{GameCategory|arma1|Scripting Commands}}


{{GameCategory|arma2|Scripting Commands}}
|x1= <sqf>round 5.25; // returns 5</sqf>
{{GameCategory|arma3|Scripting Commands}}
{{GameCategory|tkoh|Scripting Commands}}


<!-- 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|arma1|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