Java tutorial
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; public class Main { public static double round(double unrounded, int precision) { BigDecimal bd = new BigDecimal(unrounded); BigDecimal rounded = bd.setScale(precision, BigDecimal.ROUND_HALF_DOWN); return rounded.doubleValue(); } }