Java整数相除保留小数
public static void main(String[] args) throws IOException {
Integer x = 30;
Integer y = 9;
float diff = (float)x/(float)y;
float diff1 = (float) x/y;
DecimalFormat df = new DecimalFormat("0.00");
String s = df.format((float)x/y);
}
Java整数相除保留小数
public static void main(String[] args) throws IOException {
Integer x = 30;
Integer y = 9;
float diff = (float)x/(float)y;
float diff1 = (float) x/y;
DecimalFormat df = new DecimalFormat("0.00");
String s = df.format((float)x/y);
}
有建议,请留言!