Class MathFunctions


  • public final class MathFunctions
    extends Object
    This class should maintain all function methods that belongs to the Math category.
    Author:
    Massimo Rabbi (mrabbi@users.sourceforge.net)
    • Constructor Detail

      • MathFunctions

        public MathFunctions()
    • Method Detail

      • ABS

        public static Number ABS​(Number number)
        Returns the absolute value of a number.
      • FACT

        public static Long FACT​(Integer number)
        Returns the factorial of a number.
      • ISEVEN

        public static Boolean ISEVEN​(Number number)
        Checks if a number is even. If a non-integer number is specified, any digits after the decimal point are ignored.
      • ISODD

        public static Boolean ISODD​(Number number)
        Checks if a number is odd. If a non-integer number is specified, any digits after the decimal point are ignored.
      • PRODUCT

        public static Number PRODUCT​(Number... numbers)
        Returns the product of a list of numbers.
      • RAND

        public static Double RAND()
        Returns a random number between 0.0 and 1.0.
      • RANDBETWEEN

        public static Integer RANDBETWEEN​(Integer bottomRange,
                                          Integer topRange)
        Returns an Integer random number between bottom and top range (both inclusive).
      • SIGN

        public static Integer SIGN​(Number number)
        Returns the sign of a number.
      • SQRT

        public static Number SQRT​(Number number)
        Returns the positive square root of a number. The number must be positive.
      • SUM

        public static Number SUM​(Number... numbers)
        Returns the sum of a list of numbers.
      • MIN

        public static Number MIN​(Number... numbers)
        Returns the minimum of a list of numeric values.
      • MAX

        public static Number MAX​(Number... numbers)
        Returns the maximum of a list of numeric values.
      • FLOOR

        public static Double FLOOR​(Number number)
        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.
      • CEIL

        public static Double CEIL​(Number number)
        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
      • ROUND_UP

        public static BigDecimal ROUND_UP​(Number number,
                                          int scale)
        Returns a BigDecimal number rounded away from zero. It always increments the digit prior to a non-zero discarded fraction.
      • ROUND_DOWN

        public static BigDecimal ROUND_DOWN​(Number number,
                                            int scale)
        Returns a BigDecimal number rounded towards zero. It never increments the digit prior to a discarded fraction
      • ROUND_HALF_EVEN

        public static BigDecimal ROUND_HALF_EVEN​(Number number,
                                                 int scale)
        Returns a BigDecimal number rounded towards its nearest neighbor. If both neighbors are equidistant, the number is rounded towards the even neighbor. Behaves as the ROUND_HALF_UP(java.lang.Number, int) function if the digit to the left of the discarded fraction is odd; otherwise, behaves as the ROUND_HALF_DOWN(java.lang.Number, int) function. This rounding mode statistically minimizes cumulative error when it is repeatedly applied over a sequence of calculations.