Here you can find the source of formatDouble(double number)
Parameter | Description |
---|---|
number | the double to format |
private static String formatDouble(double number)
//package com.java2s; //License from project: Open Source License import java.math.RoundingMode; import java.text.DecimalFormat; public class Main { /**//from w ww. j a v a 2 s.c o m * used by {@link #toString()} and {@link #exportString()} * * @param number * the double to format * @return the formatted string */ private static String formatDouble(double number) { DecimalFormat df; if (number < 0.00001d || number > 99999d) { df = new DecimalFormat("0.#####E0"); } else { df = new DecimalFormat("###.#####"); } df.setRoundingMode(RoundingMode.HALF_UP); return df.format(number); } }