Reputation: 447
Hi although I do something like this
#include <iomanip>
...
std::cout<<"Numbers "<<std::setprecision(2)<<numb1<< " "<<std::setprecision(2)<<numb2<<" "<<std::setprecision(2)<<numb3<<" "<< std::setprecision(4)<<numb4<<std::endl;
I do get
Numbers 14 1.5e+02 0.0053 & 220
How can I really make set the precision per column to get a consistent format and not this mixture of precision(5) and scientific format?
Upvotes: 1
Views: 85
Reputation: 234665
Use the std::fixed
manipulator too which will switch off any reversion to scientific notation:
std::cout << std::fixed /*<< as before from here*/
If you want to switch the scientific notation back on again, then introduce the manipulator std::scientific
.
Reference; http://en.cppreference.com/w/cpp/io/manip/fixed
Upvotes: 4