BigDecimal类的使用

//传入的参数必须为string类型

//金钱1

BigDecimal totalPrice = new BigDecimal("0");

//金钱2

BigDecimal newPrice= new BigDecimal("10.5");

//计算金钱总额   金钱1.add(金钱2)

totalPrice = totalPrice.add(newPrice);

//BigDecimal转换为float

totalPrice.floatValue()

详解:https://blog.csdn.net/haiyinshushe/article/details/82721234

猜你喜欢

转载自blog.csdn.net/jxyang95/article/details/93876314