Java Number Round roundToDefaultPrecision(final double value)

Here you can find the source of roundToDefaultPrecision(final double value)

Description

round To Default Precision

License

Open Source License

Declaration

public static double roundToDefaultPrecision(final double value) 

Method Source Code

//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;
    }
}

Related

  1. roundToDecimals(double d, int c)
  2. roundToDecimals(double d, int numberOfDecimalPlaces)
  3. roundToDecimals(double d, int percision)
  4. roundToDecimals(double doubleValue)
  5. roundToDecimals(double input, int places)
  6. roundToDimensions(int value, int f)
  7. roundToDimensions(int value, int nearestValue)
  8. roundToEight(long i)
  9. roundToHalf(float x)