Class BigDecAdd

All Implemented Interfaces:
PostfixMathCommandI, RealBinaryFunction, Serializable

public class BigDecAdd extends Add
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:
  • Constructor Details

    • BigDecAdd

      public BigDecAdd(MathContext mc)
      Constructor. Initialises the math context.
      Parameters:
      mc -
  • Method Details

    • setMathContext

      public void setMathContext(MathContext mc)
    • getMathContext

      public MathContext getMathContext()
    • add

      public Object add(Object l, Object r) throws EvaluationException
      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 class Add
      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