I have been tricked! setprecision() does not change the amount of decimals being printed out, it changes the amount of numbers to be printed out. E.g:
Would output 24.435 (5 numbers) instead of 24.43517 (5 decimals).Code:#include <iostream> #include <iomanip> using namespace std; int main() { cout<<setprecision(5)<<24.435166; cin.get(); return 0; }
printf() can do this simply by using %.5f, so how do you do it with cout?