java how to show 2 decimal places code example
Example 1: decimal up to 6 places in java
double num = 1.34567;
System.out.format("%.4f", num);
Example 2: java round 2 decimal places
Math.round(input * 100.0) / 100.0;
double num = 1.34567;
System.out.format("%.4f", num);
Math.round(input * 100.0) / 100.0;