Here you can find the source of roundDecimals(double d, int decimalPlaces)
public static double roundDecimals(double d, int decimalPlaces)
//package com.java2s; //License from project: Open Source License public class Main { public static double roundDecimals(double d, int decimalPlaces) { int j = (int) (d * Math.pow(10, decimalPlaces)); return j / Math.pow(10, decimalPlaces); }//from w w w . j av a 2 s .c o m public static double roundDecimals(double d) { return roundDecimals(d, 2); } }