tags:

views:

133

answers:

1

Hi all,

I'm doing some calculations, and the results are being save in a file. I have to output very precise results, near the precision of the double variable, and I'm using the iomanip setprecision(int) for that. The problem is that I have to put the setprecision everywhere in the output, like that:

func1() {
cout<<setprecision(12)<<value;
cout<<setprecision(10)<<value2;
}
func2() {
cout<<setprecision(17)<<value4;
cout<<setprecision(3)<<value42;
}

And that is very cumbersome. Is there a way to set more generally the cout fixed modifier?

Thanks

+4  A: 

Are you looking for cout.precision ?

nc3b