|
两个double类型的数据double3= (double1-double2)*1000/doulbe2 如何保留小数点后面3位 |
|
![]() 10分 |
DecimalFormat h=new DecimalFormat(".###");
double d=1235.12345;
String st=h.format(d);
double d3=Double.parseDouble(st);
System.out.println(d3);
|
![]() 20分 |
public static void main(String[] args) {
double double1=10.211;
double double2=10.111;
double double3;
double3= (double1-double2)*1000/double2 ;
String str = String.format("%.3f",double3);
System.out.println(str);
}
|
![]() |
楼上都是正解
|

