This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
ROUND
Dan Gorman edited this page Nov 29, 2018
·
2 revisions
ROUND
rounds a float to an arbitrary number of decimal places, defaulting to 0 decimal places.
ROUND(arg1, arg2)
-
arg1
is an array of values -
arg2
is optional, and refers to the number of decimal places thatarg1
should be rounded to.
Let's say we're given a response with some vehicle information that looks like this:
{
"trucks":{
"first":{
"driver_id":104,
"mpg":19.15
},
"second":{
"driver_id":104,
"mpg":25.19456
}
}
}
Using the default argument, we could perform an operation like this:
ROUND(trucks.first.mpg)
This returns 19
.
ROUND(trucks.first.mpg, 1) = > 19.2
ROUND(trucks.first.mpg, 2) = > 19.15
ROUND(trucks.first.mpg, 3) = > 19.15
ROUND(trucks.second.mpg, 4) = > 25.1946