java 用BigDecimal计算商品单价乘以折扣价

商品单价价格是单位是(分),用户下单金额=商品单价*折扣  代码如下

Integer discount = 5 折扣五折

Integer orderPrice = 1000  单位分

BigDecimal bigDecimal = new BigDecimal(discount * 0.1 + "");
BigDecimal multiply = bigDecimal.multiply(new BigDecimal(orderPrice));
orderPrice = multiply.setScale(0, BigDecimal.ROUND_HALF_UP).intValue();

原文地址:https://www.cnblogs.com/SHMILYHP/p/11276869.html