CString Format VS2013

522 views Asked by At

Using the code below sometimes the text variable contains a very huge and strange number, something like "1552505576255083400000000000000000000000000000000000000000000000000000.000". A "0.000" string is expected.

I've also tryed with a basic dialog app and execute these two lines of code in the "OnInitDialog()" I'm using VS 2013. With VS 2003 seems that it works correctly.

can somebody tell me why?

CString text;
text.Format(_T("%.3f"), 0);
1

There are 1 answers

0
David Schwartz On BEST ANSWER

Your code has a bug. The %f format specifies requires a floating point number and you specify an integer. To fix the bug, change the 0 to 0.0.