Package tech.mgl.core.utils
Class MGL_DecimalUtils
java.lang.Object
tech.mgl.core.utils.MGL_DecimalUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BigDecimal提供精确的加法运算。static BigDecimaladd(BigDecimal v1, Object v2) static doublediv(double v1, double v2) 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 小数点以后10位,以后的数字四舍五入。static doublediv(double v1, double v2, int scale) 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 定精度,以后的数字四舍五入。static BigDecimalstatic BigDecimal提供精确的乘法运算。static BigDecimalmultiply(BigDecimal v1, String v2) static doubleround(double v, int scale) 提供精确的小数位四舍五入处理。static BigDecimal提供精确的减法运算。static BigDecimalsub(BigDecimal v1, Object v2)
-
Constructor Details
-
MGL_DecimalUtils
public MGL_DecimalUtils()
-
-
Method Details
-
add
提供精确的加法运算。- Parameters:
v1- 被加数v2- 加数- Returns:
- 两个参数的和
-
add
- Parameters:
v1-v2-- Returns:
-
sub
提供精确的减法运算。- Parameters:
v1- 被减数v2- 减数- Returns:
- 两个参数的差
-
sub
- Parameters:
v1-v2-- Returns:
-
multiply
提供精确的乘法运算。- Parameters:
v1- 被乘数v2- 乘数- Returns:
- 两个参数的积
-
multiply
- Parameters:
v1-v2-- Returns:
-
div
public static double div(double v1, double v2) 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 小数点以后10位,以后的数字四舍五入。- Parameters:
v1- 被除数v2- 除数- Returns:
- 两个参数的商
-
div
public static double div(double v1, double v2, int scale) 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 定精度,以后的数字四舍五入。- Parameters:
v1- 被除数v2- 除数scale- 表示表示需要精确到小数点以后几位。- Returns:
- 两个参数的商
-
div
- Parameters:
v1-v2-scale-- Returns:
-
round
public static double round(double v, int scale) 提供精确的小数位四舍五入处理。- Parameters:
v- 需要四舍五入的数字scale- 小数点后保留几位- Returns:
- 四舍五入后的结果
-