Here you can find the source of toString(double value)
public static String toString(double value)
//package com.java2s; //License from project: LGPL import java.math.BigDecimal; import java.text.NumberFormat; public class Main { public static String toString(double value) { value = round(value);/* w w w . j a v a2s .co m*/ if (value % 1 == 0) { return NumberFormat.getNumberInstance().format((int) value); } return NumberFormat.getNumberInstance().format(value); } public static double round(double value, int roundingMode) { return round(value, 2, roundingMode); } public static double round(double value) { return round(value, 2, BigDecimal.ROUND_CEILING); } public static double round(double value, int scale, int roundingMode) { return BigDecimal.valueOf(value).setScale(scale, roundingMode).doubleValue(); } }