org.pentaho.reporting.libraries.formula.util
Class NumberUtil

java.lang.Object
  extended by org.pentaho.reporting.libraries.formula.util.NumberUtil

public class NumberUtil
extends Object


Field Summary
static BigDecimal DELTA
           
static BigDecimal INT_TEST_DELTA
           
 
Method Summary
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 performTuneRounding(BigDecimal n)
           
static BigDecimal removeTrailingZeros(BigDecimal bd)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DELTA

public static final BigDecimal 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:

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