JAVA BigDecimal
作者:互联网
加
减
乘
除
BigDecimal qtySettleTotal = qtySettleTotal.setScale(2,BigDecimal.ROUND_HALF_UP);
BigDecimal qtyYF = this.txtqtyYF.getBigDecimalValue().setScale(2,BigDecimal.ROUND_HALF_UP);
BigDecimal multiple = qtySettleTotal.divide(qtyYF,2,BigDecimal.ROUND_HALF_UP);
取余
BigDecimal qtySettleTotal = qtySettleTotal.setScale(2,BigDecimal.ROUND_HALF_UP);
BigDecimal qtyYF = this.txtqtyYF.getBigDecimalValue().setScale(2,BigDecimal.ROUND_HALF_UP);
BigDecimal multiple = qtySettleTotal.divide(qtyYF,2,BigDecimal.ROUND_HALF_UP);
BigDecimal[] results = qtySettleTotal.divideAndRemainder(qtyYF);
// results[0]整数部分,results[1]应该是余数部分但是不知道我的为啥不对,所以我直接算出除数 - results[0] 从而得出是否能够整除
BigDecimal Remainder = multiple.subtract(results[0]);
if(new BigDecimal("0").compareTo(Remainder) == 0){
// 整除
}
标签:JAVA,BigDecimal,qtySettleTotal,UP,results,HALF,ROUND 来源: https://www.cnblogs.com/wmq1310/p/Bigdecimal.html