+ 2
Set precision for all variables in one step
How can I use std::setprecision on all variables of type double in my C++ program in a single step, without using it on each variable one by one? Do I need a typedef or something?
3 Antworten
+ 2
Moses Odhiambo don't use serprecision with cout in conjunction with variable to be output...
just do it once individually and all following variable will follow the same. Refer below code :
double a = 2.345;
double b = 3.4556789;
cout << setprecision(3);
cout << a << endl; // prints 2.35
cout << b << endl; // prints 3.46
Correct me if I misunderstood your question...
+ 1
Ketan Lalcheta you should be a moderator.
0
Moses Odhiambo I am looking for that honour...