Here you can find the source of round(double number, int digits)
public static double round(double number, int digits)
//package com.java2s; //License from project: Open Source License public class Main { public static double round(double number, int digits) { if (digits > 6) { return number; } else {//w ww .j a v a 2 s . c o m double roundNumber = number; roundNumber *= Math.pow(10, digits); roundNumber = Math.round(roundNumber); roundNumber /= Math.pow(10, digits); return roundNumber; } } }