Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format problem 1

Status
Not open for further replies.

PaolaS

Programmer
Aug 23, 2001
8
ES
When I use it, to convert a double to cstring, the result appears with 6 decimals

CString str;
double dDouble = 3.123456;
str.Format('Double is = %2lf',dDouble);
AfxMessageBox(str);

Result = Double is = 3.120000

My question is, How can I see only 2 decimals?

Thank you in advance.

Paola
 
Try str.Format("Double is %.2lf",dDouble); The DOT before number 2 might help. The precision is specified this way, so if you say %.54ld you would get 54 decimals after the floating point...
The Format method actually has the same behavior as the Good old sprintf C function. [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top