I want to round up the value. For example,
23.0f / 10.0f = 2.3f -> round up to 3
11.0f / 10.0f = 1.1f -> round up to 2
15.0f / 10.0f = 1.5f -> round up to 2
67.0f / 10.0f = 6.7f -> round up to 7
1738.0f / 10.0 = 173.8f -> round up to 174
My current approach does not work, it rounds to the nearest integer instead of up:
public class Test {
private static final DecimalFormat df = new DecimalFormat("0.00");
public static void main(String[] args) {
final float a = 23;
final float b = 10;
final float k = a / b;
System.out.println(k);
final float roundup = Math.round(k * 100) / 100;
System.out.println(roundOff);
}
}
How can I achieve the desired behavior in Java?