Package org.seppiko.commons.utils
Class MathUtil
java.lang.Object
org.seppiko.commons.utils.MathUtil
public class MathUtil
extends java.lang.Object
Math Util
- Author:
- Leonard Woo
-
Constructor Summary
Constructors Constructor Description MathUtil() -
Method Summary
Modifier and Type Method Description static doubleavgDecimal(java.util.List<java.math.BigDecimal> nums)BigDecimal list avg numberstatic java.math.BigDecimalavgDecimal(java.util.List<java.math.BigDecimal> nums, java.math.RoundingMode roundingMode)BigDecimal list avg numberstatic java.math.BigDecimalavgInteger(java.util.List<java.math.BigInteger> nums, java.math.RoundingMode roundingMode)BigInteger list avg numberstatic java.lang.StringconvertDecimalTo(int num, char[] alphabet)Convert decimal to alphabet numberstatic java.lang.IntegerconvertToDecimal(java.lang.CharSequence num, char[] alphabet)Convert any base to decimalstatic java.lang.Stringformat(java.lang.String precisionPattern, double number)Double formatstatic java.math.BigDecimalmaxDecimal(java.util.List<java.math.BigDecimal> nums)BigDecimal list max numberstatic java.math.BigIntegermaxInteger(java.util.List<java.math.BigInteger> nums)BigInteger list max numberstatic java.math.BigDecimalminDecimal(java.util.List<java.math.BigDecimal> nums)BigDecimal list min numberstatic java.math.BigIntegerminInteger(java.util.List<java.math.BigInteger> nums)BigInteger list min numberMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
MathUtil
public MathUtil()
-
-
Method Details
-
maxDecimal
public static java.math.BigDecimal maxDecimal(java.util.List<java.math.BigDecimal> nums) throws java.util.NoSuchElementExceptionBigDecimal list max number- Parameters:
nums- number list- Returns:
- maximum
- Throws:
java.util.NoSuchElementException- list is null
-
maxInteger
public static java.math.BigInteger maxInteger(java.util.List<java.math.BigInteger> nums) throws java.util.NoSuchElementExceptionBigInteger list max number- Parameters:
nums- number list- Returns:
- maximum
- Throws:
java.util.NoSuchElementException- list is null
-
minDecimal
public static java.math.BigDecimal minDecimal(java.util.List<java.math.BigDecimal> nums) throws java.util.NoSuchElementExceptionBigDecimal list min number- Parameters:
nums- number list- Returns:
- minimum
- Throws:
java.util.NoSuchElementException- list is null
-
minInteger
public static java.math.BigInteger minInteger(java.util.List<java.math.BigInteger> nums) throws java.util.NoSuchElementExceptionBigInteger list min number- Parameters:
nums- number list- Returns:
- minimum
- Throws:
java.util.NoSuchElementException- list is null
-
avgDecimal
public static java.math.BigDecimal avgDecimal(java.util.List<java.math.BigDecimal> nums, java.math.RoundingMode roundingMode)BigDecimal list avg number- Parameters:
nums- number listroundingMode- RoundingMode- Returns:
- average
-
avgDecimal
public static double avgDecimal(java.util.List<java.math.BigDecimal> nums) throws java.util.NoSuchElementExceptionBigDecimal list avg number- Parameters:
nums- number list- Returns:
- average double
- Throws:
java.util.NoSuchElementException- list is null
-
avgInteger
public static java.math.BigDecimal avgInteger(java.util.List<java.math.BigInteger> nums, java.math.RoundingMode roundingMode)BigInteger list avg number- Parameters:
nums- number listroundingMode- RoundingMode- Returns:
- average
-
format
public static java.lang.String format(java.lang.String precisionPattern, double number)Double format- Parameters:
precisionPattern- precision pattern, e.g. 0.00number- double number- Returns:
- formatted string
-
convertDecimalTo
public static java.lang.String convertDecimalTo(int num, char[] alphabet)Convert decimal to alphabet number- Parameters:
num- number (greater than 0)alphabet- alphabet- Returns:
- alphabet base
-
convertToDecimal
public static java.lang.Integer convertToDecimal(java.lang.CharSequence num, char[] alphabet)Convert any base to decimal- Parameters:
num- numberalphabet- base- Returns:
- if null num parser failed
-