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 Summary
Constructors Constructor Description MathFunctions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static NumberABS(Number number)Returns the absolute value of a number.static DoubleCEIL(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 integerstatic LongFACT(Integer number)Returns the factorial of a number.static DoubleFLOOR(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.static BooleanISEVEN(Number number)Checks if a number is even.static BooleanISODD(Number number)Checks if a number is odd.static NumberMAX(Number... numbers)Returns the maximum of a list of numeric values.static NumberMIN(Number... numbers)Returns the minimum of a list of numeric values.static NumberPRODUCT(Number... numbers)Returns the product of a list of numbers.static DoubleRAND()Returns a random number between 0.0 and 1.0.static IntegerRANDBETWEEN(Integer bottomRange, Integer topRange)Returns an Integer random number between bottom and top range (both inclusive).static BigDecimalROUND_CEILING(Number number, int scale)Returns a BigDecimal number rounded towards positive infinity.static BigDecimalROUND_DOWN(Number number, int scale)Returns a BigDecimal number rounded towards zero.static BigDecimalROUND_FLOOR(Number number, int scale)Returns a BigDecimal number rounded towards negative infinity.static BigDecimalROUND_HALF_DOWN(Number number, int scale)Returns a BigDecimal number rounded towards its nearest neighbor.static BigDecimalROUND_HALF_EVEN(Number number, int scale)Returns a BigDecimal number rounded towards its nearest neighbor.static BigDecimalROUND_HALF_UP(Number number, int scale)Returns a BigDecimal number rounded towards its nearest neighbor.static BigDecimalROUND_UP(Number number, int scale)Returns a BigDecimal number rounded away from zero.static IntegerSIGN(Number number)Returns the sign of a number.static NumberSQRT(Number number)Returns the positive square root of a number.static NumberSUM(Number... numbers)Returns the sum of a list of numbers.
-
-
-
Method Detail
-
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.
-
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).
-
SQRT
public static Number SQRT(Number number)
Returns the positive square root of a number. The number must be positive.
-
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 theROUND_UP(java.lang.Number,int)function, for negative values behaves as theROUND_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 theROUND_DOWN(java.lang.Number,int)function, for negative values behaves as theROUND_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 theROUND_UP(java.lang.Number,int)function if the discarded fraction is ≥ 0.5; otherwise, behaves as theROUND_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 theROUND_HALF_UP(java.lang.Number,int)function if the digit to the left of the discarded fraction is odd; otherwise, behaves as theROUND_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 theROUND_UP(java.lang.Number,int)function if the discarded fraction is > 0.5; otherwise, behaves as theROUND_DOWN(java.lang.Number,int)function.
-
-