Here you can find the source of roundToDefaultPrecision(final double value)
public static double roundToDefaultPrecision(final double value)
//package com.java2s; /**// w ww .j av a2 s . co m * Copyright (c) 2010 Darmstadt University of Technology. * 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: * Marcel Bruch - initial API and implementation. * Sebastian Proksch - stripped down to a simple calculation helper */ public class Main { public static final double P_ROUNDING_FACTOR = 1000000; public static double roundToDefaultPrecision(final double value) { return (long) (P_ROUNDING_FACTOR * value + 0.5) / P_ROUNDING_FACTOR; } }