How to set fixed format with precision of N for double value in C++

1 Answer

0 votes
#include <iostream>
#include <iomanip>

using std::cout;
using std::endl;

int main()
{
	double f = 782.123456789;

	cout << std::setprecision(7) << std::fixed << f << endl;

	return 0;
}

/*
run:

782.1234568

*/

 



answered May 21, 2018 by avibootz

Related questions

1 answer 164 views
1 answer 181 views
3 answers 280 views
1 answer 212 views
1 answer 170 views
170 views asked May 25, 2018 by avibootz
...