Java Utililty Methods Double to String

List of utility methods to do Double to String

Description

The list of methods to do Double to String are organized into topic(s).

Method

StringdoubleToString(double d)
Produce a string from a double.
if (Double.isInfinite(d) || Double.isNaN(d)) {
    return "null";
String s = Double.toString(d);
if (s.indexOf('.') > 0 && s.indexOf('e') < 0 && s.indexOf('E') < 0) {
    while (s.endsWith("0")) {
        s = s.substring(0, s.length() - 1);
    if (s.endsWith(".")) {
        s = s.substring(0, s.length() - 1);
return s;
StringdoubleToString(double d, int fNumber)
Converts the double value to locale-independent string representation.
if (fNumber < 0)
    fNumber = 0;
String value = Double.toString(d);
int ePos = value.indexOf('E');
int dotPos = value.indexOf('.');
if (ePos != -1) {
    String e = value.substring(ePos + 1);
    int exp = Integer.parseInt(e);
...
StringdoubleToString(double d, int sigDigs)
double To String
String s = Double.toString(d);
if (Math.abs(d) < 10) {
    int pos = s.indexOf(".");
    if (pos != -1) {
        s = s.substring(0, Math.min(pos + 3, s.length()));
return s;
...
StringdoubleToString(Double doub)
Convierte un doble a cadena
if (doub == null)
    return "";
else
    return String.valueOf(doub);
StringdoubleToString(double inValue, int precision, boolean useComma)
double To String
boolean trailingZero;
double absval = Math.abs(inValue); 
if (precision < 0) {
    precision = -precision;
    trailingZero = false;
} else
    trailingZero = true;
String signStr = "";
...
StringdoubleToString(double val)
convert a double to a string
return Double.toString(val);
StringdoubleToString(double val, int digits)
Returns a String containing the value of the double with (at most) the specified number of digits (rounded if needed).
double d = Math.pow(10, digits);
val *= d; 
val = Math.round(val);
val /= d;
return Double.toString(val);
StringdoubleToString(double value, int afterDecimalPoint)
Rounds a double and converts it into String.
StringBuffer stringBuffer;
double temp;
int dotPosition;
long precisionValue;
temp = value * Math.pow(10.0, afterDecimalPoint);
if (Math.abs(temp) < Long.MAX_VALUE) {
    precisionValue = (temp > 0) ? (long) (temp + 0.5) : -(long) (Math.abs(temp) + 0.5);
    if (precisionValue == 0) {
...
StringdoubleToString(double value, int afterDecimalPoint)
double To String
StringBuffer stringBuffer;
double temp;
int dotPosition;
long precisionValue;
temp = value * Math.pow(10.0, afterDecimalPoint);
if (Math.abs(temp) < Long.MAX_VALUE) {
    precisionValue = (temp > 0) ? (long) (temp + 0.5) : -(long) (Math.abs(temp) + 0.5);
    if (precisionValue == 0)
...
String[]doubleToString(double[] values)
double To String
if (values == null) {
    return null;
String[] results = new String[values.length];
for (int i = 0; i < values.length; i++) {
    results[i] = String.valueOf(values[i]);
return results;
...