public class NumberUtil extends Object
| 构造器和说明 |
|---|
NumberUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
ascii2string(String content)
ASCII码字符串转数字字符串
|
static BigDecimal |
avg(List<BigDecimal> list,
int scale,
int round)
平均值
|
static BigDecimal |
avga(List<BigDecimal> list,
int scale,
int round) |
static int |
bin2dec(String number)
二进制转十进制
|
static String |
byte2ascii(byte b)
ascii码
|
static String |
byte2bcd(byte bit) |
static BigInteger |
byte2bigint(byte[] bytes)
换字节流(字节数组)型数据转大数字
|
static String |
byte2bin(byte b)
将byte转成二进制
|
static int |
byte2decimal(byte res) |
static double |
byte2double(byte[] bytes,
int start)
byte数组转double, 默认Double占用8个字节(64位)
|
static String |
byte2hex(byte b) |
static String |
byte2hex(byte[] bytes) |
static String |
byte2hex(byte[] bytes,
int len) |
static String |
byte2hex(byte[] bytes,
int start,
int len,
String split) |
static String |
byte2hex(byte[] bytes,
int len,
String split) |
static String |
byte2hex(byte[] bytes,
String split) |
static String[] |
byte2hexs(byte[] bytes) |
static int |
byte2int(byte[] bytes,
int start) |
static int |
byte2int(byte[] bytes,
int start,
boolean big) |
static int |
byte2int(byte[] bytes,
int start,
int length) |
static int |
byte2int(byte[] bytes,
int start,
int length,
boolean big)
字节数组中解析整型数据
|
static double[] |
byte2points(byte[] bytes)
byte转double[], 可用于把数据库中的point(JDBC取出byte[])转成double[]
|
static short |
byte2short(byte[] bytes,
int start) |
static short |
byte2short(byte[] bytes,
int start,
boolean big) |
static short |
byte2short(byte[] bytes,
int start,
int length) |
static String |
byte2string(byte[] bytes) |
static String |
byte2string(byte[] bytes,
Charset charset) |
static String |
byte2string(byte[] bytes,
int start) |
static String |
byte2string(byte[] bytes,
int start,
int len) |
static String |
byte2string(byte[] bytes,
int start,
int len,
Charset charset)
从byte数组中截取start开始len位转换成String 按charset编码格式
|
static String |
bytes2bcd(byte[] bytes) |
static double |
compress(double src) |
static String |
compress(String src) |
static String |
compress(String src,
boolean integer)
压缩最前位的0与小数最后的0
|
static byte[] |
dec2bcd(long num) |
static String |
dec2bin(int number)
十进制转二进制
|
static String |
dec2hex(int number) |
static String[] |
dec2hex(int[] numbers) |
static byte[] |
double2bytes(double d) |
static Byte[] |
double2Bytes(double d) |
static String |
format(Number src,
String pattern)
数字格式化
|
static String |
format(String src,
String pattern)
数据格式化
|
static String[] |
hex2array(String hex)
16进制string拆分
0102 > ["01","02"] |
static byte |
hex2byte(String hex) |
static byte[] |
hex2bytes(String hex) |
static int |
hex2dec(String hex)
16进制转10进制
|
static int |
hex2dec(String[] hex,
int start,
int len)
截取hex中fr到to部分转成10进制
|
static String |
hex2string(String hex) |
static String |
hex2string(String hex,
String charset)
16进制转String
e4b8ade696876162633132335f23 > 中文abc123_# |
static byte[] |
int2bytes(BigInteger n)
大数字转换字节流(字节数组)型数据
|
static byte[] |
int2bytes(int in,
boolean big)
整形转换成网络传输的字节流(字节数组)型数据
|
static boolean |
isInt(double src) |
static boolean |
isInt(float src) |
static byte[] |
long2bytes(long in,
boolean big)
长整形转换成网络传输的字节流(字节数组)型数据
|
static BigDecimal |
max(BigDecimal... nums)
选取最大数
|
static BigDecimal |
max(Collection list)
最大值,不能转换成数字的忽略
|
static double |
max(double... nums)
选取最大数
|
static float |
max(float... nums)
选取最大数
|
static int |
max(int... nums)
选取最大数
|
static long |
max(long... nums)
选取最大数
|
static short |
max(short... nums)
选取最大数
|
static BigDecimal |
min(BigDecimal... nums)
选取最小数
|
static BigDecimal |
min(Collection list)
最小值,不能转换成数字的忽略
|
static double |
min(double... nums)
选取最小数
|
static float |
min(float... nums)
选取最小数
|
static int |
min(int... nums)
选取最小数
|
static long |
min(long... nums)
选取最小数
|
static short |
min(short... nums)
选取最小数
|
static double |
random(double fr,
double to) |
static List<Double> |
random(double fr,
double to,
int qty) |
static float |
random(float fr,
float to) |
static List<Float> |
random(float fr,
float to,
int qty) |
static int |
random(int fr,
int to) |
static List<Integer> |
random(int fr,
int to,
int qty) |
static long |
random(long fr,
long to) |
static List<Long> |
random(long fr,
long to,
int qty) |
static byte[] |
short2bytes(short in,
boolean big) |
static BigDecimal |
stdev(List<BigDecimal> list,
int scale,
int round)
抽样标准差(空值不参与)
抽样标准差σ=sqrt(s^2),即标准差=方差的平方根
|
static BigDecimal |
stdeva(List<BigDecimal> list,
int scale,
int round) |
static BigDecimal |
stdevp(List<BigDecimal> list,
int scale,
int round)
总体标准差(空值不参与)
总体标准差σ=sqrt(s^2),即标准差=方差的平方根
|
static BigDecimal |
stdevpa(List<BigDecimal> list,
int scale,
int round) |
static String |
string2ascii(String str)
数字字符串转ASCII码字符串
|
static byte[] |
string2bytes(String src) |
static byte[] |
string2bytes(String src,
String charset) |
static String |
string2hex(String origin) |
static String |
string2hex(String origin,
String charset)
String转16进制
中文abc123_# >e4b8ade696876162633132335f23 |
static String |
upper(long num)
中文大写(简体)
|
static BigDecimal |
var(List<BigDecimal> list,
int scale,
int round)
抽样方差variance
抽样方差s^2=[(x1-x)^2+(x2-x)^2+......
|
static BigDecimal |
vara(List<BigDecimal> list,
int scale,
int round) |
static BigDecimal |
varp(List<BigDecimal> list,
int scale,
int round)
总体方差variance
总体方差s^2=[(x1-x)^2+(x2-x)^2+......
|
static BigDecimal |
varpa(List<BigDecimal> list,
int scale,
int round) |
public static String format(String src, String pattern)
src - srcpattern - 名称统配符或正则public static String format(Number src, String pattern)
src - srcpattern - 名称统配符或正则public static String upper(long num)
num - numpublic static BigDecimal max(BigDecimal... nums)
nums - numspublic static BigDecimal min(BigDecimal... nums)
nums - numspublic static BigDecimal min(Collection list)
list - listpublic static BigDecimal max(Collection list)
list - listpublic static double max(double... nums)
nums - numspublic static double min(double... nums)
nums - numspublic static int max(int... nums)
nums - numspublic static int min(int... nums)
nums - numspublic static long max(long... nums)
nums - numspublic static long min(long... nums)
nums - numspublic static float max(float... nums)
nums - numspublic static float min(float... nums)
nums - numspublic static short max(short... nums)
nums - numspublic static short min(short... nums)
nums - numspublic static int random(int fr,
int to)
public static double random(double fr,
double to)
public static long random(long fr,
long to)
public static float random(float fr,
float to)
public static boolean isInt(double src)
public static boolean isInt(float src)
public static int bin2dec(String number)
number - numberpublic static String dec2bin(int number)
number - numberpublic static byte[] int2bytes(int in,
boolean big)
in - 一个整型数据big - 是否大端public static byte[] short2bytes(short in,
boolean big)
public static byte[] long2bytes(long in,
boolean big)
in - 一个长整型数据big - 是否大端public static byte[] int2bytes(BigInteger n)
n - 十进制public static BigInteger byte2bigint(byte[] bytes)
bytes - bytespublic static int hex2dec(String hex)
hex - hexpublic static int hex2dec(String[] hex, int start, int len)
hex - hex数组start - 开始位置len - 长度public static String byte2hex(byte[] bytes, int len)
public static String byte2hex(byte[] bytes)
public static String[] byte2hexs(byte[] bytes)
public static String byte2hex(byte b)
public static String dec2hex(int number)
public static String[] dec2hex(int[] numbers)
public static String byte2string(byte[] bytes, int start, int len, Charset charset)
bytes - bytesstart - 开始len - 长度charset - 编码public static String byte2string(byte[] bytes, int start, int len)
public static String byte2string(byte[] bytes)
public static String byte2string(byte[] bytes, int start)
public static byte[] hex2bytes(String hex)
public static byte hex2byte(String hex)
public static byte[] dec2bcd(long num)
public static String byte2bin(byte b)
b - bytepublic static int byte2decimal(byte res)
public static String byte2ascii(byte b)
b - bytepublic static String byte2bcd(byte bit)
public static String bytes2bcd(byte[] bytes)
public static String string2hex(String origin, String charset)
origin - 原文public static String hex2string(String hex, String charset)
hex - hexpublic static String[] hex2array(String hex)
hex - hexpublic static byte[] string2bytes(String src)
public static String string2ascii(String str)
str - 字符串public static String ascii2string(String content)
content - ASCII字符串public static String compress(String src, boolean integer)
src - srcinteger - 是否压缩成整数 1|1.0public static double compress(double src)
public static double[] byte2points(byte[] bytes)
bytes - bytespublic static double byte2double(byte[] bytes,
int start)
bytes - byte数组start - 开始位置public static byte[] double2bytes(double d)
public static Byte[] double2Bytes(double d)
public static int byte2int(byte[] bytes,
int start,
int length,
boolean big)
bytes - byte数组start - 开始位置length - 长度big - 是否Big Endianpublic static int byte2int(byte[] bytes,
int start,
int length)
public static int byte2int(byte[] bytes,
int start)
public static int byte2int(byte[] bytes,
int start,
boolean big)
public static short byte2short(byte[] bytes,
int start,
int length)
public static short byte2short(byte[] bytes,
int start)
public static short byte2short(byte[] bytes,
int start,
boolean big)
public static BigDecimal avg(List<BigDecimal> list, int scale, int round)
list - 集合scale - 小数位round - 舍入模式 参考BigDecimal静态常量
ROUND_UP = 0 舍入远离零的舍入模式 在丢弃非零部分之前始终增加数字(始终对非零舍弃部分前面的数字加 1) 如:2.36 转成 2.4public static BigDecimal avga(List<BigDecimal> list, int scale, int round)
public static BigDecimal var(List<BigDecimal> list, int scale, int round)
list - 集合scale - 小数位round - 舍入模式 参考BigDecimal静态常量
ROUND_UP = 0 舍入远离零的舍入模式 在丢弃非零部分之前始终增加数字(始终对非零舍弃部分前面的数字加 1) 如:2.36 转成 2.4public static BigDecimal vara(List<BigDecimal> list, int scale, int round)
public static BigDecimal varp(List<BigDecimal> list, int scale, int round)
list - 集合scale - 小数位round - 舍入模式 参考BigDecimal静态常量
ROUND_UP = 0 舍入远离零的舍入模式 在丢弃非零部分之前始终增加数字(始终对非零舍弃部分前面的数字加 1) 如:2.36 转成 2.4public static BigDecimal varpa(List<BigDecimal> list, int scale, int round)
public static BigDecimal stdev(List<BigDecimal> list, int scale, int round)
list - 集合scale - 小数位round - 舍入模式 参考BigDecimal静态常量
ROUND_UP = 0 舍入远离零的舍入模式 在丢弃非零部分之前始终增加数字(始终对非零舍弃部分前面的数字加 1) 如:2.36 转成 2.4public static BigDecimal stdeva(List<BigDecimal> list, int scale, int round)
public static BigDecimal stdevp(List<BigDecimal> list, int scale, int round)
list - 集合scale - 小数位round - 舍入模式 参考BigDecimal静态常量
ROUND_UP = 0 舍入远离零的舍入模式 在丢弃非零部分之前始终增加数字(始终对非零舍弃部分前面的数字加 1) 如:2.36 转成 2.4public static BigDecimal stdevpa(List<BigDecimal> list, int scale, int round)
Copyright © 2025. All rights reserved.