Here you can find the source of roundDouble(double d, int decimals)
public static double roundDouble(double d, int decimals)
//package com.java2s; //License from project: Open Source License public class Main { public static double roundDouble(double d) { return roundDouble(d, 2); }/* w w w .j a v a 2 s .c om*/ public static double roundDouble(double d, int decimals) { long tempD = (long) (d * Math.pow(10, decimals)); return tempD / (Math.pow(10, decimals)); } }