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








Syntax

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

public BigDecimal(long val,   MathContext mc)

Example

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

/*from  w  ww .ja v a  2s.  co  m*/
import java.math.BigDecimal;
import java.math.MathContext;

public class Main {

  public static void main(String[] args) {
    MathContext mc = new MathContext(3);
    BigDecimal bg1 = new BigDecimal(123456789L,mc);
    System.out.println(bg1);

  }
}

The code above generates the following result.