Here you can find the source of round(double num, int bit)
public static double round(double num, int bit)
//package com.java2s; //License from project: Open Source License public class Main { public static double round(double num, int bit) { int t = 10; for (int i = 0; i < bit; i++) t *= 10;/* w ww . ja va2s . co m*/ double n = num * t; if (5 <= (n % 10)) n += 10; return (double) ((int) n / 10) / (t / 10); } public static double round(double num) { return round(num, 0); } }