mc) Method



The mc) returns a BigDecimal whose value is (+this), with rounding according to the context settings.

The effect of this method is identical to that of the round(MathContext) method.


Following is the declaration for method.

public BigDecimal plus(MathContext mc)


mc − The context to use.

Return Value

This method returns the value of BigDecimal Object, rounded as necessary. A zero result will have a scale of 0.


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


The following example shows the usage of method.

package com.tutorialspoint;

import java.math.*;

public class BigDecimalDemo {

   public static void main(String[] args) {

      // create 2 BigDecimal Objects
      BigDecimal bg1, bg2;
      bg1 = new BigDecimal("-333.3454");

      MathContext mc = new MathContext(4); // 4 precision

      // perform plus on bg1 using mc
      bg2 =;

      String str = "The Result of plus using context settings is " + bg2;

      // print the value of bg2
      System.out.println( str );

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

The Result of plus using context settings is -333.3