Here you can find the source of round(Double number, Integer precision)
public static Double round(Double number, Integer precision)
//package com.java2s; //License from project: Open Source License public class Main { public static Double round(Double number, Integer precision) { Double retObj = null;/*from www. ja v a 2s. co m*/ if (number != null) { if (precision == null) precision = 0; Double decimalPlaces = Math.pow(10, precision); retObj = (double) Math.round(number * decimalPlaces) / decimalPlaces; } return retObj; } public static double round(double number, int precision) { double decimalPlaces = Math.pow(10, precision); return (double) Math.round(number * decimalPlaces) / decimalPlaces; } }