BigDecimal round

Previous
Next

In this tutorial we will see about BigDecimal‘s round method. BigDecimal’s round method is used to round the BigDecimal based on MathContext setting.

Syntax

Return type

returns BigDecimal rounded with MathContext setting

BigDecimal round example

Let’s understand BigDecimal method with the help of example

Above program will generate below output.

80.23776 is rounded to: 80.24
80.23776 is rounded to: 80.23 with help of RoundingMode

BigDecimal setScale method

You can use setScale method also to round BigDecimal.Let’s understand with the help of example.

When you run above program, you will get below output.

BigDecimal Rounding to 3 decimal places: 12.457

That’s all about BigDecimal round 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