Java float保留2位或多位小数 白 float f = 0.123456f; float f2 = (float)(Math.round(f*100))/100; System.out.println(f2); //结果:0.12