Java tutorial
//package com.java2s; import java.math.BigDecimal; public class Main { public static Float getFloatFromFloatRoundHalfUp(float sourceNum, int scale) { BigDecimal bigDecimal = new BigDecimal(sourceNum); return bigDecimal.setScale(scale, BigDecimal.ROUND_HALF_UP).floatValue(); } }