Here you can find the source of formatFloat(double val1, double val2)
public static float formatFloat(double val1, double val2)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; public class Main { public static final DecimalFormat floatFormatter = new DecimalFormat("#.00"); public static float formatFloat(double val1, double val2) { return val2 == 0 ? 0 : Float.parseFloat(floatFormatter.format(val1 / val2)); }//from ww w .j a va2 s . co m }