Here you can find the source of round(double valueToRound, int numberOfDecimalPlaces)
public static double round(double valueToRound, int numberOfDecimalPlaces)
//package com.java2s; //License from project: Open Source License public class Main { public static double round(double valueToRound, int numberOfDecimalPlaces) { if (Double.isNaN(valueToRound)) return Double.NaN; double multipicationFactor = Math.pow(10, numberOfDecimalPlaces); double interestedInZeroDPs = valueToRound * multipicationFactor; return Math.round(interestedInZeroDPs) / multipicationFactor; }/*from www . j a va 2s . c om*/ }