AMD
AMD

Reputation: 1268

setprecision without iomanip

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

Upvotes: 4

Views: 6361

Answers (2)

Dietmar K&#252;hl
Dietmar K&#252;hl

Reputation: 154045

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

std::cout.precision(5);

Upvotes: 3

Idrizi.A
Idrizi.A

Reputation: 12080

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;

Upvotes: 13

Related Questions