Class NumberUtil


  • public class NumberUtil
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.math.BigDecimal DELTA  
      static java.math.BigDecimal INT_TEST_DELTA  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.math.BigDecimal divide​(java.math.BigDecimal bd1, java.math.BigDecimal bd2)  
      static java.math.BigDecimal getAsBigDecimal​(java.lang.Number number)  
      static java.math.BigDecimal performIntRounding​(java.math.BigDecimal n)
      Performs a rounding to get a more reliable (int) cast.
      static java.math.BigDecimal performTuneRounding​(java.math.BigDecimal n)  
      static java.math.BigDecimal removeTrailingZeros​(java.math.BigDecimal bd)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DELTA

        public static final java.math.BigDecimal DELTA
      • INT_TEST_DELTA

        public static final java.math.BigDecimal INT_TEST_DELTA
    • Method Detail

      • getAsBigDecimal

        public static java.math.BigDecimal getAsBigDecimal​(java.lang.Number number)
      • performIntRounding

        public static java.math.BigDecimal performIntRounding​(java.math.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 java.math.BigDecimal performTuneRounding​(java.math.BigDecimal n)
      • removeTrailingZeros

        public static java.math.BigDecimal removeTrailingZeros​(java.math.BigDecimal bd)