Class MathUtil
java.lang.Object
jodd.util.MathUtil
Various math utilities.
note: Any random values from this class are not cryptographically secure!
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringhumanReadableByteCount(long bytes, boolean useSi) Formats byte size to human readable bytecount.static booleanisEven(int x) Returnstrueif a number is even.static booleanisOdd(int x) Returnstrueif a number is odd.static intparseDigit(char digit) Converts char digit into integer value.static intrandomInt(int min, int max) Generates pseudo-random integer from specific range.static longrandomLong(long min, long max) Generates pseudo-random long from specific range.
-
Constructor Details
-
MathUtil
public MathUtil()
-
-
Method Details
-
parseDigit
public static int parseDigit(char digit) Converts char digit into integer value. Accepts numeric chars (0 - 9) as well as letter (A-z). -
randomLong
public static long randomLong(long min, long max) Generates pseudo-random long from specific range. Generated number is great or equals to min parameter value and less then max parameter value.- Parameters:
min- lower (inclusive) boundarymax- higher (exclusive) boundary- Returns:
- pseudo-random value
-
randomInt
public static int randomInt(int min, int max) Generates pseudo-random integer from specific range. Generated number is great or equals to min parameter value and less then max parameter value.- Parameters:
min- lower (inclusive) boundarymax- higher (exclusive) boundary- Returns:
- pseudo-random value
-
isEven
public static boolean isEven(int x) Returnstrueif a number is even. -
isOdd
public static boolean isOdd(int x) Returnstrueif a number is odd. -
humanReadableByteCount
Formats byte size to human readable bytecount. https://stackoverflow.com/questions/3758606/how-to-convert-byte-size-into-human-readable-format-in-java/3758880#3758880
-