List of utility methods to do Decimal Format
String | toString(double value) to String if (Double.isNaN(value)) { return "NaN"; BigDecimal bigDecimal = new BigDecimal(value); return bigDecimal.toString(); |
String | toString(double value, int precision) Thread-safe version of converting a double value to a String when only a certain number of digits are desired after a decimal point. StringBuilder buf = new StringBuilder("0"); if (precision > 0) { buf.append("."); for (int i = 0; i < precision; i++) { buf.append("0"); DecimalFormat format = new DecimalFormat(buf.toString()); ... |
String | toString(double[] array) to String String display = "["; for (double val : array) { display += val + ", "; display = display.substring(0, display.length() - 2); display += "]"; return display; |
String | toString(Double[] input) to String StringBuilder ret = new StringBuilder(); for (Double o : input) { ret.append(""); if (o != null) ret.append("" + dcf.format(o)); else ret.append("NULL"); ret.append(" "); ... |
String | toString(double[][] a, int decimals) to String if (decimals < 0) throw new IllegalArgumentException("Number of decimals must be positive"); StringBuilder decs = new StringBuilder("0."); for (int i = 0; i < decimals; i++) decs.append("0"); NumberFormat decimalsFormat = new DecimalFormat(decs.toString()); StringBuilder sb = new StringBuilder(); for (int i = 0; i < a.length; i++) { ... |
String | toString(final Double value) to String if (Double.isNaN(value) || Double.isInfinite(value)) { return "U"; } else { return formatters.get().format(value); |
String | toString(final double value, final int maxDecimalPlaces) to String DECIMAL_FORMAT.setMaximumFractionDigits(maxDecimalPlaces);
return DECIMAL_FORMAT.format(value);
|
String | toStringForHumans(double doubleToConvert) to String For Humans NumberFormat formatter = NumberFormat.getInstance();
return formatter.format(doubleToConvert);
|
String | toStringNoDigits(double[] v) to String No Digits NumberFormat nf = new DecimalFormat("0"); String res = ""; for (int i = 0; i < v.length; i++) { res += (i > 0 ? "," : "") + nf.format(v[i]); return res + ""; |
String | toStringScientific(double x) Scientific format return scientific_.format(x);
|