Possible Duplicate:
How to nicely format floating types to String?
I have number:
Double d1=(Double)0;
Double d2=(Double)2.2;
Double d3=(Double)4;
When I use to String, I get 0.0, 2.2, 4.0, but I want to see 0, 2.2, 4.
How can I do it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
DecimalFormat.formatinsted ofDouble.toString:You don’t even need
Doubles for that,doubles will work just fine.