Package freemarker.template.utility
Class NumberUtil
- java.lang.Object
-
- freemarker.template.utility.NumberUtil
-
public class NumberUtil extends Object
Number- and math-related utilities.- Since:
- 2.3.20
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intgetSignum(Number num)static booleanisInfinite(Number num)static booleanisIntegerBigDecimal(BigDecimal bd)Tells if aBigDecimalstores a whole number.static booleanisNaN(Number num)static inttoIntExact(Number num)Converts aNumbertointwhose mathematical value is exactly the same as of the original number.
-
-
-
Method Detail
-
isInfinite
public static boolean isInfinite(Number num)
-
isNaN
public static boolean isNaN(Number num)
-
getSignum
public static int getSignum(Number num) throws ArithmeticException
- Returns:
- -1 for negative, 0 for zero, 1 for positive.
- Throws:
ArithmeticException- if the number is NaN
-
isIntegerBigDecimal
public static boolean isIntegerBigDecimal(BigDecimal bd)
Tells if aBigDecimalstores a whole number. For example, it returnstruefor1.0000, butfalsefor1.0001.- Since:
- 2.3.21
-
toIntExact
public static int toIntExact(Number num)
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
-
-