public class MathUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static BigDecimal |
parseAsBigDecimal(String s) |
static BigDecimal |
parseAsBigDecimal(String s,
int maxNumberOfChars) |
static BigInteger |
parseAsBigInteger(String s) |
static double |
parseAsDouble(String s) |
static double |
parseAsDouble(String s,
int maxNumberOfChars) |
static float |
parseAsFloat(String s) |
static float |
parseAsFloat(String s,
int maxNumberOfChars) |
static int |
parseAsInt(String s) |
static long |
parseAsLong(String s) |
static int |
safeDoubleToInt(double d) |
static int |
safeFloatToInt(float f) |
static BigInteger |
toBigInteger(BigDecimal value) |
static int |
toInt(BigDecimal value) |
static long |
toLong(BigDecimal value) |
public static int safeFloatToInt(float f)
public static int safeDoubleToInt(double d)
public static BigDecimal parseAsBigDecimal(String s)
s - string to parseNumberFormatException - if parse failsIllegalArgumentException - if string is too longNullPointerException - if string is nullpublic static BigDecimal parseAsBigDecimal(String s, int maxNumberOfChars)
s - string to parsemaxNumberOfChars - maximum number of characters allowed in the stringNumberFormatException - if parse failsIllegalArgumentException - if string is too longNullPointerException - if string is nullpublic static BigInteger parseAsBigInteger(String s)
s - string to parseNumberFormatException - if parse failsIllegalArgumentException - if string is too longNullPointerException - if string is nullpublic static float parseAsFloat(String s)
s - string to parseNumberFormatException - if parse failsIllegalArgumentException - if string is too longNullPointerException - if string is nullpublic static float parseAsFloat(String s, int maxNumberOfChars)
s - string to parsemaxNumberOfChars - maximum number of characters allowed in the stringNumberFormatException - if parse failsIllegalArgumentException - if string is too longNullPointerException - if string is nullpublic static double parseAsDouble(String s)
s - string to parseNumberFormatException - if parse failsIllegalArgumentException - if string is too longNullPointerException - if string is nullpublic static double parseAsDouble(String s, int maxNumberOfChars)
s - string to parsemaxNumberOfChars - maximum number of characters allowed in the stringNumberFormatException - if parse failsIllegalArgumentException - if string is too longNullPointerException - if string is nullpublic static long parseAsLong(String s)
s - string to parseNumberFormatException - if parse failsIllegalArgumentException - if string is too longNullPointerException - if string is nullpublic static int parseAsInt(String s)
s - string to parseNumberFormatException - if parse failsIllegalArgumentException - if string is too longNullPointerException - if string is nullpublic static BigInteger toBigInteger(BigDecimal value)
value - BigDecimal to convertIllegalArgumentException - if the input has an absolute exponent that is too large to safely convertNullPointerException - if value is nullpublic static long toLong(BigDecimal value)
value - BigDecimal to convertIllegalArgumentException - if the input has an absolute exponent that is too large to safely convert
or if the value is out of long rangeNullPointerException - if value is nullpublic static int toInt(BigDecimal value)
value - BigDecimal to convertIllegalArgumentException - if the input has an absolute exponent that is too large to safely convert
or if the value is out of int rangeNullPointerException - if value is null