voloshin
asked on
float to CString conversion - not with gcvt!!!
I need to convert float a=0.000432 to CString. Using gcvt function results in 4.32 E-4.
But I need to keep it in the same form "0.000432" and not to use exponential presentation.
Any help?
Thanks,
Alex
But I need to keep it in the same form "0.000432" and not to use exponential presentation.
Any help?
Thanks,
Alex
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Why use an additional variable?
because %f does not work in CString::Format. You have to use sprintf for converting floats.
ASKER
Thanks for good advice, str.Format("%.6f",a) provides exactly 6 places after the dot.
char szBuffer[24];
float nNumber = 0.000432;
sprintf(szBuffer, "%0.6lf", nNumber)
CString strNumber = szBuffer;