Java tutorial
//package com.java2s; import java.math.BigDecimal; public class Main { public static float handleFloat(float num, int limit) { BigDecimal bigDecimal = new BigDecimal(num); float res = bigDecimal.setScale(limit, BigDecimal.ROUND_HALF_UP).floatValue(); return res; } }