Class BigDecVSum
java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.functions.ArrayFunctionBase
com.singularsys.jep.bigdecimal.functions.BigDecVSum
- All Implemented Interfaces:
FixedPrecisionFunctionI,ZeroLengthBehaviourI,PostfixMathCommandI,Serializable
Sum function, expanding its arguments together.
Uses
BigDecimal.add(BigDecimal, MathContext) for
calculating running totals.
If the number of decimal places is set, then the final value is
rounded to that number of decimal places.- Since:
- Jep 4.1
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.singularsys.jep.functions.ZeroLengthBehaviourI
ZeroLengthBehaviourI.DefaultZeroLengthBehaviourI, ZeroLengthBehaviourI.ZeroLengthErrorBehaviour, ZeroLengthBehaviourI.ZeroLengthHelper -
Field Summary
FieldsFields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, description, name, NaN, numberOfParameters -
Constructor Summary
ConstructorsConstructorDescriptionConstructor with a given MathContextBigDecVSum(MathContext mc, int dp) Fixed-point constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectAbstract method for performing the array calculation.booleancheckNumberOfParameters(int n) Must have one or more parameterintGets the number of decimal places used.voidsetDecimalPlaces(int scale) Sets the number of decimal places to use.voidMethods inherited from class com.singularsys.jep.functions.ArrayFunctionBase
addToArray, getZeroLengthErrorBehaviour, getZeroLengthValue, run, setZeroLengthErrorBehaviour, setZeroLengthValue, throwAtLeastOneExcepMethods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, getDescription, getDescription, getDescriptionWithType, getName, getNumberOfParameters, setCurNumberOfParameters, setDescription, setName, toString, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.singularsys.jep.functions.ZeroLengthBehaviourI
getErrorMessage, getValueOrException, zeroLengthResultOrException
-
Field Details
-
mc
-
scale
protected int scale
-
-
Constructor Details
-
BigDecVSum
Constructor with a given MathContext- Parameters:
mc- MathContext to use
-
BigDecVSum
Fixed-point constructor- Parameters:
mc- MathContext to usedp- number of decimal places to round final results to
-
-
Method Details
-
checkNumberOfParameters
public boolean checkNumberOfParameters(int n) Description copied from class:ArrayFunctionBaseMust have one or more parameter- Specified by:
checkNumberOfParametersin interfacePostfixMathCommandI- Overrides:
checkNumberOfParametersin classArrayFunctionBase- Parameters:
n- number of parameters function will be called with.- Returns:
- false if an illegal number of parameters is supplied, true otherwise.
-
calc
Description copied from class:ArrayFunctionBaseAbstract method for performing the array calculation.- Specified by:
calcin classArrayFunctionBase- Parameters:
l- The list to operate on. Note this is in reverse order of the arguments of the function.- Returns:
- The result of the calculation.
- Throws:
EvaluationException- if the calculation cannot be performed
-
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
-
getMathContext
-
setMathContext
-
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
-