I am trying to print a whole number as a double, using set precision and it does not work. It works for double number but not for whole numbers.
1 2 3 4 5 6 7 8 9 10 11 12
|
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
double val = 2.0;
std::cout << setprecision(3)<< val << endl;
return 0;
}
|
Last edited on
Thanks a lot that worked :)