Java tutorial
//package com.java2s; public class Main { /** * Function that rounds a number to N decimal places * * @param d * Double to round * @param n * Number of decimal places to round to * @return */ public static double roundn(double d, int n) { d = d * Math.pow(10, n); d = Math.round(d); d = d / Math.pow(10, n); return d; } }