ROUND

ROUND rounds a float to an arbitrary number of decimal places. Default is 0 decimal places.

Function category: Statistical

Syntax

ROUND(arg1, arg2)

Arguments

Description

arg1

Array of values.

arg2

Optional. Number of decimal places that arg1 should be rounded.

Examples

Let's say we're given a response with the following vehicle information:

{
"trucks":{
"first":{
"driver_id":104,
"mpg":19.15
},
"second":{
"driver_id":104,
"mpg":25.19456
}
}
}

Example 1: Round a value

Using the default argument (default is 0) we could perform a rounding operation using the following function.

# Round the value of the mpg key
ROUND(trucks.first.mpg)
# Returns 19

Example 2: Round at different number of decimal places

Using arg2, we can round values at different decimal places, as in the following functions.

# Round at the first decimal place
ROUND(trucks.first.mpg, 1)
# Returns 19.2
# Round at the second decimal place
ROUND(trucks.first.mpg, 2)
# Returns 19.15
# Round at the third decimal place
ROUND(trucks.second.mpg, 3)
# Returns 25.194
# Round at the fourth decimal place
ROUND(trucks.second.mpg, 4)
# Returns 25.1946