- All Implemented Interfaces:
- Function
public class RoundFunction
extends FunctionBase
implements Function
http://docs.jsonata.org/numeric-functions.html
$round(number [, precision])
Returns the value of the number parameter rounded to the number of decimal
places specified by the optional precision parameter.
The precision parameter (which must be an integer) species the number of
decimal places to be present in the rounded number. If precision is not
specified then it defaults to the value 0 and the number is rounded to the
nearest integer. If precision is negative, then its value specifies which
column to round to on the left side of the decimal place
This function uses the Round half to even strategy to decide which way to
round numbers that fall exactly between two candidates at the specified
precision. This strategy is commonly used in financial calculations and is
the default rounding mode in IEEE 754.
Examples
$round(123.456)==123 $round(123.456, 2)==123.46 $round(123.456, -1) ==
120 $round(123.456, -2)==100 $round(11.5)==12 $round(12.5)==12
$round(125, -1)==120