,2,BigDecimal.ROUND_HALF_EVEN )
BigDecimal定义了舍入模式,仅在进行除法和四舍五入时使用。 以下简单说明。 有关详细信息,请参阅J2se API文档
静态int
ROUND_CEILING
roundingmodetoroundtowardspositiveinfinity。
向正的无限方向舍入
静态int
ROUND_DOWN
轮调模式到轮调towards zero。
向零方向舍入
静态int
ROUND_FLOOR
roundingmodetoroundtowardsnegativeinfinity。
向负的无限方向舍入
静态int
ROUND_HALF_DOWN
roundingmodetoroundtowards ' nearest neighbor ' unlessbothneighborsareequidistant,in which case round down。
除非两侧距离相等,否则四舍五入到最接近(距离)的一侧。 如果是,就四舍五入。 例如,1.55会保留小数1.5的结果
静态int
ROUND_HALF_EVEN
roundingmodetoroundtowardsthe ' nearest neighbor ' unlessbothneighborsareequidistant,in which case,round towards the even neighbobobot
对于向最接近(距离)的一侧的舍入,如果是这样,则使用ROUND_HALF_UP作为保留位数,如果是偶数,则使用ROUND_HALF_DOWN作为保留位数
静态int
ROUND_HALF_UP
roundingmodetoroundtowards ' nearest neighbor ' unlessbothneighborsareequidistant,in which case round up。
除非两侧距离相等,否则向上舍入到最接近(距离)的一侧。 那样的话,就结束。 1.55保留小数1.6的结果
静态int
ROUND_UNNECESSARY
roundingmodetoassertthattherequestedoperationhasanexactresult,hence no rounding is necessary。
计算结果准确,不需要舍入模式
静态int
ROUND_UP
roundingmodetoroundawayfromzero。
向远离0的方向舍入