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