// Manipulators: showpoint #include #include using namespace std; int main() { // showpoint double mynum = 33.; cout << "default 33. with setprecision(2)" << endl; cout << setprecision(2) << endl; cout << "default: " << setw(10) << mynum << endl; cout << showpoint; cout << "showpoint: " << setw(10) << mynum << endl; cout << noshowpoint; cout << "noshowpoint: " << setw(10) << mynum << endl << endl; mynum = 33.1; cout << setprecision(4) << endl; cout << "default 33.1 with setprecision(4)" << endl; cout << "default: " << setw(10) << mynum << endl; cout << showpoint; cout << "showpoint: " << setw(10) << mynum << endl; cout << noshowpoint; cout << "noshowpoint: " << setw(10) << mynum << endl << endl; // fixed mynum = 33.; cout << "fixed 33. with setprecision(2)" << endl; cout << fixed << setprecision(2) << endl; cout << "default: " << setw(10) << mynum << endl; cout << showpoint; cout << "showpoint: " << setw(10) << mynum << endl; cout << noshowpoint; cout << "noshowpoint: " << setw(10) << mynum << endl << endl; mynum = 33.1; cout << fixed << setprecision(4) << endl; cout << "fixed 33.1 with setprecision(4)" << endl; cout << "default: " << setw(10) << mynum << endl; cout << showpoint; cout << "showpoint: " << setw(10) << mynum << endl; cout << noshowpoint; cout << "noshowpoint: " << setw(10) << mynum << endl << endl; // scientific mynum = 33.; cout << "scientific 33. with setprecision(2)" << endl; cout << scientific << setprecision(2) << endl; cout << "default: " << setw(10) << mynum << endl; cout << showpoint; cout << "showpoint: " << setw(10) << mynum << endl; cout << noshowpoint; cout << "noshowpoint: " << setw(10) << mynum << endl << endl; mynum = 33.1; cout << scientific << setprecision(4) << endl; cout << "scientific 33.1 with setprecision(4)" << endl; cout << "default: " << setw(10) << mynum << endl; cout << showpoint; cout << "showpoint: " << setw(10) << mynum << endl; cout << noshowpoint; cout << "noshowpoint: " << setw(10) << mynum << endl << endl; /* default 33. with setprecision(2) default: 33 showpoint: 33. noshowpoint: 33 default 33.1 with setprecision(4) default: 33.1 showpoint: 33.10 noshowpoint: 33.1 fixed 33. with setprecision(2) default: 33.00 showpoint: 33.00 noshowpoint: 33.00 fixed 33.1 with setprecision(4) default: 33.1000 showpoint: 33.1000 noshowpoint: 33.1000 scientific 33. with setprecision(2) default: 3.30e+01 showpoint: 3.30e+01 noshowpoint: 3.30e+01 scientific 33.1 with setprecision(4) default: 3.3100e+01 showpoint: 3.3100e+01 noshowpoint: 3.3100e+01 */ return 0; }