round

Rounds a number to a number of decimal places (none unless given). Halves round away from zero, on the server and on the device alike: 2.5 gives 3, -2.5 gives -3, 1.005 to two places gives 1.01. A negative number of places rounds to tens, hundreds: round(1234, -2) is 1200.

Runs on: either side: the compiler places the statement that calls it where the values it uses live.

Format:

round(number [, places])

Parameters:

Parameter Type Description
number number the number
places number  [Optional]the decimal places to keep; 0 unless given

Returned Value:

Type Description
number the rounded number

Examples

total = round(subtotal * (1 + tax_rate), 2)