In the actual development process BigDecimal is a frequently used type of data, and it is int, between Long interchangeable.
Conversion relations following code shows:
A, int data type is converted into BigDecimal
//int 转换成 bigDecimal类型 public static BigDecimal intToBigDecimal(int i){ BigDecimal b = new BigDecimal(i); return b;
Two, Lont converted into the data type BigDecimal
// Long cast into BigDecimal public static longToBigDecimal the BigDecimal (Long L) { the BigDecimal the BigDecimal new new B = (L); return B;
Three, BigDecimal Long data type is converted into
//bigDecimal 转换成 Long类型 public static Long bigDecimalToLong(BigDecimal b){ BigDecimal c = new BigDecimal(b); Long l = c.longValue(); return l;
Four, BigDecimal converted to data type int
//bigDecimal 转换成 int类型 public static void bigDecimalToInt(BigDecimal b){ BigDecimal c = new BigDecimal(b); int i = c.intValue();