If the idea is to print integers stored as doubles as if they are integers, and otherwise print the doubles with the minimum necessary precision:
publicstaticString fmt(double d){if(d ==(long) d)returnString.format("%d",(long)d);elsereturnString.format("%s",d);}
Produces:
2320.1812378751924.5801.2345
And does not rely on string manipulation.