Here you can find the source of round(BigDecimal d, int decimalPlace)
public static double round(BigDecimal d, int decimalPlace)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; public class Main { public static double round(BigDecimal d, int decimalPlace) { d = d.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP); return d.doubleValue(); }//from w w w. ja va 2s . c om public static double round(double d, int decimalPlace) { BigDecimal bd = new BigDecimal(Double.toString(d)); bd = bd.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP); return bd.doubleValue(); } }