Java tutorial
//package com.java2s; import java.math.BigDecimal; public class Main { public static double roundDouble(double value, int scale, int roundingMode) { BigDecimal bd = new BigDecimal(value); bd = bd.setScale(scale, roundingMode); double d = bd.doubleValue(); bd = null; return d; } }