+ 1

How do I round double variables in c++

I need to round double variables in my program, but I can't figure out how to do this. For example I need to round 2.845 to 2.90 or 4.0397 to 4.04. Please help! Thanks in advance!

16th Nov 2019, 2:06 PM
Ernestas Star
Ernestas Star - avatar
2 Respostas
+ 2
Use set precision. Read this may help you .. http://www.cplusplus.com/reference/iomanip/setprecision/
16th Nov 2019, 2:36 PM
Jayakrishna 🇮🇳