org.pentaho.reporting.libraries.formula.util

Class NumberUtil

public class NumberUtil extends Object

Field Summary
static BigDecimalDELTA
static BigDecimalINT_TEST_DELTA
Method Summary
static BigDecimaldivide(BigDecimal bd1, BigDecimal bd2)
static BigDecimalgetAsBigDecimal(Number number)
static BigDecimalperformIntRounding(BigDecimal n)
Performs a rounding to get a more reliable (int) cast.
static BigDecimalperformTuneRounding(BigDecimal n)
static BigDecimalremoveTrailingZeros(BigDecimal bd)

Field Detail

DELTA

public static final BigDecimal DELTA

INT_TEST_DELTA

public static final BigDecimal INT_TEST_DELTA

Method Detail

divide

public static BigDecimal divide(BigDecimal bd1, BigDecimal bd2)

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:

performTuneRounding

public static BigDecimal performTuneRounding(BigDecimal n)

removeTrailingZeros

public static BigDecimal removeTrailingZeros(BigDecimal bd)