类 MathUtil
java.lang.Object
com.weicoder.common.util.MathUtil
- 直接已知子类:
U.M
各种数学相关操作类
- 作者:
- WD
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static BigDecimal提供精确的加法运算。static byte[]为大数据优化的方法static List<byte[]>为大数据优化的方法static BigDecimal提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 小数点以后2位,以后的数字四舍五入。static BigDecimal提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 小数点以后2位,以后的数字四舍五入。static BigDecimal提供精确的乘法运算。static byte[]nextBytes(int len, int m, int n) static byte[]获得static byte[]随机获得一个字节数组 确保输入的m和n在byte之内 不做额外验证static List<byte[]>随机获得一个字节数组列表 验证s与e在Byte.min~Byte.max之间static double同方法Random.nextDouble()static float同方法Random.nextFloat()static intnextInt()同方法Random.nextInt()static intnextInt(int n) 同方法Random.nextInt(n)static intnextInt(int m, int n) 在m-n的范围中随机获得static longnextLong()同方法Random.nextLong()static ThreadLocalRandomrandom()返回当前线程的ThreadLocalRandomstatic Stringrandom(int len) 获取指定位数的随机数static BigDecimal提供(相对)精确的取模运算,当发生除不尽的情况时,精确到 小数点以后2位,以后的数字四舍五入。static BigDecimal提供(相对)精确的取模运算,当发生除不尽的情况时,精确到 小数点以后2位,以后的数字四舍五入。static BigDecimal提供精确的小数位四舍五入处理。static BigDecimal提供精确的小数位四舍五入处理。static BigDecimal提供精确的减法运算。static BigDecimal提供精确的减法运算static String格式化数字 把数字里的,去掉static String根据传进来的值返回长数字字符串 去处科学计数法用
-
构造器详细资料
-
MathUtil
public MathUtil()
-
-
方法详细资料
-
random
返回当前线程的ThreadLocalRandom- 返回:
- ThreadLocalRandom 独立线程的随机数
-
nextBytes
public static byte[] nextBytes(int len, int m, int n) -
nextBytes
获得- 参数:
r-len-m-n-- 返回:
-
nextBytes
随机获得一个字节数组 确保输入的m和n在byte之内 不做额外验证- 参数:
r- 随机数生成类len- 生成长度m- 开始数n- 结束数is- 是否可重复 true 可重复 false 不可重复- 返回:
- 字节数组
-
nextBytes
随机获得一个字节数组列表 验证s与e在Byte.min~Byte.max之间- 参数:
r- 随机数生成类len- 生成长度s- 开始数e- 结束数n- 生成列表长度is- 是否可重复 true 可重复 false 不可重复- 返回:
- 字节数组
-
bytes
为大数据优化的方法- 参数:
r- 随机数生成类len- 生成长度s- 开始数e- 结束数n- 生成列表长度- 返回:
- 字节数组
-
bytes
为大数据优化的方法- 参数:
r- 随机数生成类len- 生成长度m- 开始数n- 结束数- 返回:
- 字节数组
-
nextInt
public static int nextInt()同方法Random.nextInt()- 返回:
- int 返回的随机数
-
nextInt
public static int nextInt(int n) 同方法Random.nextInt(n)- 参数:
n- 在0-n的范围中- 返回:
- int 返回的随机数
-
nextInt
public static int nextInt(int m, int n) 在m-n的范围中随机获得- 参数:
m- 起始数n- 结束数- 返回:
- int 返回的随机数
-
nextDouble
public static double nextDouble()同方法Random.nextDouble()- 返回:
- double 返回的随机数
-
nextFloat
public static float nextFloat()同方法Random.nextFloat()- 返回:
- float 返回的随机数
-
nextLong
public static long nextLong()同方法Random.nextLong()- 返回:
- long 返回的随机数
-
random
获取指定位数的随机数- 参数:
len- 随机长度- 返回:
- 字符串格式的随机数
-
add
提供精确的加法运算。- 参数:
values- 相加的数字- 返回:
- 相加结果
-
subtract
提供精确的减法运算。- 参数:
v1- 被减数v2- 减数- 返回:
- 结果
-
subtract
提供精确的减法运算- 参数:
v1- 被减数v2- 减数scale- 保留精度- 返回:
- 结果
-
multiply
提供精确的乘法运算。- 参数:
values- 相乘的数字- 返回:
- 相乘结果
-
divide
提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 小数点以后2位,以后的数字四舍五入。- 参数:
v1- 被除数v2- 除数- 返回:
- 两个参数的商
-
divide
提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 小数点以后2位,以后的数字四舍五入。- 参数:
v1- 被除数v2- 除数scale- 小数点后保留几位- 返回:
- 两个参数的商
-
remainder
提供(相对)精确的取模运算,当发生除不尽的情况时,精确到 小数点以后2位,以后的数字四舍五入。- 参数:
v1- 被除数v2- 除数- 返回:
- 两个参数的商
-
remainder
提供(相对)精确的取模运算,当发生除不尽的情况时,精确到 小数点以后2位,以后的数字四舍五入。- 参数:
v1- 被除数v2- 除数scale- 小数点后保留几位- 返回:
- 两个参数的商
-
scale
提供精确的小数位四舍五入处理。- 参数:
v- 需要四舍五入的数字- 返回:
- 四舍五入后的结果
-
scale
提供精确的小数位四舍五入处理。- 参数:
v- 需要四舍五入的数字scale- 小数点后保留几位- 返回:
- 四舍五入后的结果
-
take
格式化数字 把数字里的,去掉- 参数:
v- 数字- 返回:
- 去掉,后的数字
-
toString
根据传进来的值返回长数字字符串 去处科学计数法用- 参数:
val- 要获得的值- 返回:
- 字符串
-