Difference between revisions of "NXSL:round"
Jump to navigation
Jump to search
Line 11: | Line 11: | ||
== Parameters == | == Parameters == | ||
:{| | :{| class="wikitable" | ||
|- | |- | ||
| ''x'' || Floating point value. | | ''x'' || Floating point value. |
Revision as of 13:19, 22 November 2017
Round floating point value to the nearest integral value or floating point value with given precision.
Since: 1.2.5
Syntax
round(x [, precision]);
Parameters
x Floating point value. precision optional number of decimal places to be left. If omited or set to 0, x will be rounded to integral value.
Return Value
The integral value that is closest to x if precision is omited or set to 0, or floating point value rounded to have given number of decimal places.
Examples
round(2.3) -> 2 round(3.8) -> 4 round(-2.3) -> -2 round(-3.8) -> -4 round(2.378, 2) -> 2.38 round(2.378, 1) -> 2.4