Here you can find the source of round(float f, int dp)
public static float round(float f, int dp)
//package com.java2s; //License from project: Open Source License public class Main { public static float round(float f, int dp) { float pow = (float) Math.pow(10, dp); float round = Math.round(f * pow); return round / pow; }/*from www . j a va 2 s .c o m*/ public static Float round(Float f, int dp) { return f != null ? round(f.floatValue(), dp) : null; } }