Here you can find the source of formatDouble(double d, int n)
Parameter | Description |
---|---|
d | the double to format |
n | the number of places past the decimal place |
public static String formatDouble(double d, int n)
//package com.java2s; /* J_LZ_COPYRIGHT_BEGIN ******************************************************* * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. * * Use is subject to license terms. * * J_LZ_COPYRIGHT_END *********************************************************/ public class Main { /** /*from ww w. jav a2s .c om*/ * @param d the double to format * @param n the number of places past the decimal place */ public static String formatDouble(double d, int n) { int x = (int) Math.pow(10, n); return Double.toString((double) (((int) (x * d)) / (double) x)); } }