Rounding a float to two decimal places - JSP/Java Views : 562
Tagged in : JSP-Java
0 0
Send mail

The following code is one of the ways to round a float value to two decimal places.


float avg = 1.23567f;
avg *= 100;
avg = (float)Math.round(avg)/100;
System.out.println(avg);


By raja, On - 2010-01-28



    Login to add Comments .