Here you can find the source of roundDouble(double value)
Parameter | Description |
---|---|
value | value to be rounded |
public static double roundDouble(double value)
//package com.java2s; /*//from w w w.j ava 2 s . c o m * @(#)ConversionUtil.java * * Copyright by ObjectFrontier, Inc., * 12225 Broadleaf Lane, Alpharetta, GA 30005, U.S.A. * All rights reserved. * * This software is the confidential and proprietary information * of ObjectFrontier, Inc. You shall not disclose such Confidential * Information and shall use it only in accordance with the terms of * the license agreement you entered into with ObjectFrontier. */ public class Main { /** * This method takes double value as a parameter and rounds it to * two decimal points and returns the rounded value. * * @param value value to be rounded * @return double roundedvalue */ public static double roundDouble(double value) { int decimalPlace = 2; double power_of_ten = 1; while (decimalPlace-- > 0) { power_of_ten *= 10.0; } return Math.round(value * power_of_ten) / power_of_ten; } }