I've had a look at some questions before posting this and couldn't find what I was looking for, so if it's a duplicate I'm sorry.
I have this code:
cout << "The balance at year " << i << " will be " << char(156) << std::setprecision(2)
<< balance << endl;
To my knowledge this should print to the console something like:
£2.00
£100.46
*fyi Above are just examples I know there's nothing to suggest those numbers, but the format should look like that, right?
But here's my output:
£1e+002
£1.1e+002
Why is it doing this?
It was my understanding that using setprecision
would show 2 decimal places and nothing more.
Oh and also noticed hardly any questions about printing doubles that said use setprecision
actually state that this needs including:
#include <iomanip>