Hi everyone. I have a simple question that i don't knot it :
I have the next division :
296/91=3,2527472527472527472527472527473
I want print the result of it, but only with 4 decimals. What is the command ?
Thank you!
Printable View
Hi everyone. I have a simple question that i don't knot it :
I have the next division :
296/91=3,2527472527472527472527472527473
I want print the result of it, but only with 4 decimals. What is the command ?
Thank you!
Look up the stream manipulators in the iomanip header such as setprecision.
[edit]Code sample follows:[/edit]
Code:#include <iostream>
#include <iomanip>
int main()
{
double p = 12.345467889;
std::cout << p << std::endl;
std::cout << std::setprecision(8) << p << std::endl;
return 0;
}