BigDecimal divide

Previous
Next

In this tutorial we will see about BigDecimal‘s divide method. BigDecimal’s divide method is used to divide one BigDecimal by another.You can specify scale and rounding mode to get the output according to your need. There are 6 overloaded version of divide method.

Syntax

Return type

returns BigDecimal

BigDecimal round example

Let’s understand BigDecimal’s divide method with the help of example

Above program will generate below output.

18/5 = 3.6
17/3 = 5.667

Please be careful when you use divide method.Please check if divisor is zero or not before dividing otherwise you will get divide by zero exception.

That’s all about BigDecimal’s divide method.

Previous
Next

Join Our News Letter – Stay Updated

Subscribe to Awesome Java Content.




Add Comment

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.
You can like our facebook page Java2blog