目前我使用的DecimalFormat类四舍五入双重价值四舍五入双值在Java中
double d = 42.405;
DecimalFormat f = new DecimalFormat("##.00");
System.out.println(f.format(d));
output: 42.41;
我使用硒做浏览器的应用程序测试,所以基于我需要四舍五入值的浏览器。
例如:
IE四舍五入42.405到42.40和其他四舍五入至42.41。但是,如果数值是42.403,42.406,那么我在所有浏览器中看到一致性。所以,现在我已经把一个条件,我的剧本,所以如果浏览器是IE则四舍五入以这样的方式,我应该得到42.40和其他浏览器是应该发生的应该得到42.41。我怎样才能做到这一点?
的【如何把一个数字在Javañ小数]可能重复(http://stackoverflow.com/questions/153724/how-to-round-a-number-to-n-decimal-places-在-JAVA) –