public class NumberUtil extends Object
Modifier and Type | Method and Description |
---|---|
static int |
getSignum(Number num) |
static boolean |
isInfinite(Number num) |
static boolean |
isIntegerBigDecimal(BigDecimal bd)
Tells if a
BigDecimal stores a whole number. |
static boolean |
isNaN(Number num) |
static int |
toIntExact(Number num)
Converts a
Number to int whose mathematical value is exactly the same as of the original number. |
public static boolean isInfinite(Number num)
public static boolean isNaN(Number num)
public static int getSignum(Number num) throws ArithmeticException
ArithmeticException
- if the number is NaNpublic static boolean isIntegerBigDecimal(BigDecimal bd)
BigDecimal
stores a whole number. For example, it returns true
for 1.0000
,
but false
for 1.0001
.public static int toIntExact(Number num)
Number
to int
whose mathematical value is exactly the same as of the original number.ArithmeticException
- if the conversion to int
is not possible without losing precision or overflow/underflow.