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