Java tutorial
//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(); } }