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 - " *\| *([Cc]omments|COMMENTS|Game|[Gg]ame [Nn]ame( +[0-9])?|Game [Vv]ersion( +[0-9])?|Game Version \(number surrounded by NO SPACES\)|Arguments in MP|MP[Aa]rg|Multiplayer Arguments( \("local" or "global"\))?|Effects|Execution|Effects...)
Line 1: Line 1:
{{Command|Comments=
{{Command


| arma1 |Game name=
| arma1


|1.00|Game version=
|1.00


|gr1= Math |GROUP1=
|gr1= Math


| Rounds up or down to the closest integer. |DESCRIPTION=
| Rounds up or down to the closest integer.


| [[Number]] <nowiki>=</nowiki> '''round''' x |SYNTAX=
| [[Number]] <nowiki>=</nowiki> '''round''' x


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


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


| [[ceil]], [[floor]], [[linearConversion]], [[Math Commands]]|SEEALSO=
| [[ceil]], [[floor]], [[linearConversion]], [[Math Commands]]


}}
}}

Revision as of 11:04, 18 January 2021

Hover & click on the images for description

Description

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

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:
ceilfloorlinearConversionMath Commands

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
Posted on February 23, 2018 - 05:21 (UTC)
feint
If you want to round to a specific place past the decimal point, use toFixed and parseNumber together.

For example: parseNumber (3.16666 toFixed 1); // 3.2
Posted on April 3, 2018 - 21:33 (UTC)
Lou Montana
Before toFixed Arma 3 logo black.png1.66 and parseNumber Logo A1 black.png1.00, you could round with decimals with a dirty little "hack": (round ((getDir player) * 100)) / 100