public static void main(String[] args) {

double a = 26765;
int b = 45676;
double c = a/b;
double d = a/b/1.000;
double e = a/1000.00;
String result = String.format("%.3f",c);//  %-小数点前任意位数;3-小数点后三位; f-浮点型

System.out.println("c="+result);
System.out.println("d="+d);
System.out.println("e="+e);

}

运算结果:

c=0.586
d=0.5859751291706804
e=26.765

posted on 2019-01-09 21:28  qqzhulu  阅读(286)  评论(0编辑  收藏  举报