Here you can find the source of round(double value, int decimalPlace)
public static double round(double value, int decimalPlace)
//package com.java2s; //License from project: Open Source License public class Main { public static double round(double value, int decimalPlace) { double power_of_ten = 1; while (decimalPlace-- > 0) power_of_ten *= 10.0;//from w w w .j a v a 2s . c o m return Math.round(value * power_of_ten) / power_of_ten; } }