Converting a BigDecimal to a primitive type

Use the methods doubleValue, floatValue, intValue or longValue.

Main.java:

import java.math.*;
  
public class Main {
   public static void main(String args[]) {
      BigDecimal bd = new BigDecimal("4.9");
 
      int bdInt       = bd.intValue();
      long bdLong     = bd.longValue();
      float bdFloat   = bd.floatValue();
      double bdDouble = bd.doubleValue();
 
      System.out.println("Conversion " + bd + " to:");
      System.out.println("tint:t" + bdInt);
      System.out.println("tlong:t" + bdLong);
      System.out.println("tfloat:t" + bdFloat);
      System.out.println("tdouble:t" + bdDouble);
   } 
}

outputs:

Conversion 4.9 to:
	int:	4
	long:	4
	float:	4.9
	double:	4.9