+ 2
How to round of float value to two decimal value in java?
program to round of float value to two decimal.
2 Antworten
+ 12
// Use printf instead :
float f = 12.56994f;
System.out.printf("Value: %.2f", f);
/* You can also use Math.round() for the same purpose */
+ 3
DecimalFormat("###.##");
You can also use Math.round().
http://docs.oracle.com/javase/1.5.0/docs/api/java/text/DecimalFormat.html
http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Math.html