BigDecimal.add() Method - Java.math Package

What is Java math Big Decimal add() Method?

Description

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.

Declaration

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

Parameters

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

Exception

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

Example

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 DMCA.com Protection Status

Java.math Package Topics