类 MathUtil


  • public final class MathUtil
    extends Object
    This util class can make some formal calculation.
    • 方法详细资料

      • Factorial

        public static long Factorial​(int n)
        Calc the factorial of n
        参数:
        n - The number N should greater or equal to 0
        返回:
        The result of factorial n
        抛出:
        RuntimeException - The n should greater or equal to 0
      • Sum

        public static double Sum​(Collection<? extends Number> numbers)
        Get the sum of the numbers
        参数:
        numbers - The numbers
        返回:
        The sum value of the numbers
      • Average

        public static double Average​(Collection<? extends Number> numbers)
        Get the average value of the numbers
        参数:
        numbers - The numbers
        返回:
        The average value of the numbers
      • IsBetween

        public static boolean IsBetween​(Number num,
                                        Number noLess,
                                        Number noGreater)
        Check the num whether is between the noLess and noGreater number
        参数:
        num - The number
        noLess - The num should not less than this number.
        noGreater - The num should not bigger than this number.
        返回:
        True while num no less than noLess and num no graeter than noGreater.
      • IsNotBetween

        public static boolean IsNotBetween​(Number num,
                                           Number noLess,
                                           Number noGreater)
        Check the num whether is not between the noLess and noGreater number
        参数:
        num - The number
        noLess - The num should not less than this number.
        noGreater - The num should not bigger than this number.
        返回:
        True while num no less than noLess and num no graeter than noGreater.
      • ToHexString

        public static String ToHexString​(int value,
                                         boolean toUpper)
        Transformat a decimal number to hex number.
        参数:
        value - The number with decimal format.
        toUpper - To specify will it be transformatted to Upper case. Default in lower case.
        返回:
        The hex string of the number.
      • ToBinaryString

        public static String ToBinaryString​(int value)
      • ToOctalString

        public static String ToOctalString​(int value)