How can I remove the uesless ‘0’ for double value in C++?
double dVal = 6.606000;
double dOut;
dOut = someMethod(dVal); // dOut = 6.606;
thanks.
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.
Your question is based on a misunderstanding.
If you have 10 pencils or 10.0 pencils, the pencils are the same. There’s no way to take 10.0 pencils and give back 10 pencils. — They’re the same pencils. In pencils, “10.0” and “10” are the same.
The zeroes are not in the stored value, they’re just presented that way for output. The way “6.606000” is represented as a double is identical to the way “6.606” would be represented.