When cout-ing a number with floating points, i.e. 31.14159, how can I set cout to use the setprecision(4) on the floating point:
cout <<setprecision(4)<< 31.14159<<endl; // returns 31.14
As-is, it considers the whole number with its decimal digits, and outputs: 31.14. However, I want to get: 31.1416.