A
abc
Easy newbie-question here for the experts:
What's a clean way of writing a Double into a String, avoiding
the ".0" at the end ?
The Double.toString() method insists on appending a decimal fraction
".0" no matter what, and I only want the fractions to show up if they
are non-zero.
I found a dirty workaround (see code below), using a regex to remove the
trailing ".0", but there has to be a prettier way to do this.
....
String s = Double.toString(x);
s = s.replaceAll((String)"\\.0$", "");
....
TIA
What's a clean way of writing a Double into a String, avoiding
the ".0" at the end ?
The Double.toString() method insists on appending a decimal fraction
".0" no matter what, and I only want the fractions to show up if they
are non-zero.
I found a dirty workaround (see code below), using a regex to remove the
trailing ".0", but there has to be a prettier way to do this.
....
String s = Double.toString(x);
s = s.replaceAll((String)"\\.0$", "");
....
TIA