[Software]/Programming Tips2012. 1. 26. 11:00


http://www.cplusplus.com/reference/iostream/manipulators/fixed/


// modify basefield
#include <iostream>
using namespace std;

int main () {
  double a,b,c;
  a = 3.1415926534;
  b = 2006.0;
  c = 1.0e-10;
  cout.precision(5);
  cout <<   a << '\t' << b << '\t' << c << endl;
  cout <<   fixed    << a << '\t' << b << '\t' << c << endl;
  cout << scientific << a << '\t' << b << '\t' << c << endl;
  return 0;
}


The execution of this example displays something similar to:
3.1416 2006 1e-010 3.14159 2006.00000 0.00000 3.14159e+000 2.00600e+003 1.00000e-010


Posted by 바트정