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 Number
ABS(Number number)
Returns the absolute value of a number.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 integerstatic Long
FACT(Integer number)
Returns the factorial of a number.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.static Boolean
ISEVEN(Number number)
Checks if a number is even.static Boolean
ISODD(Number number)
Checks if a number is odd.static Number
MAX(Number... numbers)
Returns the maximum of a list of numeric values.static Number
MIN(Number... numbers)
Returns the minimum of a list of numeric values.static Number
PRODUCT(Number... numbers)
Returns the product of a list of numbers.static Double
RAND()
Returns a random number between 0.0 and 1.0.static Integer
RANDBETWEEN(Integer bottomRange, Integer topRange)
Returns an Integer random number between bottom and top range (both inclusive).static BigDecimal
ROUND_CEILING(Number number, int scale)
Returns a BigDecimal number rounded towards positive infinity.static BigDecimal
ROUND_DOWN(Number number, int scale)
Returns a BigDecimal number rounded towards zero.static BigDecimal
ROUND_FLOOR(Number number, int scale)
Returns a BigDecimal number rounded towards negative infinity.static BigDecimal
ROUND_HALF_DOWN(Number number, int scale)
Returns a BigDecimal number rounded towards its nearest neighbor.static BigDecimal
ROUND_HALF_EVEN(Number number, int scale)
Returns a BigDecimal number rounded towards its nearest neighbor.static BigDecimal
ROUND_HALF_UP(Number number, int scale)
Returns a BigDecimal number rounded towards its nearest neighbor.static BigDecimal
ROUND_UP(Number number, int scale)
Returns a BigDecimal number rounded away from zero.static Integer
SIGN(Number number)
Returns the sign of a number.static Number
SQRT(Number number)
Returns the positive square root of a number.static Number
SUM(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.
-
-