Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setprecision without iomanip

Tags:

c++

I want to compile a C++ application and I must not use

#include <iomanip>

Is there any alternative way to do that?

Info: I need the setprecision to be 5

like image 201
AMD Avatar asked Dec 05 '22 13:12

AMD


2 Answers

Yes you have the ability to use

cout.precision(5);

This does not require

#include <iomanip>

Note: This will set precision for the whole document.

Example:

cout.precision(5);
cout << f;
like image 59
Enve Avatar answered Dec 25 '22 16:12

Enve


You can set the precision() directly on the stream, e.g.:

std::cout.precision(5);
like image 41
Dietmar Kühl Avatar answered Dec 25 '22 14:12

Dietmar Kühl