Here you can find the source of round(double d, int p)
public static double round(double d, int p)
//package com.java2s; //License from project: Apache License public class Main { public static double round(double d, int p) { long tmp = (long) Math.pow(10, p); double num = Math.round(d * tmp); num /= tmp;//from w w w . j av a 2s . co m return num; } }