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