| <<< Floating-point Manipulators | Index | C++ String >>> |
#include <iostream>
using namespace std;
int main()
{
const double PI = 3.1415926;
cout.precision( 7 );
cout << fixed << "fixed format: " << PI << '\n';
cout << scientific << "scientific format: " << PI << '\n';
// back to default format:
cout.unsetf( ios_base::fixed );
cout.unsetf( ios_base::scientific );
cout << "default format: " << PI << '\n';
return 0;
}
/*
Output:
fixed format: 3.1415926
scientific format: 3.1415926e+000
default format: 3.141593
*/
| <<< Floating-point Manipulators | Index | C++ String >>> |