NXSL:round

Revision as of 18:13, 13 September 2022 by AlexKirhenshtein (talk | contribs) (Text replacement - "^" to "{{deprecated}}")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This Wiki is deprecated and we are are currrently migrating remaining pages into product documentation (Admin Guide, NXSL Guide)

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