How to conrol the number of decimals in a cmath program

Jan 31, 2013 at 3:09am
I am working on a project currently, and I have the program working except that it doesn't output four decimal places like I need it too. I have tried using the setpoint, but that doesn't work. How do I get it to work?

Thanks for your help.
Jan 31, 2013 at 3:18am
http://www.cplusplus.com/reference/iomanip/setprecision/
Perhaps?

std::cout << std::setprecision(4) << 0.12345678901234567 << std::endl;

Works for me.
Last edited on Jan 31, 2013 at 3:18am
Jan 31, 2013 at 4:50am
Thanks. This worked.
Topic archived. No new replies allowed.