Skip to main content

floatformat.cpp


// Example of floating-point formatting
// (NDE, 2013-12-29)
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
  double x = 0.012574;
  cout << x << endl;
  cout << setprecision(4) << x << endl;
  cout << fixed << x << endl;
  cout << scientific << x << endl;
  return 0;
}