Java Data Type Tutorial - Java BigDecimal(BigInteger val, MathContext mc) Constructor








Syntax

BigDecimal(BigInteger val, MathContext mc) constructor from BigDecimal has the following syntax.

public BigDecimal(BigInteger val,   MathContext mc)

Example

In the following code shows how to use BigDecimal.BigDecimal(BigInteger val, MathContext mc) constructor.

import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
//  ww  w.  jav a 2  s. c  o  m
public class Main {

  public static void main(String[] args) {
    MathContext mc = new MathContext(3);
    BigDecimal bg1 = new BigDecimal(new BigInteger("40"),mc);

  }
}