Here you can find the source of round(double value, int scalar, int standard)
public static double round(double value, int scalar, int standard) throws Exception
//package com.java2s; /**//from w w w. j a v a 2 s . co m * Copyright (C) 2002-2005 WUZEWEN. All rights reserved. * WUZEWEN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ public class Main { public static double round(double value, int scalar, int standard) throws Exception { return Double.parseDouble(round(String.valueOf(value), scalar, standard)); } public static String round(String value, int scalar, int standard) throws Exception { String back = null; int point = value.indexOf("."); if (point > -1) { int len = value.length() - point + 1; if (len <= scalar) { back = value; } else { back = value.substring(0, point + scalar + 1); String vsTemp = value.substring(point + scalar + 1, point + scalar + 2); if (Integer.parseInt(vsTemp) >= standard) { back = String.valueOf(Integer.parseInt(back) + 1); } } } else { back = value; } return back; } }