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 160 views
1 answer 174 views
3 answers 264 views
1 answer 205 views
1 answer 163 views
163 views asked May 25, 2018 by avibootz
...