(unspecified) setprecision(int iDigits);
#include <iomanip>
#include <iostream> #include <iomanip> int main() { using namespace std; double dPi = 3.14159; // Output the value with default settings cout << "Default: " << dPi << endl; // Output the value with the precision set cout << setprecision(3); cout << "With 3 decimal places: " << dPi << endl; // Keep the window open cin.get(); return 0; }
© 20072024 XoaX.net LLC. All rights reserved.