double d=39.555;
BigDecimal bd = new BigDecimal(d);
System.out.println(bd.toString());
BigDecimal bd1 = bd.setScale(2, BigDecimal.
ROUND_HALF_EVEN);
System.out.println(bd1.doubleValue());
结果:
IWAV0055I
Java Bean test.TestA started with the main method
39.55499999999999971578290569595992565155029296875
39.55
以后要用BigDecimal.valueOf(double d)了。。。。。
详见:
阅读(2034) | 评论(0) | 转发(0) |