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