Here you can find the source of round(double d, int i)
public static double round(double d, int i)
//package com.java2s; //License from project: Apache License public class Main { public static double round(double d, int i) { long powerTen = 1; for (int x = 0; x < i; x++) { powerTen *= 10;/* w w w.j av a 2 s . c o m*/ } return ((double) Math.round(d * powerTen)) / powerTen; } }