Here you can find the source of round(float d, int decimalPlace)
public static float round(float d, int decimalPlace)
//package com.java2s; import java.math.BigDecimal; public class Main { public static float round(float d, int decimalPlace) { BigDecimal bd = new BigDecimal(Float.toString(d)); bd = bd.setScale(decimalPlace, BigDecimal.ROUND_FLOOR); return bd.floatValue(); }/* www. j av a 2 s.c o m*/ }