cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
user name:
password:
Forgot your password?
please wait
try again
cancel
forgot your password?
sign up
log in
[Legacy version]
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
How to conrol the number of decimals in
How to conrol the number of decimals in a cmath program
Jan 31, 2013 at 3:09am
Jan 31, 2013 at 3:09am UTC
jsmi2016
(12)
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
Jan 31, 2013 at 3:18am UTC
LB
(13399)
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 3:18am UTC
Jan 31, 2013 at 4:50am
Jan 31, 2013 at 4:50am UTC
jsmi2016
(12)
Thanks. This worked.
Topic archived. No new replies allowed.