Class MathUtil

java.lang.Object
org.seppiko.commons.utils.MathUtil

public class MathUtil extends Object
Math Util
Author:
Leonard Woo
  • Method Details

    • maxDecimal

      public static BigDecimal maxDecimal(List<BigDecimal> nums) throws NoSuchElementException
      BigDecimal list max number
      Parameters:
      nums - number list
      Returns:
      maximum
      Throws:
      NoSuchElementException - list is null
    • maxInteger

      public static BigInteger maxInteger(List<BigInteger> nums) throws NoSuchElementException
      BigInteger list max number
      Parameters:
      nums - number list
      Returns:
      maximum
      Throws:
      NoSuchElementException - list is null
    • minDecimal

      public static BigDecimal minDecimal(List<BigDecimal> nums) throws NoSuchElementException
      BigDecimal list min number
      Parameters:
      nums - number list
      Returns:
      minimum
      Throws:
      NoSuchElementException - list is null
    • minInteger

      public static BigInteger minInteger(List<BigInteger> nums) throws NoSuchElementException
      BigInteger list min number
      Parameters:
      nums - number list
      Returns:
      minimum
      Throws:
      NoSuchElementException - list is null
    • avgDecimal

      public static BigDecimal avgDecimal(List<BigDecimal> nums, RoundingMode roundingMode)
      BigDecimal list avg number
      Parameters:
      nums - number list
      roundingMode - RoundingMode
      Returns:
      average
    • avgDecimal

      public static double avgDecimal(List<BigDecimal> nums) throws NoSuchElementException
      BigDecimal list avg number
      Parameters:
      nums - number list
      Returns:
      average double
      Throws:
      NoSuchElementException - list is null
    • avgInteger

      public static BigDecimal avgInteger(List<BigInteger> nums, RoundingMode roundingMode)
      BigInteger list avg number
      Parameters:
      nums - number list
      roundingMode - RoundingMode
      Returns:
      average
    • pow

      public static BigInteger pow(int a, int b)
      Returns the value of the first argument raised to the power of the second argument.
      Parameters:
      a - the base.
      b - the exponent.
      Returns:
      the value ab.
    • pow

      public static BigInteger pow(long a, int b)
      Returns the value of the first argument raised to the power of the second argument.
      Parameters:
      a - the base.
      b - the exponent.
      Returns:
      the value ab.
    • pow

      public static BigInteger pow(BigInteger a, int b)
      Returns the value of the first argument raised to the power of the second argument.
      Parameters:
      a - the base.
      b - the exponent.
      Returns:
      the value ab.
    • pow

      public static BigDecimal pow(double a, int b)
      Returns the value of the first argument raised to the power of the second argument.
      Parameters:
      a - the base.
      b - the exponent.
      Returns:
      the value ab.
    • pow

      public static BigDecimal pow(BigDecimal a, int b)
      Returns the value of the first argument raised to the power of the second argument.
      Parameters:
      a - the base.
      b - the exponent.
      Returns:
      the value ab.
    • convertDecimalTo

      public static String convertDecimalTo(long num, char[] alphabet)
      Convert decimal to alphabet number
      Parameters:
      num - number (greater than 0)
      alphabet - alphabet
      Returns:
      alphabet base, if num lass than 1 will return null
    • convertToDecimal

      public static Long convertToDecimal(CharSequence num, char[] alphabet)
      Convert alphabet number to decimal
      Parameters:
      num - number
      alphabet - alphabet
      Returns:
      if return null than num parser failed