Add two BigDecimal together
import java.math.BigDecimal;
public class Main {
public static void main(String[] args) {
BigDecimal decimalA = new BigDecimal("123456789012345");
BigDecimal decimalB = new BigDecimal("10");
decimalA = decimalA.add(decimalB);
System.out.println("decimalA = " + decimalA);
}
}
Output:
decimalA = 123456789012355
Home
Java Book
Runnable examples
Java Book
Runnable examples
BigDecimal:
- Create BigDecimal from long and String
- Add two BigDecimal together
- Divide BigDecimal from another BigDecimal
- Multiply one BigDecimal to another BigDecimal
- Negate a BigDecimal
- Subtract BigDecimal from another BigDecimal
- Truncate BigDecimal value
- Power a BigDecimal
- Round a BigDecimal(double) up
- Round a BigDecimal(double) down
- Format BigDecimal to Currency and Percentage