home *** CD-ROM | disk | FTP | other *** search
/ Shareware Supreme Volume 6 #1 / swsii.zip / swsii / 099 / IOSTREAM.ZIP / EX_O73.CPP < prev    next >
C/C++ Source or Header  |  1993-01-07  |  599b  |  29 lines

  1.  // EXAMPLE OUTPUT-73
  2.  
  3.  // HOW TO EMULATE printf AND SET
  4.  // THE PRECISION
  5.  
  6.  #include <header.h>
  7.  
  8.  int main()
  9.  {
  10.     cout.setf(ios::showpoint) ;
  11.     cout.precision(2) ;
  12.  
  13.     // Guarantee fixed decimal
  14.     cout.setf(ios::fixed , ios::floatfield) ;
  15.     cout << 1.2300 << '\n' ;
  16.     cout << 4.00 << '\n' ;
  17.     cout << 5.678E2  << '\n' ;
  18.     cout << 0.0 << '\n' ;
  19.  
  20.     // Guarantee scientific
  21.     cout.setf(ios::scientific , ios::floatfield) ;
  22.     cout << 1.2300 << '\n' ;
  23.     cout << 4.00  << '\n' ;
  24.     cout << 5.678E2<< '\n' ;
  25.     cout << 0.0 << '\n' ;
  26.  
  27.     return 0 ;
  28.  }
  29.