类 MathUtil
- java.lang.Object
-
- cn.vorbote.commons.MathUtil
-
public final class MathUtil extends Object
This util class can make some formal calculation.
-
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static doubleAverage(Collection<? extends Number> numbers)Get the average value of the numbersstatic longFactorial(int n)Calc the factorial of nstatic booleanIsBetween(Number num, Number noLess, Number noGreater)Check the num whether is between the noLess and noGreater numberstatic booleanIsNotBetween(Number num, Number noLess, Number noGreater)Check the num whether is not between the noLess and noGreater numberstatic doubleSum(Collection<? extends Number> numbers)Get the sum of the numbersstatic StringToBinaryString(int value)static StringToHexString(int value, boolean toUpper)Transformat a decimal number to hex number.static StringToOctalString(int value)
-
-
-
方法详细资料
-
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 numbernoLess- Thenumshould not less than this number.noGreater- Thenumshould 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 numbernoLess- Thenumshould not less than this number.noGreater- Thenumshould 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)
-
-