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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

decimal places

Status
Not open for further replies.

satee

Programmer
Joined
Oct 14, 2003
Messages
1
Location
MU
Hi Everybody,
My program displays a variable of type float. How do I specify the number of decimal places?

Thanks for your help
Satee
 
printf("%.2f", someFloat);

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
#include <iomanip>;...cout << setprecision(n);
// total number of digits before and after dec point.
Don't forget set to default (if you need).
See also setw(n). See C++ i/o manipulators helps/docs.
 
Yes, old good unsafe printf is more, more better...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top