Can anyone tell me how to set a float to a specific no of decimal places in c++?
jim.
Printable View
Can anyone tell me how to set a float to a specific no of decimal places in c++?
jim.
Like this -
Code:#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
double d = 1.234;
cout.setf(ios::fixed);
cout << setprecision(2) << d;
return 0;
}
thanx a lt zen, much obliged. i've been rackin my tiny little brain over this for some time now!
Thanx again, Jim.