DecimalFormat df = new DecimalFormat("#.000000000");
System.out.println(df.format(1.0));
System.out.println(df.format(1.111111111111));1.000000000
1.111111111
System.out.println(df.format(1.0));
System.out.println(df.format(1.111111111111));1.000000000
1.111111111
System.out.println(bd);
System.out.println(df.format(1.0));
System.out.println(df.format(1.111111111111));1.000000000
1.111111111
如果是1。0的时候就显示1。0。这样怎么做?
int iRound
//BigDecimal的构造函数参数类型是double
BigDecimal deSource = new BigDecimal(dSource);
//deSource.setScale(0,BigDecimal.ROUND_HALF_UP) 返回值类型 BigDecimal
//intValue() 方法将BigDecimal转化为int
iRound= deSource.setScale(0,BigDecimal.ROUND_HALF_UP).intValue();
return iRound;
}