Here you can find the source of roundTo(double num, int dp)
public static double roundTo(double num, int dp)
//package com.java2s; //License from project: Open Source License public class Main { public static double roundTo(double num, int dp) { int dpM = (int) Math.pow(10, dp); return Math.round(num * dpM) / dpM; }/*from w w w .ja v a 2 s . c om*/ }