Java tutorial
//package com.java2s; import java.math.BigDecimal; import java.math.RoundingMode; public class Main { public static BigDecimal redondear(double f, int scale) { String val = f + ""; BigDecimal big = new BigDecimal(val); big = big.setScale(scale, RoundingMode.HALF_UP); return big; } }