BigDecimal.add() Method - Java.math Package

What is Java math Big Decimal add() Method?


The java.math.BigDecimal.add(BigDecimal augend, MathContext mc) returns a BigDecimal whose price is (this + augend), with rounding according to the MathContext settings. If either number is zero and the precision placing is nonzero then the opposite number, rounded if essential, is used as the result.


Following is the declaration for java.math.BigDecimal.add() technique.


augend − Value to be added to this BigDecimal.

mc − The context to use.

Return Value

This method returns a BigDecimal object whose value is this + augend, rounded as necessary


ArithmeticException − If the result is inexact but the rounding mode is UNNECESSARY.


The following example shows the usage of math.BigDecimal.add() method.

Let us compile and run the above program, this will produce the following result −

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

Java.math Package Topics