java.lang.Object
org.seppiko.commons.utils.NumberUtil
Number Util
- Author:
- Leonard Woo
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intFullwidth digits ('0'through'9')static final intISO-LATIN-1(ASCII) digits ('0'through'9') -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanbetween(byte num, byte min, byte max) test num between min and maxstatic booleanbetween(char num, char min, char max) test num between min and maxstatic booleanbetween(double num, double min, double max) test num between min and maxstatic booleanbetween(float num, float min, float max) test num between min and maxstatic booleanbetween(int num, int min, int max) test num between min and maxstatic booleanbetween(long num, long min, long max) test num between min and maxstatic booleanbetween(short num, short min, short max) test num between min and maxstatic booleanbetween(BigDecimal num, BigDecimal min, BigDecimal max) test num between min and maxstatic booleanbetween(BigInteger num, BigInteger min, BigInteger max) test num between min and maxstatic Stringconvert(CharSequence input, int outType) Convert betweenLATIN_DIGITSandFULLWIDTH_DIGITSand support calculation result.static StringDouble formatstatic int[]toUnsignedIntArray(byte[] src) byte array to unsigned int arraystatic long[]toUnsignedLongArray(int[] src) int array to unsigned long arraystatic int[]toUnsignedShortArray(short[] src) short array to unsigned int array
-
Field Details
-
LATIN_DIGITS
public static final int LATIN_DIGITSISO-LATIN-1(ASCII) digits ('0'through'9')- See Also:
-
FULLWIDTH_DIGITS
public static final int FULLWIDTH_DIGITSFullwidth digits ('0'through'9')- See Also:
-
-
Constructor Details
-
NumberUtil
public NumberUtil()
-
-
Method Details
-
between
public static boolean between(byte num, byte min, byte max) test num between min and max- Parameters:
num- numbermin- minimum numbermax- maximum number- Returns:
- true number is between the maximum and minimum
-
between
public static boolean between(short num, short min, short max) test num between min and max- Parameters:
num- numbermin- minimum numbermax- maximum number- Returns:
- true number is between the maximum and minimum
-
between
public static boolean between(int num, int min, int max) test num between min and max- Parameters:
num- numbermin- minimum numbermax- maximum number- Returns:
- true number is between the maximum and minimum
-
between
public static boolean between(long num, long min, long max) test num between min and max- Parameters:
num- numbermin- minimum numbermax- maximum number- Returns:
- true number is between the maximum and minimum
-
between
public static boolean between(float num, float min, float max) test num between min and max- Parameters:
num- numbermin- minimum numbermax- maximum number- Returns:
- true number is between the maximum and minimum
-
between
public static boolean between(double num, double min, double max) test num between min and max- Parameters:
num- numbermin- minimum numbermax- maximum number- Returns:
- true number is between the maximum and minimum
-
between
public static boolean between(char num, char min, char max) test num between min and max- Parameters:
num- numbermin- minimum numbermax- maximum number- Returns:
- true number is between the maximum and minimum
-
between
test num between min and max- Parameters:
num- numbermin- minimum numbermax- maximum number- Returns:
- true number is between the maximum and minimum
-
between
test num between min and max- Parameters:
num- numbermin- minimum numbermax- maximum number- Returns:
- true number is between the maximum and minimum
-
format
Double format- Parameters:
precisionPattern- precision pattern, e.g. 0.00number- double number- Returns:
- formatted string
-
toUnsignedIntArray
public static int[] toUnsignedIntArray(byte[] src) byte array to unsigned int array- Parameters:
src- byte array- Returns:
- unsigned int array
-
toUnsignedShortArray
public static int[] toUnsignedShortArray(short[] src) short array to unsigned int array- Parameters:
src- short array- Returns:
- unsigned int array
-
toUnsignedLongArray
public static long[] toUnsignedLongArray(int[] src) int array to unsigned long array- Parameters:
src- int array- Returns:
- unsigned long array
-
convert
Convert betweenLATIN_DIGITSandFULLWIDTH_DIGITSand support calculation result.- Parameters:
input- digit character sequenceoutType- output digit typeNumberUtil.LATIN_DIGITSorNumberUtil.FULLWIDTH_DIGITS- Returns:
- digit string
- Throws:
IllegalArgumentException- input is not digit or outType is wrong
-