J
jeff_zhang446
Hi,
I try to convert double to string as below:
std::string cnvrtToString(double lValue)
{
std:stringstream lStream;
lStream << lValue;
return lStream.str();
}
however I found that I have lost the accuracy(having lesser decimal
value) of my result after I print it to an outfile by doing
fprintf(File, "%s", stream.ctr());
I am not able to print directly:
fprintf(File, "%f", lValue); as I need to format my outfile
appropriately.
I wonder if the lost of accuracy happen when I convert double to
string? If yes, is there anyway I can avoid that?
Please correct me if I am wrong.
Thnak you.
jeff
I try to convert double to string as below:
std::string cnvrtToString(double lValue)
{
std:stringstream lStream;
lStream << lValue;
return lStream.str();
}
however I found that I have lost the accuracy(having lesser decimal
value) of my result after I print it to an outfile by doing
fprintf(File, "%s", stream.ctr());
I am not able to print directly:
fprintf(File, "%f", lValue); as I need to format my outfile
appropriately.
I wonder if the lost of accuracy happen when I convert double to
string? If yes, is there anyway I can avoid that?
Please correct me if I am wrong.
Thnak you.
jeff