Class BigDecRound
- java.lang.Object
-
- com.singularsys.jep.functions.PostfixMathCommand
-
- com.singularsys.jep.functions.NaryFunction
-
- com.singularsys.jep.functions.Round
-
- com.singularsys.jep.bigdecimal.functions.BigDecRound
-
- All Implemented Interfaces:
PostfixMathCommandI
,java.io.Serializable
public class BigDecRound extends Round
Rounding functions for BigDecimals. Support all the modes inRoundingMode
as well as a mode compatible withMath.round(double)
. Two types of function are supported round(x) rounds to 0 decimal places and round(x,k) rounds to k decimal places. This can be used to implement floor() and ceil() functions. Uses theBigDecimal.setScale(int,RoundingMode)
method.- Since:
- Jep 3.5
- Author:
- Richard Morris
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, name, NaN, numberOfParameters
-
-
Constructor Summary
Constructors Constructor Description BigDecRound()
Constructor with a rounding mode matching the behavior or Math.round, that is it equivalent to Math.floor(a + 0.5d).BigDecRound(java.math.RoundingMode mode)
Constructor with a specified rounding mode.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
round(java.lang.Object l)
java.lang.Object
round(java.lang.Object l, java.lang.Object r)
-
Methods inherited from class com.singularsys.jep.functions.Round
checkNumberOfParameters, eval, round, run
-
Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString, toString
-
-
-
-
Constructor Detail
-
BigDecRound
public BigDecRound()
Constructor with a rounding mode matching the behavior or Math.round, that is it equivalent to Math.floor(a + 0.5d). This does not match any of the modes inRoundingMode
.
-
BigDecRound
public BigDecRound(java.math.RoundingMode mode)
Constructor with a specified rounding mode.- Parameters:
mode
-
-
-
Method Detail
-
round
public java.lang.Object round(java.lang.Object l) throws EvaluationException
- Overrides:
round
in classRound
- Throws:
EvaluationException
-
round
public java.lang.Object round(java.lang.Object l, java.lang.Object r) throws EvaluationException
- Overrides:
round
in classRound
- Throws:
EvaluationException
-
-