声明实体
private BigDecimal AA; private BigDecimal BB;
给默认值 0 的方法
rpAccount.setAA(new BigDecimal("0")); rpAccount.setBB(new BigDecimal("0")); rpAccount.setAA(BigDecimal.ZERO); rpAccount.setBB(BigDecimal.ZERO);
数据库 如下图 假装AA 和 BB
BigDecimal 的运算
加法
rpAccounts.setBalance(rpAccount.getAA().
add
(rpAccount.getBB()));减法
rpAccounts.setBalance(rpAccount.getAA().subtract(rpAccount.getBB()));
乘法
rpAccounts.setBalance(rpAccount.getAA().multiply(rpAccount.getBB()));
除法
rpAccounts.setBalance(rpAccount.getAA().divide(rpAccount.getBB()));