/**
*不可变的、任意精度的有符号十进制数。
*除法时如果除不尽会报异常
*/
BigDecimal d = new BigDecimal(3);
//BigDecimal.ONE.divide(d) ;
BigDecimal.ONE.divide(d,2,BigDecimal.model) ;
//保留小数
BigDecimal bd = new BigDecimal(3.1415926);
System.out.println(bd);
System.out.println(bd.setScale(5,BigDecimal.ROUND_HALF_EVEN));
System.out.println(bd.setScale(3,BigDecimal.ROUND_HALF_UP));
System.out.println(bd.setScale(3,BigDecimal.ROUND_HALF_UP));
System.out.println(bd.setScale(2,BigDecimal.ROUND_HALF_UP));
System.out.println(bd.setScale(1,BigDecimal.ROUND_HALF_UP));
System.out.println(bd.setScale(0,BigDecimal.ROUND_HALF_UP));