I want to write a method to round the BMI of the user (float number)to one digit, is the logic correct and how to write it in android Java?
private static final DecimalFormat oneDigit = new DecimalFormat("#,##0.0");
public static float roundToOneDigit(float paramFloat)
{
float f = Float.valueOf(oneDigit.format(paramFloat)).floatValue();
f=f;
return f;
}
Try this: