Hi I need to remove the .0 from a double. But I don't want to cast to int in all cases because I could have something like 67.002 where I don't want to truncate any meaningful data.
thanks!
There are probably far more mathemeatical and sophisticated ways of doing this, but I can't think of any right now !
Code:
double d = 0.0d;
String ds = d +"";
String[] dss = ds.split(".");
if (dss[1].equals("0")) {
// just a n.0 number
} else {
// has some other format like n.013581
}
Thanks,
I acually found some number formatting code that I can re-use in our app but it actually turns the double into a String. So now when I convert back to double, I get the trailing .0 again. Is there a way to convert back to double without adding on the trailing zero and not truncate any meaningful data?
thanks again
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.