Class MathFunctions

java.lang.Object
net.sf.jasperreports.functions.standard.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 Details

    • MathFunctions

      public MathFunctions()
  • Method Details

    • 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_CEILING

      public static BigDecimal ROUND_CEILING(Number number, int scale)
      Returns a BigDecimal number rounded towards positive infinity. For positive values behaves as the ROUND_UP(java.lang.Number, int) function, for negative values behaves as the ROUND_DOWN(java.lang.Number, int) function.
    • ROUND_FLOOR

      public static BigDecimal ROUND_FLOOR(Number number, int scale)
      Returns a BigDecimal number rounded towards negative infinity. For positive values behaves as the ROUND_DOWN(java.lang.Number, int) function, for negative values behaves as the ROUND_UP(java.lang.Number, int) function.
    • ROUND_HALF_UP

      public static BigDecimal ROUND_HALF_UP(Number number, int scale)
      Returns a BigDecimal number rounded towards its nearest neighbor. If both neighbors are equidistant, the number is rounded up. Behaves as the ROUND_UP(java.lang.Number, int) function if the discarded fraction is ≥ 0.5; otherwise, behaves as the ROUND_DOWN(java.lang.Number, int) function.
    • 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.
    • ROUND_HALF_DOWN

      public static BigDecimal ROUND_HALF_DOWN(Number number, int scale)
      Returns a BigDecimal number rounded towards its nearest neighbor. If both neighbors are equidistant, the number is rounded down. Behaves as the ROUND_UP(java.lang.Number, int) function if the discarded fraction is > 0.5; otherwise, behaves as the ROUND_DOWN(java.lang.Number, int) function.