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 閱讀(121)
評論(0) 編輯 收藏