public class MathUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T extends Number> |
divide(T dividend,
T divisor)
Returns a double average number by given dividend and divisor.
Returns 0 if dividend == null or divisor == null. Returns 1 if dividend == divisor or divisor == 0. |
static <T extends Number> |
divideRoundDown(T dividend,
T divisor)
Returns a long average number by round down with specify dividend and
divisor.
Returns 0 if dividend == null or divisor == null. Returns 1 if dividend == divisor or divisor == 0. e.g: average is 3.5, then return 3. |
static <T extends Number> |
divideRoundUp(T dividend,
T divisor)
Returns a long average number by round up with specify dividend and
divisor.
Returns 0 if dividend == null or divisor == null. Returns 1 if dividend == divisor or divisor == 0. e.g: average is 3.5, then return 4. |
static <T extends Number> |
isAliquot(T dividend,
T divisor)
Judge divisor is an aliquot part of dividend. 判断被除数是否能被除数整除。
|
static double |
randomDouble()
Returns a double value between 0.0 and 1.0 from this random number.
|
static float |
randomFloat()
Returns a float value between 0.0 and 1.0 from this random number.
|
static int |
randomInt()
Returns a natural integer value between 0 and integer max value.
|
static int |
randomInt(int max)
Returns a natural integer value between 0 and given max value.
|
static int |
randomInt(int min,
int max)
Returns a natural integer number between given minimum value and max
value.
|
static long |
randomLong()
Returns a random long value.
|
static long |
randomLong(long max)
Returns a natural long value between 0 and given max value.
|
static long |
randomLong(long min,
long max)
Returns a natural long value between given minimum value and max value.
|
static <T extends Number> |
RoundDown(T number)
Returns a long number by round down with specify number.
Returns 0 if number == null. e.g: average is 3.5, then return 3. |
static <T extends Number> |
RoundUp(T number)
Returns a long number by round up with specify number.
Returns 0 if number == null. e.g: average is 3.5, then return 4. |
public static int randomInt()
public static int randomInt(int max)
max - the max value to random.public static int randomInt(int min,
int max)
min - the minimum value to random.max - the max value to random.public static long randomLong()
public static long randomLong(long max)
max - the max value to random.public static long randomLong(long min,
long max)
min - the minimum value to random.max - the max value to random.public static double randomDouble()
public static float randomFloat()
public static <T extends Number> long RoundUp(T number)
number - number to be handled.public static <T extends Number> long RoundDown(T number)
number - number to be handled.public static <T extends Number> double divide(T dividend, T divisor)
dividend - number to be handled.divisor - number to be handled.public static <T extends Number> long divideRoundUp(T dividend, T divisor)
dividend - number to be handled.divisor - number to be handled.public static <T extends Number> long divideRoundDown(T dividend, T divisor)
dividend - number to be handled.divisor - number to be handled.public static <T extends Number> boolean isAliquot(T dividend, T divisor)
dividend - number to be handled.被除数。divisor - number to be handled.除数。Copyright © 2014. All rights reserved.