Here you can find the source of formatFloat(float input, int numDecimals)
static public float formatFloat(float input, int numDecimals)
//package com.java2s; //License from project: Open Source License public class Main { static public float formatFloat(float input, int numDecimals) { float m = (float) Math.pow(10, numDecimals); return Math.round(input * m) / m; }/*from w ww . j ava2 s. com*/ static public int round(float input) { return Math.round(input); } }