posts - 495,  comments - 11,  trackbacks - 0

1.(double) (Math.round(sd3*10000)/10000.0);

这样为保持4位

(double) (Math.round(sd3*100)/100.0);

这样为保持2位.

2.另一种办法

import java.text.DecimalFormat;

DecimalFormat df2   = new DecimalFormat("###.00");

DecimalFormat df2   = new DecimalFormat("###.000");

System.out.println(df2.format(doube_var));

第一个为2位,第二个为3位.

posted on 2007-08-06 04:49 jadmin 阅读(116) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: