Class NumberUtil


  • public class NumberUtil
    extends Object
    Number- and math-related utilities.
    Since:
    2.3.20
    • Method Detail

      • isInfinite

        public static boolean isInfinite​(Number num)
      • isNaN

        public static boolean isNaN​(Number num)
      • isIntegerBigDecimal

        public static boolean isIntegerBigDecimal​(BigDecimal bd)
        Tells if a BigDecimal stores a whole number. For example, it returns true for 1.0000, but false for 1.0001.
        Since:
        2.3.21
      • toIntExact

        public static int toIntExact​(Number num)
        Converts a Number to int whose mathematical value is exactly the same as of the original number.
        Throws:
        ArithmeticException - if the conversion to int is not possible without losing precision or overflow/underflow.
        Since:
        2.3.22