Here you can find the source of round(double what, int howmuch)
public static double round(double what, int howmuch)
//package com.java2s; public class Main { public static double round(double what, int howmuch) { return (double) ((int) (what * Math.pow(10, howmuch) + .5)) / Math.pow(10, howmuch); }// w w w. j a v a2 s . c o m }