Return to Snippet

Revision: 42156
at February 28, 2011 19:40 by bits

Initial Code
std::string formatToString(int precision, double dValue)
    CString sTmpVal;
    CString sFormat;
    sFormat.Format("%%.%df", precision);
    sTmpVal.Format(sFormat, dValue);
    return static_cast<LPCSTR>(sTmpVal);

Initial URL

Initial Description
This function shows how you can format a double value to a string with a given precision.

Initial Title
Function to format double values to a string

Initial Tags

Initial Language