Class BigDecAdd
java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.functions.NaryBinaryFunction
com.singularsys.jep.functions.Add
com.singularsys.jep.bigdecimal.functions.BigDecAdd
- All Implemented Interfaces:
PostfixMathCommandI
,RealBinaryFunction
,Serializable
Function class for the addition operator. It can operate on multiple
BigDecimals whose values are added or on Strings which are concatenated
together. Inheriting from NaryBinaryFunction creates an n-ary function which
is applied repeatedly if more than two arguments are provided.
- See Also:
-
Field Summary
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, name, NaN, numberOfParameters
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds two numbers together.boolean
Whether adding strings is allowed.void
setAllowStrings
(boolean allowStrings) Sets whether strings should be allowed with this operator or not.void
Methods inherited from class com.singularsys.jep.functions.NaryBinaryFunction
checkNumberOfParameters, eval, instanceOf, instanceOf, run
Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString, toString
-
Constructor Details
-
BigDecAdd
Constructor. Initialises the math context.- Parameters:
mc
-
-
-
Method Details
-
setMathContext
-
getMathContext
-
add
Description copied from class:Add
Adds two numbers together. The parameters can be of type Number, Complex, or String. If a certain combination of types is not supported, a EvaluationException is thrown.- Overrides:
add
in classAdd
- Parameters:
l
- The first parameter to be added.r
- The second parameter to be added.- Returns:
- The sum of param1 and param2, or concatenation of the two if they are Strings.
- Throws:
EvaluationException
- if the calculation cannot be performed
-
getAllowStrings
public boolean getAllowStrings()Whether adding strings is allowed. (Treated as concatenation ).- Returns:
- true if allowed
- Since:
- 3.4.0
-
setAllowStrings
public void setAllowStrings(boolean allowStrings) Sets whether strings should be allowed with this operator or not.- Parameters:
allowStrings
- When true, strings are allowed. When false an IllegalParameterException is thrown during evaluation.- Since:
- 3.4.0
-