Here you can find the source of roundDouble(double d, int places)
Parameter | Description |
---|---|
d | - the double |
places | - amount of decimal places |
public static double roundDouble(double d, int places)
//package com.java2s; public class Main { /**//from ww w . ja va 2 s . c o m * Rounds a double to a set number of decimal places * @param d - the double * @param places - amount of decimal places * @return double - the rounded double */ public static double roundDouble(double d, int places) { return Math.round(d * Math.pow(10, (double) places)) / Math.pow(10, (double) places); } }