Class RoundFunction
java.lang.Object
com.api.jsonata4java.expressions.functions.FunctionBase
com.api.jsonata4java.expressions.functions.RoundFunction
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
-
Nested Class Summary
Nested classes/interfaces inherited from class com.api.jsonata4java.expressions.functions.FunctionBase
FunctionBase.CtxEvalResult -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintintcom.fasterxml.jackson.databind.JsonNodeinvoke(ExpressionsVisitor expressionVisitor, MappingExpressionParser.Function_callContext ctx) Methods inherited from class com.api.jsonata4java.expressions.functions.FunctionBase
evalContext, getArgumentCount, getFunctionName
-
Field Details
-
ERR_BAD_CONTEXT
-
ERR_ARG1BADTYPE
-
ERR_ARG2BADTYPE
-
ERR_ARG3BADTYPE
-
-
Constructor Details
-
RoundFunction
public RoundFunction()
-
-
Method Details
-
invoke
public com.fasterxml.jackson.databind.JsonNode invoke(ExpressionsVisitor expressionVisitor, MappingExpressionParser.Function_callContext ctx) - Specified by:
invokein classFunctionBase
-
getMaxArgs
public int getMaxArgs()- Specified by:
getMaxArgsin classFunctionBase
-
getMinArgs
public int getMinArgs()- Specified by:
getMinArgsin classFunctionBase
-
getSignature
- Specified by:
getSignaturein classFunctionBase
-