public final class Numbers extends Object
Number utility 十进制:10 二进制:0B10 八进制:010 十六进制:0X10 小数点:1e-9
| 限定符和类型 | 字段和说明 |
|---|---|
static byte |
ZERO_BYTE |
static int |
ZERO_INT |
static Integer |
ZERO_INTEGER |
| 构造器和说明 |
|---|
Numbers() |
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
bound(Integer value,
int min,
int max)
区间取值
|
static boolean |
equals(Long a,
Integer b)
Returns the Long object is equals the Integer object
|
static String |
format(double value,
int scale)
Returns a string value of double
|
static String |
format(Object obj)
数字格式化
|
static String |
format(Object obj,
String format)
数字格式化
|
static boolean |
isNullOrZero(Integer value) |
static boolean |
isNullOrZero(Long value) |
static double |
lower(double value,
int pow)
向下转单位
|
static double |
lower(double value,
int pow,
int scale) |
static int |
nullZero(Integer value) |
static long |
nullZero(Long value) |
static List<Tuple2<Integer,Integer>> |
partition(int number,
int size)
Partition the number
partition( 0, 2) -> [(0, 0)]
partition( 2, 3) -> [(0, 0), (1, 1)]
partition( 3, 1) -> [(0, 2)]
partition( 9, 3) -> [(0, 2), (3, 5), (6, 8)]
partition(10, 3) -> [(0, 3), (4, 6), (7, 9)]
partition(11, 3) -> [(0, 3), (4, 7), (8, 10)]
partition(12, 3) -> [(0, 3), (4, 7), (8, 11)]
|
static String |
percent(double numerator,
double denominator,
int scale)
百分比
|
static String |
percent(double value,
int scale)
百分比
|
static int[] |
prorate(int[] array,
int value)
Prorate the value for array
prorate(new int[]{249, 249, 249, 3}, 748) = [249, 249, 248, 2]
prorate(new int[]{43, 1, 47} , 61 ) = [29, 1, 31]
|
static double |
scale(Object value,
int scale)
数字精度
|
static int[] |
slice(int quantity,
int segment)
分片
slice(0 , 2) -> [0, 0]
slice(2 , 3) -> [1, 1, 0]
slice(3 , 1) -> [3]
slice(9 , 3) -> [3, 3, 3]
slice(10, 3) -> [4, 3, 3]
slice(11, 3) -> [4, 4, 3]
slice(12, 3) -> [4, 4, 4]
|
static double |
sum(Double a,
Double b) |
static int |
sum(Integer a,
Integer b) |
static long |
sum(Long a,
Long b) |
static boolean |
toBoolean(Object obj) |
static boolean |
toBoolean(Object obj,
boolean defaultVal) |
static byte |
toByte(Object obj) |
static byte |
toByte(Object obj,
byte defaultVal) |
static char |
toChar(Object obj) |
static char |
toChar(Object obj,
char defaultVal) |
static double |
toDouble(Object obj) |
static double |
toDouble(Object obj,
double defaultVal) |
static float |
toFloat(Object obj) |
static float |
toFloat(Object obj,
float defaultVal) |
static String |
toHex(BigInteger value)
To upper hex string and remove prefix 0
|
static int |
toInt(Object obj) |
static int |
toInt(Object obj,
int defaultVal) |
static long |
toLong(Object obj) |
static long |
toLong(Object obj,
long defaultVal) |
static short |
toShort(Object obj) |
static short |
toShort(Object obj,
short defaultVal) |
static Boolean |
toWrapBoolean(Object obj) |
static Byte |
toWrapByte(Object obj) |
static Character |
toWrapChar(Object obj) |
static Double |
toWrapDouble(Object obj) |
static Float |
toWrapFloat(Object obj) |
static Integer |
toWrapInt(Object obj) |
static Long |
toWrapLong(Object obj) |
static Short |
toWrapShort(Object obj) |
static double |
upper(double value,
int pow)
向上转单位
|
static double |
upper(double value,
int pow,
int scale) |
static Integer |
zeroNull(int value) |
static Long |
zeroNull(long value) |
public static final int ZERO_INT
public static final Integer ZERO_INTEGER
public static final byte ZERO_BYTE
public static char toChar(Object obj)
public static char toChar(Object obj, char defaultVal)
public static boolean toBoolean(Object obj)
public static boolean toBoolean(Object obj, boolean defaultVal)
public static byte toByte(Object obj)
public static byte toByte(Object obj, byte defaultVal)
public static short toShort(Object obj)
public static short toShort(Object obj, short defaultVal)
public static int toInt(Object obj)
public static int toInt(Object obj, int defaultVal)
public static long toLong(Object obj)
public static long toLong(Object obj, long defaultVal)
public static float toFloat(Object obj)
public static float toFloat(Object obj, float defaultVal)
public static double toDouble(Object obj)
public static double toDouble(Object obj, double defaultVal)
public static double scale(Object value, int scale)
value - the number valuescale - the scalepublic static double lower(double value,
int pow)
value - the number valuepow - the powpublic static double lower(double value,
int pow,
int scale)
public static double upper(double value,
int pow)
value - pow - public static double upper(double value,
int pow,
int scale)
public static long nullZero(Long value)
public static Long zeroNull(long value)
public static int nullZero(Integer value)
public static Integer zeroNull(int value)
public static boolean isNullOrZero(Long value)
public static boolean isNullOrZero(Integer value)
public static String percent(double numerator, double denominator, int scale)
numerator - denominator - scale - public static String percent(double value, int scale)
value - scale - public static String format(double value, int scale)
value - the double valuescale - the scalepublic static int bound(Integer value, int min, int max)
value - min - max - public static int[] slice(int quantity,
int segment)
slice(0 , 2) -> [0, 0] slice(2 , 3) -> [1, 1, 0] slice(3 , 1) -> [3] slice(9 , 3) -> [3, 3, 3] slice(10, 3) -> [4, 3, 3] slice(11, 3) -> [4, 4, 3] slice(12, 3) -> [4, 4, 4]
quantity - the quantitysegment - the segmentpublic static List<Tuple2<Integer,Integer>> partition(int number, int size)
partition( 0, 2) -> [(0, 0)] partition( 2, 3) -> [(0, 0), (1, 1)] partition( 3, 1) -> [(0, 2)] partition( 9, 3) -> [(0, 2), (3, 5), (6, 8)] partition(10, 3) -> [(0, 3), (4, 6), (7, 9)] partition(11, 3) -> [(0, 3), (4, 7), (8, 10)] partition(12, 3) -> [(0, 3), (4, 7), (8, 11)]
number - the numbersize - the sizepublic static int[] prorate(int[] array,
int value)
prorate(new int[]{249, 249, 249, 3}, 748) = [249, 249, 248, 2]
prorate(new int[]{43, 1, 47} , 61 ) = [29, 1, 31]
array - the arrayvalue - the valuepublic static boolean equals(Long a, Integer b)
a - the Long ab - the Integer btruepublic static String toHex(BigInteger value)
value - the BigInteger valueCopyright © 2024. All rights reserved.