How to limit decimal numbers in a float/double?

Well, title says it all. And cout.precision() works for the whole number, not just the decimals!
I wonder if a string stream could be of any use to you.
http://cplusplus.com/reference/iostream/stringstream/

-Albatross
So, if I'm reading this correctly, what you mean is that you want to limit the number of digits after the decimal point, rather than limiting the number of total significant digits shown? If so, this reference document will explain how to use the setf() method to achieve this:

http://www.cplusplus.com/reference/iostream/ios_base/precision/
Topic archived. No new replies allowed.