Here you can find the source of round(double value)
public static double round(double value)
//package com.java2s; /******************************************************************************* * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w . j a v a2s .co m * IBM Corporation - initial API and implementation *******************************************************************************/ public class Main { /** * @deprecated */ public static double round(double value) { return Math.round(value * 10000) / 10000.0; } /** * @deprecated */ public static double round(double value, int precision) { if (precision < 0) { throw new IllegalArgumentException("Should have a precision at least greater than 0!"); } if (precision == 0) return (long) Math.floor(value); double factor = 10; int n = 1; while (n++ < precision) factor *= 10; return Math.round(value * factor) / factor; } }