Class NumberUtil
- java.lang.Object
-
- org.pentaho.reporting.libraries.formula.util.NumberUtil
-
public class NumberUtil extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static BigDecimal
DELTA
static BigDecimal
INT_TEST_DELTA
static BigDecimal
MINUTE_ROUNDING_DELTA
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BigDecimal
divide(BigDecimal bd1, BigDecimal bd2)
static BigDecimal
getAsBigDecimal(Number number)
static BigDecimal
performIntRounding(BigDecimal n)
Performs a rounding to get a more reliable (int) cast.static BigDecimal
performMinuteRounding(BigDecimal n)
Performs a rounding to get a more reliable (int) cast for minute functionMinuteFunction
.static BigDecimal
performTuneRounding(BigDecimal n)
static BigDecimal
removeTrailingZeros(BigDecimal bd)
-
-
-
Field Detail
-
DELTA
public static final BigDecimal DELTA
-
MINUTE_ROUNDING_DELTA
public static final BigDecimal MINUTE_ROUNDING_DELTA
-
INT_TEST_DELTA
public static final BigDecimal INT_TEST_DELTA
-
-
Method Detail
-
getAsBigDecimal
public static BigDecimal getAsBigDecimal(Number number)
-
performIntRounding
public static BigDecimal performIntRounding(BigDecimal n)
Performs a rounding to get a more reliable (int) cast. This makes sure that nearly exact values like 0.9999999..9999 are correctly interpreted as 1 while exact values like 0.99 are interpreted as 0.- Parameters:
n
-- Returns:
-
performMinuteRounding
public static BigDecimal performMinuteRounding(BigDecimal n)
Performs a rounding to get a more reliable (int) cast for minute functionMinuteFunction
. Seeorg.pentaho.reporting.libraries.formula.util.NumberUtilTest#testPerformMinuteRounding()
for more information.- Parameters:
n
- value of theBigDecimal
to be rounded- Returns:
- a
BigDecimal
rounded value - See Also:
org.pentaho.reporting.libraries.formula.function.datetime.MinuteFunctionTest.java
-
performTuneRounding
public static BigDecimal performTuneRounding(BigDecimal n)
-
removeTrailingZeros
public static BigDecimal removeTrailingZeros(BigDecimal bd)
-
divide
public static BigDecimal divide(BigDecimal bd1, BigDecimal bd2) throws EvaluationException
- Throws:
EvaluationException
-
-