程序包 org.anyline.util
类 NumberUtil
java.lang.Object
org.anyline.util.NumberUtil
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static Stringascii2string(String content) ASCII码字符串转数字字符串static BigDecimalavg(List<BigDecimal> list, int scale, int round) 平均值static BigDecimalavga(List<BigDecimal> list, int scale, int round) static int二进制转十进制static Stringbyte2ascii(byte b) ascii码static Stringbyte2bcd(byte bit) static BigIntegerbyte2bigint(byte[] bytes) 换字节流(字节数组)型数据转大数字static Stringbyte2bin(byte b) 将byte转成二进制static intbyte2decimal(byte res) static doublebyte2double(byte[] bytes, int start) byte数组转double, 默认Double占用8个字节(64位)static Stringbyte2hex(byte b) static Stringbyte2hex(byte[] bytes) static Stringbyte2hex(byte[] bytes, int len) static Stringstatic Stringstatic Stringstatic String[]byte2hexs(byte[] bytes) static intbyte2int(byte[] bytes, int start) static intbyte2int(byte[] bytes, int start, boolean big) static intbyte2int(byte[] bytes, int start, int length) static intbyte2int(byte[] bytes, int start, int length, boolean big) 字节数组中解析整型数据static double[]byte2points(byte[] bytes) byte转double[], 可用于把数据库中的point(JDBC取出byte[])转成double[]static shortbyte2short(byte[] bytes, int start) static shortbyte2short(byte[] bytes, int start, boolean big) static shortbyte2short(byte[] bytes, int start, int length) static Stringbyte2string(byte[] bytes) static Stringbyte2string(byte[] bytes, int start) static Stringbyte2string(byte[] bytes, int start, int len) static Stringbyte2string(byte[] bytes, int start, int len, Charset charset) 从byte数组中截取start开始len位转换成String 按charset编码格式static Stringbyte2string(byte[] bytes, Charset charset) static Stringbytes2bcd(byte[] bytes) static doublecompress(double src) static Stringstatic String压缩最前位的0与小数最后的0static byte[]dec2bcd(long num) static Stringdec2bin(int number) 十进制转二进制static Stringdec2hex(int number) static String[]dec2hex(int[] numbers) static byte[]double2bytes(double d) static Byte[]double2Bytes(double d) static String数字格式化static String数据格式化static String[]16进制string拆分
0102 > ["01","02"]static bytestatic byte[]static int16进制转10进制static int截取hex中fr到to部分转成10进制static Stringhex2string(String hex) static Stringhex2string(String hex, String charset) 16进制转String
e4b8ade696876162633132335f23 > 中文abc123_#static byte[]int2bytes(int in, boolean big) 整形转换成网络传输的字节流(字节数组)型数据static byte[]大数字转换字节流(字节数组)型数据static booleanisInt(double src) static booleanisInt(float src) static byte[]long2bytes(long in, boolean big) 长整形转换成网络传输的字节流(字节数组)型数据static doublemax(double... nums) 选取最大数static floatmax(float... nums) 选取最大数static intmax(int... nums) 选取最大数static longmax(long... nums) 选取最大数static shortmax(short... nums) 选取最大数static BigDecimalmax(BigDecimal... nums) 选取最大数static doublemin(double... nums) 选取最小数static floatmin(float... nums) 选取最小数static intmin(int... nums) 选取最小数static longmin(long... nums) 选取最小数static shortmin(short... nums) 选取最小数static BigDecimalmin(BigDecimal... nums) 选取最小数static doublerandom(double fr, double to) random(double fr, double to, int qty) static floatrandom(float fr, float to) random(float fr, float to, int qty) static intrandom(int fr, int to) random(int fr, int to, int qty) static longrandom(long fr, long to) random(long fr, long to, int qty) static byte[]short2bytes(short in, boolean big) static BigDecimalstdev(List<BigDecimal> list, int scale, int round) 抽样标准差(空值不参与) 抽样标准差σ=sqrt(s^2),即标准差=方差的平方根static BigDecimalstdeva(List<BigDecimal> list, int scale, int round) static BigDecimalstdevp(List<BigDecimal> list, int scale, int round) 总体标准差(空值不参与) 总体标准差σ=sqrt(s^2),即标准差=方差的平方根static BigDecimalstdevpa(List<BigDecimal> list, int scale, int round) static Stringstring2ascii(String str) 数字字符串转ASCII码字符串static byte[]string2bytes(String src) static byte[]string2bytes(String src, String charset) static Stringstring2hex(String origin) static Stringstring2hex(String origin, String charset) String转16进制
中文abc123_# >e4b8ade696876162633132335f23static Stringupper(long num) 中文大写(简体)static BigDecimalvar(List<BigDecimal> list, int scale, int round) 抽样方差variance 抽样方差s^2=[(x1-x)^2+(x2-x)^2+......static BigDecimalvara(List<BigDecimal> list, int scale, int round) static BigDecimalvarp(List<BigDecimal> list, int scale, int round) 总体方差variance 总体方差s^2=[(x1-x)^2+(x2-x)^2+......static BigDecimalvarpa(List<BigDecimal> list, int scale, int round)
-
构造器详细资料
-
NumberUtil
public NumberUtil()
-
-
方法详细资料
-
format
数据格式化- 参数:
src- srcpattern- 名称统配符或正则- 返回:
- String
-
format
数字格式化- 参数:
src- srcpattern- 名称统配符或正则- 返回:
- String
-
upper
中文大写(简体)- 参数:
num- num- 返回:
- String
-
max
选取最大数- 参数:
nums- nums- 返回:
- BigDecimal
-
min
选取最小数- 参数:
nums- nums- 返回:
- BigDecimal
-
max
public static double max(double... nums) 选取最大数- 参数:
nums- nums- 返回:
- double
-
min
public static double min(double... nums) 选取最小数- 参数:
nums- nums- 返回:
- double
-
max
public static int max(int... nums) 选取最大数- 参数:
nums- nums- 返回:
- int
-
min
public static int min(int... nums) 选取最小数- 参数:
nums- nums- 返回:
- int
-
max
public static long max(long... nums) 选取最大数- 参数:
nums- nums- 返回:
- long
-
min
public static long min(long... nums) 选取最小数- 参数:
nums- nums- 返回:
- long
-
max
public static float max(float... nums) 选取最大数- 参数:
nums- nums- 返回:
- float
-
min
public static float min(float... nums) 选取最小数- 参数:
nums- nums- 返回:
- float
-
max
public static short max(short... nums) 选取最大数- 参数:
nums- nums- 返回:
- short
-
min
public static short min(short... nums) 选取最小数- 参数:
nums- nums- 返回:
- short
-
random
public static int random(int fr, int to) -
random
public static double random(double fr, double to) -
random
public static long random(long fr, long to) -
random
public static float random(float fr, float to) -
random
-
random
-
random
-
random
-
isInt
public static boolean isInt(double src) -
isInt
public static boolean isInt(float src) -
bin2dec
二进制转十进制- 参数:
number- number- 返回:
- int
-
dec2bin
十进制转二进制- 参数:
number- number- 返回:
- String
-
int2bytes
public static byte[] int2bytes(int in, boolean big) 整形转换成网络传输的字节流(字节数组)型数据- 参数:
in- 一个整型数据big- 是否大端- 返回:
- 4个字节的byte数组
-
short2bytes
public static byte[] short2bytes(short in, boolean big) -
long2bytes
public static byte[] long2bytes(long in, boolean big) 长整形转换成网络传输的字节流(字节数组)型数据- 参数:
in- 一个长整型数据big- 是否大端- 返回:
- 8个字节的byte数组
-
int2bytes
大数字转换字节流(字节数组)型数据- 参数:
n- 十进制- 返回:
- bytes
-
byte2bigint
换字节流(字节数组)型数据转大数字- 参数:
bytes- bytes- 返回:
- BigInteger
-
hex2dec
16进制转10进制- 参数:
hex- hex- 返回:
- int
-
hex2dec
截取hex中fr到to部分转成10进制- 参数:
hex- hex数组start- 开始位置len- 长度- 返回:
- int
-
byte2hex
-
byte2hex
-
byte2hex
-
byte2hex
-
byte2hex
-
byte2hexs
-
byte2hex
-
dec2hex
-
dec2hex
-
byte2string
从byte数组中截取start开始len位转换成String 按charset编码格式- 参数:
bytes- bytesstart- 开始len- 长度charset- 编码- 返回:
- String
-
byte2string
-
byte2string
-
byte2string
-
byte2string
-
hex2bytes
-
hex2byte
-
dec2bcd
public static byte[] dec2bcd(long num) -
byte2bin
将byte转成二进制- 参数:
b- byte- 返回:
- String
-
byte2decimal
public static int byte2decimal(byte res) -
byte2ascii
ascii码- 参数:
b- byte- 返回:
- String
-
byte2bcd
-
bytes2bcd
-
string2hex
String转16进制
中文abc123_# >e4b8ade696876162633132335f23- 参数:
origin- 原文- 返回:
- hex
-
string2hex
-
hex2string
16进制转String
e4b8ade696876162633132335f23 > 中文abc123_#- 参数:
hex- hex- 返回:
- String
-
hex2string
-
hex2array
16进制string拆分
0102 > ["01","02"]- 参数:
hex- hex- 返回:
- strings
-
string2bytes
-
string2bytes
-
string2ascii
数字字符串转ASCII码字符串- 参数:
str- 字符串- 返回:
- ASCII字符串
-
ascii2string
ASCII码字符串转数字字符串- 参数:
content- ASCII字符串- 返回:
- 字符串
-
compress
压缩最前位的0与小数最后的0- 参数:
src- srcinteger- 是否压缩成整数 1|1.0- 返回:
- String
-
compress
public static double compress(double src) -
compress
-
byte2points
public static double[] byte2points(byte[] bytes) byte转double[], 可用于把数据库中的point(JDBC取出byte[])转成double[]- 参数:
bytes- bytes- 返回:
- double[]
-
byte2double
public static double byte2double(byte[] bytes, int start) byte数组转double, 默认Double占用8个字节(64位)- 参数:
bytes- byte数组start- 开始位置- 返回:
- double
-
double2bytes
public static byte[] double2bytes(double d) -
double2Bytes
-
byte2int
public static int byte2int(byte[] bytes, int start, int length, boolean big) 字节数组中解析整型数据- 参数:
bytes- byte数组start- 开始位置length- 长度big- 是否Big Endian- 返回:
- int
-
byte2int
public static int byte2int(byte[] bytes, int start, int length) -
byte2int
public static int byte2int(byte[] bytes, int start) -
byte2int
public static int byte2int(byte[] bytes, int start, boolean big) -
byte2short
public static short byte2short(byte[] bytes, int start, int length) -
byte2short
public static short byte2short(byte[] bytes, int start) -
byte2short
public static short byte2short(byte[] bytes, int start, boolean big) -
avg
平均值- 参数:
list- 集合scale- 小数位round- 舍入模式 参考BigDecimal静态常量 ROUND_UP = 0 舍入远离零的舍入模式 在丢弃非零部分之前始终增加数字(始终对非零舍弃部分前面的数字加 1) 如:2.36 转成 2.4
ROUND_DOWN = 1 接近零的舍入模式 在丢弃某部分之前始终不增加数字(从不对舍弃部分前面的数字加1, 即截短). 如:2.36 转成 2.3
ROUND_CEILING = 2 接近正无穷大的舍入模式 如果 BigDecimal 为正, 则舍入行为与 ROUND_UP 相同 如果为负, 则舍入行为与 ROUND_DOWN 相同 相当于是 ROUND_UP 和 ROUND_DOWN 的合集
ROUND_FLOOR = 3 接近负无穷大的舍入模式 如果 BigDecimal 为正, 则舍入行为与 ROUND_DOWN 相同 如果为负, 则舍入行为与 ROUND_UP 相同 与ROUND_CEILING 正好相反
ROUND_HALF_UP = 4 四舍五入
ROUND_HALF_DOWN = 5 五舍六入
ROUND_HALF_EVEN = 6 四舍六入 五留双(银行家舍入法)
如果舍弃部分左边的数字为奇数, 则舍入行为与 ROUND_HALF_UP 相同(四舍五入)
如果为偶数, 则舍入行为与 ROUND_HALF_DOWN 相同(五舍六入)
如:1.15 转成 1.2, 因为5前面的1是奇数;1.25 转成 1.2, 因为5前面的2是偶数
ROUND_UNNECESSARY=7 断言所请求的操作具有准确的结果,因此不需要舍入。如果在产生不精确结果的操作上指定了该舍入模式,则会抛出ArithmeticException异常- 返回:
- 平均值
-
avga
-
var
抽样方差variance 抽样方差s^2=[(x1-x)^2+(x2-x)^2+......(xn-x)^2]/(n-1)(x为平均数)- 参数:
list- 集合scale- 小数位round- 舍入模式 参考BigDecimal静态常量 ROUND_UP = 0 舍入远离零的舍入模式 在丢弃非零部分之前始终增加数字(始终对非零舍弃部分前面的数字加 1) 如:2.36 转成 2.4
ROUND_DOWN = 1 接近零的舍入模式 在丢弃某部分之前始终不增加数字(从不对舍弃部分前面的数字加1, 即截短). 如:2.36 转成 2.3
ROUND_CEILING = 2 接近正无穷大的舍入模式 如果 BigDecimal 为正, 则舍入行为与 ROUND_UP 相同 如果为负, 则舍入行为与 ROUND_DOWN 相同 相当于是 ROUND_UP 和 ROUND_DOWN 的合集
ROUND_FLOOR = 3 接近负无穷大的舍入模式 如果 BigDecimal 为正, 则舍入行为与 ROUND_DOWN 相同 如果为负, 则舍入行为与 ROUND_UP 相同 与ROUND_CEILING 正好相反
ROUND_HALF_UP = 4 四舍五入
ROUND_HALF_DOWN = 5 五舍六入
ROUND_HALF_EVEN = 6 四舍六入 五留双(银行家舍入法)
如果舍弃部分左边的数字为奇数, 则舍入行为与 ROUND_HALF_UP 相同(四舍五入)
如果为偶数, 则舍入行为与 ROUND_HALF_DOWN 相同(五舍六入)
如:1.15 转成 1.2, 因为5前面的1是奇数;1.25 转成 1.2, 因为5前面的2是偶数
ROUND_UNNECESSARY=7 断言所请求的操作具有准确的结果,因此不需要舍入。如果在产生不精确结果的操作上指定了该舍入模式,则会抛出ArithmeticException异常- 返回:
- 方差
-
vara
-
varp
总体方差variance 总体方差s^2=[(x1-x)^2+(x2-x)^2+......(xn-x)^2]/n(x为平均数)- 参数:
list- 集合scale- 小数位round- 舍入模式 参考BigDecimal静态常量 ROUND_UP = 0 舍入远离零的舍入模式 在丢弃非零部分之前始终增加数字(始终对非零舍弃部分前面的数字加 1) 如:2.36 转成 2.4
ROUND_DOWN = 1 接近零的舍入模式 在丢弃某部分之前始终不增加数字(从不对舍弃部分前面的数字加1, 即截短). 如:2.36 转成 2.3
ROUND_CEILING = 2 接近正无穷大的舍入模式 如果 BigDecimal 为正, 则舍入行为与 ROUND_UP 相同 如果为负, 则舍入行为与 ROUND_DOWN 相同 相当于是 ROUND_UP 和 ROUND_DOWN 的合集
ROUND_FLOOR = 3 接近负无穷大的舍入模式 如果 BigDecimal 为正, 则舍入行为与 ROUND_DOWN 相同 如果为负, 则舍入行为与 ROUND_UP 相同 与ROUND_CEILING 正好相反
ROUND_HALF_UP = 4 四舍五入
ROUND_HALF_DOWN = 5 五舍六入
ROUND_HALF_EVEN = 6 四舍六入 五留双(银行家舍入法)
如果舍弃部分左边的数字为奇数, 则舍入行为与 ROUND_HALF_UP 相同(四舍五入)
如果为偶数, 则舍入行为与 ROUND_HALF_DOWN 相同(五舍六入)
如:1.15 转成 1.2, 因为5前面的1是奇数;1.25 转成 1.2, 因为5前面的2是偶数
ROUND_UNNECESSARY=7 断言所请求的操作具有准确的结果,因此不需要舍入。如果在产生不精确结果的操作上指定了该舍入模式,则会抛出ArithmeticException异常- 返回:
- 方差
-
varpa
-
stdev
抽样标准差(空值不参与) 抽样标准差σ=sqrt(s^2),即标准差=方差的平方根- 参数:
list- 集合scale- 小数位round- 舍入模式 参考BigDecimal静态常量 ROUND_UP = 0 舍入远离零的舍入模式 在丢弃非零部分之前始终增加数字(始终对非零舍弃部分前面的数字加 1) 如:2.36 转成 2.4
ROUND_DOWN = 1 接近零的舍入模式 在丢弃某部分之前始终不增加数字(从不对舍弃部分前面的数字加1, 即截短). 如:2.36 转成 2.3
ROUND_CEILING = 2 接近正无穷大的舍入模式 如果 BigDecimal 为正, 则舍入行为与 ROUND_UP 相同 如果为负, 则舍入行为与 ROUND_DOWN 相同 相当于是 ROUND_UP 和 ROUND_DOWN 的合集
ROUND_FLOOR = 3 接近负无穷大的舍入模式 如果 BigDecimal 为正, 则舍入行为与 ROUND_DOWN 相同 如果为负, 则舍入行为与 ROUND_UP 相同 与ROUND_CEILING 正好相反
ROUND_HALF_UP = 4 四舍五入
ROUND_HALF_DOWN = 5 五舍六入
ROUND_HALF_EVEN = 6 四舍六入 五留双(银行家舍入法)
如果舍弃部分左边的数字为奇数, 则舍入行为与 ROUND_HALF_UP 相同(四舍五入)
如果为偶数, 则舍入行为与 ROUND_HALF_DOWN 相同(五舍六入)
如:1.15 转成 1.2, 因为5前面的1是奇数;1.25 转成 1.2, 因为5前面的2是偶数
ROUND_UNNECESSARY=7 断言所请求的操作具有准确的结果,因此不需要舍入。如果在产生不精确结果的操作上指定了该舍入模式,则会抛出ArithmeticException异常- 返回:
- 标准差
-
stdeva
-
stdevp
总体标准差(空值不参与) 总体标准差σ=sqrt(s^2),即标准差=方差的平方根- 参数:
list- 集合scale- 小数位round- 舍入模式 参考BigDecimal静态常量 ROUND_UP = 0 舍入远离零的舍入模式 在丢弃非零部分之前始终增加数字(始终对非零舍弃部分前面的数字加 1) 如:2.36 转成 2.4
ROUND_DOWN = 1 接近零的舍入模式 在丢弃某部分之前始终不增加数字(从不对舍弃部分前面的数字加1, 即截短). 如:2.36 转成 2.3
ROUND_CEILING = 2 接近正无穷大的舍入模式 如果 BigDecimal 为正, 则舍入行为与 ROUND_UP 相同 如果为负, 则舍入行为与 ROUND_DOWN 相同 相当于是 ROUND_UP 和 ROUND_DOWN 的合集
ROUND_FLOOR = 3 接近负无穷大的舍入模式 如果 BigDecimal 为正, 则舍入行为与 ROUND_DOWN 相同 如果为负, 则舍入行为与 ROUND_UP 相同 与ROUND_CEILING 正好相反
ROUND_HALF_UP = 4 四舍五入
ROUND_HALF_DOWN = 5 五舍六入
ROUND_HALF_EVEN = 6 四舍六入 五留双(银行家舍入法)
如果舍弃部分左边的数字为奇数, 则舍入行为与 ROUND_HALF_UP 相同(四舍五入)
如果为偶数, 则舍入行为与 ROUND_HALF_DOWN 相同(五舍六入)
如:1.15 转成 1.2, 因为5前面的1是奇数;1.25 转成 1.2, 因为5前面的2是偶数
ROUND_UNNECESSARY=7 断言所请求的操作具有准确的结果,因此不需要舍入。如果在产生不精确结果的操作上指定了该舍入模式,则会抛出ArithmeticException异常- 返回:
- 标准差
-
stdevpa
-