Java tutorial
//package com.java2s; import java.math.BigDecimal; public class Main { public static float myround2(float paramFloat) { return (float) (Math.round(100.0F * paramFloat) / 100.0D); } 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(); } }