类 CalculationUtil
java.lang.Object
cn.vorbote.core.utils.CalculationUtil
Calculation Util can help you with high precision math calculation.
This util is made by Github User @sunzsh, and the source code location is Github Gist
Note: Some changes was made by Github user @vorbote because of the deprecation of method
BigDecimal.setScale(int, int), all call to this method was moved to
BigDecimal.setScale(int, RoundingMode).
- 作者:
- sunzsh, vorbote
-
方法概要
修饰符和类型方法说明Add a number to the original figure.Calc: the original value add the other number.Calc: the original value divide the other number.Calc: the original value divide the other number.divideWithScale(Number other, Integer scale) Calc: the original value divide the other number.divideWithScale(Number other, Integer scale, Integer beforeOperateScale) Calc: the original value divide the other number.Get the value of the calculation inDouble.getDouble(int scale) Get the value of the calculation inDouble.Get the value of the calculation inInteger.getLong()Get the value of the calculation inLong.getValue()Get the value of the calculation inBigDecimal.getValue(int scale) Get the value of the calculation inBigDecimal.Calc: the original value multiply the other number.Calc: the original value multiply the other number.static CalculationUtilThe initial value of start.Calc: the original value subtract the other number.Calc: the original value subtract the other number.
-
方法详细资料
-
startOf
The initial value of start.- 参数:
value- The initial value.- 返回:
- The
CalculationUtilinstance.
-
add
Add a number to the original figure.- 参数:
other- The other number.- 返回:
- The calculated instance.
-
add
Calc: the original value add the other number.- 参数:
other- The other number to be added.beforeOperateScale- RoundothertobeforeOperateScaledecimal places before doing adding.- 返回:
- The calculated instance.
-
subtract
Calc: the original value subtract the other number.- 参数:
other- The value to be subtracted.- 返回:
- The calculated instance.
-
subtract
Calc: the original value subtract the other number.- 参数:
other- The value to be subtracted.beforeOperateScale- RoundothertobeforeOperateScaledecimal places before doing subtracting.- 返回:
- The calculated instance.
-
multiply
Calc: the original value multiply the other number.- 参数:
other- The value to be multiplied.- 返回:
- The calculated instance.
-
multiply
Calc: the original value multiply the other number.- 参数:
other- The value to be multiplied.beforeOperateScale- RoundothertobeforeOperateScaledecimal places before doing multiplication.- 返回:
- The calculated instance.
-
divide
Calc: the original value divide the other number.- 参数:
other- The value to be divided.- 返回:
- The calculated instance.
-
divide
Calc: the original value divide the other number.- 参数:
other- The value to be multiplied.beforeOperateScale- RoundothertobeforeOperateScaledecimal places before doing multiplication.- 返回:
- The calculated instance.
-
divideWithScale
Calc: the original value divide the other number.- 参数:
other- The value to be multiplied.scale- The result is rounded toscaledecimal places.- 返回:
- The calculated instance.
-
divideWithScale
Calc: the original value divide the other number.- 参数:
other- The value to be multiplied.scale- The result is rounded toscaledecimal places.beforeOperateScale- RoundothertobeforeOperateScaledecimal places before doing dividing.- 返回:
- The calculated instance.
-
getValue
Get the value of the calculation inBigDecimal.- 返回:
- The result of the figure.
-
getValue
Get the value of the calculation inBigDecimal.- 参数:
scale- The result is rounded toscaledecimal places.- 返回:
- The result of the figure.
-
getDouble
Get the value of the calculation inDouble.- 返回:
- The result of the figure.
-
getDouble
Get the value of the calculation inDouble.- 参数:
scale- The result is rounded toscaledecimal places.- 返回:
- The result of the figure.
-
getLong
Get the value of the calculation inLong.- 返回:
- The result of the figure.
-
getInteger
Get the value of the calculation inInteger.- 返回:
- The result of the figure.
-