Possible Duplicate:
Convert a double to fixed decimal point in C++
Suppose , I have double a = 0
and I want to print it as 0.0000
.
I've tried this :
cout.precision(4) ;
cout<<a<<endl ;
but it gaves 0
as the output.
Possible Duplicate:
Convert a double to fixed decimal point in C++
Suppose , I have double a = 0
and I want to print it as 0.0000
.
I've tried this :
cout.precision(4) ;
cout<<a<<endl ;
but it gaves 0
as the output.
#include <iomanip>
#include <iostream.h>
int main()
{
double a = 0.00;
// print a double, 2 places of precision
cout << setprecision(4) << a << endl;
}
std::
s and non existent iostream.h
, without std::fixed
this simply doesn't work. –
Pinniped © 2022 - 2024 — McMap. All rights reserved.