Package freemarker.template.utility
Class NumberUtil
java.lang.Object
freemarker.template.utility.NumberUtil
Number- and math-related utilities.
- Since:
- 2.3.20
-
Method Summary
Modifier and TypeMethodDescriptionstatic intstatic booleanTells if the type of the parameter number is known to not be able to represent infinite (positive or negative) and NaN.static booleanisInfinite(Number num)static booleanTells if aBigDecimalstores a whole number.static booleanstatic inttoIntExact(Number num)Converts aNumbertointwhose mathematical value is exactly the same as of the original number.
-
Method Details
-
isInfinite
-
isNaN
-
getSignum
- Returns:
- -1 for negative, 0 for zero, 1 for positive.
- Throws:
ArithmeticException- if the number is NaN
-
isIntegerBigDecimal
Tells if aBigDecimalstores a whole number. For example, it returnstruefor1.0000, butfalsefor1.0001.- Since:
- 2.3.21
-
hasTypeThatIsKnownToNotSupportInfiniteAndNaN
Tells if the type of the parameter number is known to not be able to represent infinite (positive or negative) and NaN. If this returnsfalse, that doesn't mean that it can do that, because it's maybe just that this utility doesn't know that type.- Since:
- 2.3.28
-
toIntExact
Converts aNumbertointwhose mathematical value is exactly the same as of the original number.- Throws:
ArithmeticException- if the conversion tointis not possible without losing precision or overflow/underflow.- Since:
- 2.3.22
-