I use setprecision(n) to control decimal places: cout << fixed << setprecision(2) << 3.14159; prints 3.14. The fixed forces standard notation, and setprecision(2) rounds to 2 places.
Without fixed, setprecision(n) controls total substantial digits, not decimal places. Writing cout << setprecision(2) << 3.14159; prints 3.1, which is probably not what you want.
The precision persists: cout << fixed << setprecision(2); cout << 3.14159 << " " << 2.7; prints 3.14 2.70. Notice 2.7 becomes 2.70 with the trailing zero.