Class BigDecAdd

  • All Implemented Interfaces:
    PostfixMathCommandI, RealBinaryFunction, java.io.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 a n-ary function which is applied repeatedly if more than two arguments are provided.
    See Also:
    Serialized Form
    • Constructor Detail

      • BigDecAdd

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

      • setMathContext

        public void setMathContext​(java.math.MathContext mc)
      • getMathContext

        public java.math.MathContext getMathContext()
      • add

        public java.lang.Object add​(java.lang.Object l,
                                    java.lang.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