Tricky Tricks ›› Programming Tricks ›› C Languages Tricks ›› How To Prepare The Output Stream To Print Fixed Precision Numbers

How To Prepare The Output Stream To Print Fixed Precision Numbers

C Programming Tricks

How to prepare the output stream to print fixed precision numbers (3.40 instead of 3.4):

   std::cout.setf(ios::fixed, ios::floatfield);
   std::cout.setf(ios::showpoint);
   std::cout.precision(2);
 

Partners