Class BigDecRoundSigFig
java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.functions.BinaryFunction
com.singularsys.jep.bigdecimal.functions.BigDecRoundSigFig
- All Implemented Interfaces:
FixedPrecisionFunctionI,PostfixMathCommandI,Serializable
Rounding functions to round to a specific number of significant figures.
Support all the modes in
RoundingMode.
roundSF(x,k) rounds to k significant figures.
Uses the BigDecimal.round(MathContext) method.- Since:
- Jep 3.5
- Author:
- Richard Morris
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.singularsys.jep.functions.BinaryFunction
BinaryFunction.BiFunctionWithException<T> -
Field Summary
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, description, name, NaN, numberOfParameters -
Constructor Summary
ConstructorsConstructorDescriptionConstructor with a specified rounding mode.BigDecRoundSigFig(RoundingMode mode, int scale) -
Method Summary
Modifier and TypeMethodDescriptionEvaluate the functionintGets the number of decimal places used.voidsetDecimalPlaces(int scale) Sets the number of decimal places to use.Methods inherited from class com.singularsys.jep.functions.BinaryFunction
instanceOf, instanceOf, instanceOf, instanceOf, runMethods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, checkNumberOfParameters, getDescription, getDescription, getDescriptionWithType, getName, getNumberOfParameters, setCurNumberOfParameters, setDescription, setName, toString, toString
-
Constructor Details
-
BigDecRoundSigFig
Constructor with a specified rounding mode.- Parameters:
mode-
-
BigDecRoundSigFig
-
-
Method Details
-
eval
Description copied from class:BinaryFunctionEvaluate the function- Specified by:
evalin classBinaryFunction- Parameters:
l- lhs argumentr- rhs argument- Returns:
- the results
- Throws:
EvaluationException- if the function cannot be evaluated.
-
getDecimalPlaces
public int getDecimalPlaces()Description copied from interface:FixedPrecisionFunctionIGets the number of decimal places used.- Specified by:
getDecimalPlacesin interfaceFixedPrecisionFunctionI- Returns:
- either zero, a positive number or -1 for floating-point formats
-
setDecimalPlaces
public void setDecimalPlaces(int scale) Description copied from interface:FixedPrecisionFunctionISets the number of decimal places to use.- Specified by:
setDecimalPlacesin interfaceFixedPrecisionFunctionI- Parameters:
scale- either zero, a positive number or -1 for floating-point formats
-