/*
    Print program to illustrate how cout stream works for doubles.
    NB. The formatting manipulators ONLY affect the next thing being outputtet.

    See Nyhoff P226 for details on formatting.
*/

#include <iostream>           // Include cin / cout streams for input/output
#include <iomanip>            // formatting manipulators
#include <cmath>              // exp()
using namespace std;

int main()               
{          
   double x=exp(1.0);

   cout << "x=" << x << "" << endl;                // prints number with 5 digit precision

// Formatting number with 10 char wide field
   cout << "x=|" << setw(10) << x << "|" << endl;
   cout << "x=|" << left << setw(10) << x << "|" << endl;

   cout << "x=" << setprecision(15) << x << " 15 decimals" << endl;
   cout << "x=" << scientific << x << " more scientific" << endl;
   return 0;
}
