Class CBLMath

java.lang.Object
com.softwaremining.util.CBLMath

public class CBLMath extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static Log
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static BigDecimal
     
    static double
    annuity(double percentage, double numberOfPeriods)
    return annuity value same as in COBOL
    static BigDecimal
     
    static BigDecimal
     
    static BigDecimal
    cos(BigDecimal input)
     
    static double
    factorial(double value)
    return value of computed factorial for its first argument
    static BigDecimal
    log(BigDecimal input)
     
    static BigDecimal
     
    static double
    max(double[] args)
    returns largest number in the sequence
    static double
    return maximum from a field.
    static String
    max(CBLString theField)
    return maximum from a field.
    static String
    max(String[] args)
    return maximum from sequence of strings, where maximum is determined through lexicographical comparisons
    static double
    mean(double[] args)
     
    static double
    return MEAN from an arrayed field.
    static double
    median(double[] args)
     
    static double
    return median from a field.
    static double
    midrange(double[] args)
     
    static double
    return MID-RANGE from a field.
    static double
    min(double[] args)
     
    static double
    return minimum from a field.
    static String
    min(CBLString theField)
    return minimum from a field.
    static String
    min(String[] args)
    return minimum from sequence of strings, where minimum is determined through lexicographical comparisons
    static BigDecimal
    min(BigDecimal[] args)
     
    static double
    mod(double arg1, double arg2)
     
    static double
    return numeric value of its first argument
    static double
    return numeric value of its first argument
    static double
    numval(String value)
    return numeric value of its argument.
    static double
    return numeric value of its first argument
    static double
    numvalC(ISMNumeric field, String currencySign)
    return numeric value of its first argument
    static double
    return numeric value of its first argument
    static double
    numvalC(ISMString field, String currencySign)
    return numeric value of its first argument
    static double
    numvalC(String value)
    return numeric value of its first argument
    static double
    numvalC(String value, String currencySign)
    return numeric value of its first argument
    static int
    ordMax(double[] args)
    Translation of COBOL INTRINSIC FUNCTION ORD-MAX.
    static double
    Translation of COBOL INTRINSIC FUNCTION ORD-MAX.
    static int
    ordMax(String[] args)
    Translation of COBOL INTRINSIC FUNCTION ORD-MAX.
    static int
    ordMin(double[] args)
    Translation of COBOL INTRINSIC FUNCTION ORD-MIN.
    static double
    Translation of COBOL INTRINSIC FUNCTION ORD-MIN.
    static int
    ordMin(String[] args)
    Translation of COBOL INTRINSIC FUNCTION ORD-MIN.
    static double
    presentField(double[] args2)
    Deprecated.
    - use persentValue
    static double
    presentField(double arg1, double[] args2)
    Deprecated.
    - use persentValue
    static double
    Deprecated.
    - please use presentValue
    static double
    presentValue(double[] args2)
    Translation of COBOL INTRINSIC FUNCTION PRESENT-VALUE
    static double
    presentValue(double arg1, double[] args2)
    Translation of COBOL INTRINSIC FUNCTION PRESENT-VALUE
    static double
    Translation of COBOL INTRINSIC FUNCTION PRESENT-VALUE It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)
    static double
    range(double[] args)
    return RANGE from a field (numerical difference between min and max) It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)
    static double
    return RANGE from a field.
    static final void
    setRound(ISMNumeric theField, double doubleVal)
    Support for COBOL's ROUNDED statement.
    static BigDecimal
    sin(BigDecimal input)
     
    static double
    standardDeviation(double arg)
    interface function for degenerative case of one argument
    static double
    standardDeviation(double[] args)
    interface function for degenerative case of one argument
    static double
    interface function for degenerative case of one argument It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)
    static BigDecimal
    tan(BigDecimal input)
     
    static int
    testNumval(String argument1)
    IBM's CALL FUNCTION TEST-NUMVAL (ARG)
    static int
    testNumvalC(String argument1)
    IBM's CALL FUNCTION TEST-NUMVAL-C (ARG)
    static String
    Deprecated.
    - please use java's string.trim()
    static double
    variance(double arg)
    Function for degenerative case of one argument
    static double
    variance(double[] args)
    Function for degenerative case of one argument
    static double
    Function for degenerative case of one argument It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • log

      protected static transient Log log
  • Constructor Details

    • CBLMath

      public CBLMath()
  • Method Details

    • max

      public static double max(double[] args)
      returns largest number in the sequence
      Parameters:
      args -
      Returns:
    • max

      public static String max(String[] args)
      return maximum from sequence of strings, where maximum is determined through lexicographical comparisons
      Parameters:
      args -
      Returns:
      lexicographical maximum
    • max

      public static String max(CBLString theField)
      return maximum from a field. It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)
      Parameters:
      theField -
      Returns:
    • max

      public static double max(AbstractCBLNumeric theField)
      return maximum from a field. It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)
      Parameters:
      theField -
      Returns:
    • min

      public static double min(double[] args)
    • min

      public static BigDecimal min(BigDecimal[] args)
    • min

      public static String min(String[] args)
      return minimum from sequence of strings, where minimum is determined through lexicographical comparisons
      Parameters:
      args -
      Returns:
      lexicographical minimum
    • min

      public static double min(AbstractCBLNumeric theField)
      return minimum from a field. It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)
      Parameters:
      theField -
      Returns:
    • min

      public static String min(CBLString theField)
      return minimum from a field. It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)
      Parameters:
      theField -
      Returns:
    • mean

      public static double mean(double[] args)
    • mean

      public static double mean(AbstractCBLNumeric theField)
      return MEAN from an arrayed field. It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)
      Parameters:
      theField -
      Returns:
    • median

      public static double median(double[] args)
    • median

      public static double median(AbstractCBLNumeric theField)
      return median from a field. It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)
      Parameters:
      theField -
      Returns:
    • midrange

      public static double midrange(double[] args)
    • midrange

      public static double midrange(AbstractCBLNumeric theField)
      return MID-RANGE from a field. It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)
      Parameters:
      theField -
      Returns:
    • range

      public static double range(double[] args)
      return RANGE from a field (numerical difference between min and max) It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)
      Parameters:
      theField -
      Returns:
    • range

      public static double range(AbstractCBLNumeric theField)
      return RANGE from a field. (numerical difference between min and max) It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)
      Parameters:
      theField -
      Returns:
    • mod

      public static double mod(double arg1, double arg2)
    • ordMax

      public static int ordMax(double[] args)
      Translation of COBOL INTRINSIC FUNCTION ORD-MAX.
      returns position of the largest (max) item in the provided list. The position is starts at 1
      Returns:
      \
    • ordMax

      public static double ordMax(AbstractCBLNumeric theField)
      Translation of COBOL INTRINSIC FUNCTION ORD-MAX. It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)
      returns position of the largest (max) item in the provided list. The position is starts at 1
      Returns:
      \
    • ordMax

      public static int ordMax(String[] args)
      Translation of COBOL INTRINSIC FUNCTION ORD-MAX.
      returns position of the largest (max) item in the provided list. The position is starts at 1
      Parameters:
      args -
      Returns:
    • ordMin

      public static int ordMin(double[] args)
      Translation of COBOL INTRINSIC FUNCTION ORD-MIN.
      returns position of the smallest (min) item in the provided list. The position is starts at 1
      Returns:
    • ordMin

      public static int ordMin(String[] args)
      Translation of COBOL INTRINSIC FUNCTION ORD-MIN.
      returns position of the smallest (min) item in the provided list. The position is starts at 1
    • ordMin

      public static double ordMin(AbstractCBLNumeric theField)
      Translation of COBOL INTRINSIC FUNCTION ORD-MIN. It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)
      returns position of the smallest (min) item in the provided list. The position is starts at 1
    • variance

      public static double variance(double arg)
      Function for degenerative case of one argument
    • variance

      public static double variance(double[] args)
      Function for degenerative case of one argument
    • variance

      public static double variance(AbstractCBLNumeric theField)
      Function for degenerative case of one argument It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)
    • standardDeviation

      public static double standardDeviation(double arg)
      interface function for degenerative case of one argument
    • standardDeviation

      public static double standardDeviation(double[] args)
      interface function for degenerative case of one argument
    • standardDeviation

      public static double standardDeviation(AbstractCBLNumeric theField)
      interface function for degenerative case of one argument It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)
    • presentField

      public static double presentField(double arg1, double[] args2)
      Deprecated.
      - use persentValue
      Parameters:
      arg1 -
      args2 -
      Returns:
    • presentValue

      public static double presentValue(double arg1, double[] args2)
      Translation of COBOL INTRINSIC FUNCTION PRESENT-VALUE
      Parameters:
      arg1 -
      args2 -
      Returns:
    • presentField

      public static double presentField(double[] args2)
      Deprecated.
      - use persentValue
      Parameters:
      args2 -
      arg1 -
      Returns:
    • presentField

      public static double presentField(AbstractCBLNumeric theField)
      Deprecated.
      - please use presentValue
      Translation of COBOL INTRINSIC FUNCTION PRESENT-VALUE It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)
      Parameters:
      theField -
      Returns:
    • presentValue

      public static double presentValue(AbstractCBLNumeric theField)
      Translation of COBOL INTRINSIC FUNCTION PRESENT-VALUE It is expected the field internally represents an arrayed field (it may have multi-dim OCCURS declarations)
      Parameters:
      theField -
      Returns:
    • presentValue

      public static double presentValue(double[] args2)
      Translation of COBOL INTRINSIC FUNCTION PRESENT-VALUE
      Parameters:
      args2 -
      arg1 -
      Returns:
    • numval

      public static double numval(String value)
      return numeric value of its argument. NB: currently, CR and DB trailings are not supported
      Parameters:
      value -
      Returns:
      - value of field as a Double
    • testNumvalC

      public static int testNumvalC(String argument1)
      IBM's CALL FUNCTION TEST-NUMVAL-C (ARG)
      Parameters:
      argument1 -
      Returns:
    • testNumval

      public static int testNumval(String argument1)
      IBM's CALL FUNCTION TEST-NUMVAL (ARG)
      Parameters:
      argument1 -
      Returns:
    • numval

      public static double numval(ISMNumeric field)
      return numeric value of its first argument
      Parameters:
      field -
      Returns:
      - value of field as a Double
    • numval

      public static double numval(CBLString field)
      return numeric value of its first argument
      Parameters:
      field -
      Returns:
      - value of field as a Double
    • numvalC

      public static double numvalC(String value)
      return numeric value of its first argument
      Parameters:
      value -
      Returns:
      - value of field as a Double
    • numvalC

      public static double numvalC(ISMString value)
      return numeric value of its first argument
      Parameters:
      value -
      Returns:
      - value of field as a Double
    • numvalC

      public static double numvalC(ISMNumeric field)
      return numeric value of its first argument
      Parameters:
      field -
      Returns:
      - value of field as a Double
    • numvalC

      public static double numvalC(String value, String currencySign)
      return numeric value of its first argument
      Parameters:
      value -
      currencySign -
      Returns:
      - value of field as a Double
    • numvalC

      public static double numvalC(ISMNumeric field, String currencySign)
      return numeric value of its first argument
      Parameters:
      field -
      currencySign -
      Returns:
      - value of field as a Double
    • numvalC

      public static double numvalC(ISMString field, String currencySign)
      return numeric value of its first argument
      Parameters:
      field -
      currencySign -
      Returns:
      - value of field as a Double
    • factorial

      public static double factorial(double value)
      return value of computed factorial for its first argument
      Parameters:
      value -
      Returns:
      - factorial
    • annuity

      public static double annuity(double percentage, double numberOfPeriods)
      return annuity value same as in COBOL
      Parameters:
      value -
      Returns:
      - annuity value for investment amount of 1.0
    • setRound

      public static final void setRound(ISMNumeric theField, double doubleVal)
      Support for COBOL's ROUNDED statement. E.g. Subtract A from B ROUNDED
      Parameters:
      doubleVal -
    • trim

      public static String trim(String s1)
      Deprecated.
      - please use java's string.trim()
      Parameters:
      s1 -
      Returns:
    • cos

      public static BigDecimal cos(BigDecimal input)
    • sin

      public static BigDecimal sin(BigDecimal input)
    • acos

      public static BigDecimal acos(BigDecimal input)
    • asin

      public static BigDecimal asin(BigDecimal input)
    • log

      public static BigDecimal log(BigDecimal input)
    • log10

      public static BigDecimal log10(BigDecimal input)
    • tan

      public static BigDecimal tan(BigDecimal input)
    • atan

      public static BigDecimal atan(BigDecimal input)