Class MathFunctions


  • public class MathFunctions
    extends Object
    This class provides the math function for experssion evaluator
    • Constructor Detail

      • MathFunctions

        public MathFunctions​(ExpressionContext expressionContext)
        Default constructor
    • Method Detail

      • abs

        public static Double abs​(Double value)
        Returns the absolute value
        Parameters:
        value -
        Returns:
      • abs

        public static Long abs​(Long value)
      • min

        public static Double min​(Double value1,
                                 Double value2)
        Returns the minimum of two numbers.
        Parameters:
        value1 -
        value2 -
        Returns:
      • min

        public static Long min​(Long value1,
                               Long value2)
        Returns the minimum of two numbers.
        Parameters:
        value1 -
        value2 -
        Returns:
      • max

        public static Double max​(Double value1,
                                 Double value2)
        Returns the maximum of two numbers.
        Parameters:
        value1 -
        value2 -
        Returns:
      • max

        public static Double max​(Double value1,
                                 Long value2)
        Returns the maximum of two numbers.
        Parameters:
        value1 -
        value2 -
        Returns:
      • max

        public static Double max​(Long value1,
                                 Double value2)
        Returns the maximum of two numbers.
        Parameters:
        value1 -
        value2 -
        Returns:
      • max

        public static Long max​(Long value1,
                               Long value2)
        Returns the maximum of two numbers.
        Parameters:
        value1 -
        value2 -
        Returns:
      • sin

        public static Double sin​(Number value)
        Returns the trigonometric sine of an angle
        Parameters:
        value -
        Returns:
      • cos

        public static Double cos​(Number value)
        Returns the trigonometric cosine of an angle
        Parameters:
        value -
        Returns:
      • tan

        public static Double tan​(Number value)
        Returns the trigonometric tangent of an angle
        Parameters:
        value -
        Returns:
      • asin

        public static Double asin​(Number value)
        Returns the trigonometric arc sine of an angle
        Parameters:
        value -
        Returns:
      • acos

        public static Double acos​(Number value)
        Returns the trigonometric arc cosine of an angle
        Parameters:
        value -
        Returns:
      • atan

        public static Double atan​(Number value)
        Returns the trigonometric arc tangent of an angle
        Parameters:
        value -
        Returns:
      • atan2

        public static Double atan2​(Number y,
                                   Number x)
        Converts rectangular coordinates (xy) to polar (r,  theta ).
        Parameters:
        y -
        x -
        Returns:
      • exp

        public static Double exp​(Number value)
        Returns Euler's number e raised to the power of a double value. Special cases:
        Parameters:
        value - the exponent to raise e to.
        Returns:
      • pow

        public static Double pow​(Number base,
                                 Number exponent)
        Computes the power
        Parameters:
        base -
        exponent -
        Returns:
      • log

        public static Double log​(Number value)
        Returns the natural logarithm (base e ) of a double value.
        Parameters:
        value - a value
        Returns:
        the value ln  a, the natural logarithm of a.
      • sqrt

        public static Double sqrt​(Number value)
        Returns the correctly rounded positive square root of a double value.
        Parameters:
        value - a value.
        Returns:
        the positive square root of a. If the argument is NaN or less than zero, the result is NaN.
      • ceil

        public static Double ceil​(Number value)
        Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer.
        Parameters:
        a - a value.
        Returns:
      • floor

        public static Double floor​(Number value)
        Returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer.
        Parameters:
        value - a value.
        Returns:
      • rint

        public static Double rint​(Double value)
        Returns the double value that is closest in value to the argument and is equal to a mathematical integer. If two double values that are mathematical integers are equally close, the result is the integer value that is even.
        Parameters:
        value - a double value.
        Returns:
      • round

        public static Long round​(Double value)
        Returns the closest int to the argument. The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to type int. In other words, the result is equal to the value of the expression:

         (int) Math.floor( a + 0.5f )
         

        Parameters:
        a - a floating-point value to be rounded to an integer.
        Returns:
        the value of the argument rounded to the nearest int value.
      • random

        public static Double random()
        Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. Returned values are chosen pseudorandomly with (approximately) uniform distribution from that range.
        Returns:
        a pseudorandom double greater than or equal to 0.0 and less than 1.0.