Class BigDecAbs

All Implemented Interfaces:
FixedPrecisionFunctionI, PostfixMathCommandI, RealUnaryFunction, Serializable

public class BigDecAbs extends Abs implements FixedPrecisionFunctionI
Absolute value function for BigDecimals, Double and other Number types. Uses BigDecimal.abs() for BigDecimals and Abs for other types.
Author:
Richard Morris
See Also:
  • Field Details

    • scale

      protected int scale
    • mc

      protected MathContext mc
  • Constructor Details

  • Method Details

    • abs

      public Object abs(Object l) throws EvaluationException
      Description copied from class: Abs
      Calculates the absolute value of its argument
      Overrides:
      abs in class Abs
      Parameters:
      l - supports Double, Float, Integer, Long, Short, Complex and Number arguments
      Returns:
      the absolute value. Gives the same type as its argument except for Number arguments that are converted to Double before conversions and return a Double argument.
      Throws:
      EvaluationException - if type not supported
    • setMathContext

      public void setMathContext(MathContext mc)
    • getDecimalPlaces

      public int getDecimalPlaces()
      Description copied from interface: FixedPrecisionFunctionI
      Gets the number of decimal places used.
      Specified by:
      getDecimalPlaces in interface FixedPrecisionFunctionI
      Returns:
      either zero, a positive number or -1 for floating-point formats
    • setDecimalPlaces

      public void setDecimalPlaces(int scale)
      Description copied from interface: FixedPrecisionFunctionI
      Sets the number of decimal places to use.
      Specified by:
      setDecimalPlaces in interface FixedPrecisionFunctionI
      Parameters:
      scale - either zero, a positive number or -1 for floating-point formats
    • getMathContext

      public MathContext getMathContext()