Java tutorial
//package com.java2s; import java.math.BigDecimal; public class Main { public static double round(double paramDouble, int paramInt) { if (paramInt < 0) { throw new IllegalArgumentException("The scale must be a positive integer or zero"); } return new BigDecimal(Double.toString(paramDouble)).divide(new BigDecimal("1"), paramInt, 5).doubleValue(); } }