I want to divide a bigdecimal value with an integer.i have rounded the bigdecimal value(if it is 133.333 then rounded value is 133).given below is my code snippet.
v1 = v1.setScale(0, RoundingMode.HALF_UP);
int temp = BigDecimal.valueOf(v1.longValue()).divide(constant1);
value of constant is 12. It is showing an error message that
The method divide(BigDecimal) in the type BigDecimal is not applicable for the arguments (int)
Can anyone help me to do the division?
Change
.divide(constant1);
to
.divide(new BigDecimal(constant1));
Btw, why don't you just do something like
int temp = (int) (Math.round(v1.doubleValue()) / constant1);
??
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With