float f = 0.123456f;
float f2 = (float)(Math.round(f*100))/100;
System.out.println(f2);

//结果:0.12

 

相关文章: