Difference between revisions of "NXSL:round"

From NetXMS Wiki
Jump to navigation Jump to search
Line 5: Line 5:
== Syntax ==
== Syntax ==


round(''x''[, ''precision'']);
round(''x'' [, ''precision'']);





Revision as of 02:06, 6 January 2013

Round floating point value to the nearest integral value or floating point value with given precision.


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