读《Effective Java》Item 60 : Avoid float and double if exact answers are required的时候,结尾写BigDecimal的优点时写道
Using BigDecimal has the added advantage that it gives you full control over rounding, letting you select from eight rounding modes whenever an operation that entails rounding is performed.
这里的eight rounding modes(八种舍入模式)第一次看到,查找资料记录一下
参考资料:http://www.blogjava.net/wangzc2001/archive/2010/12/17/340988.html
ROUND_UP
舍入远离零的舍入模式。
在丢弃非零部分之前始终增加数字(始终对非零舍弃部分前面的数字加1)。
即,有小数位的情况下,去掉小数位,正数+1,负数-1