Computer Science Canada

outputting a double to n decimal places

Author:  DanielG [ Thu Dec 25, 2008 2:30 pm ]
Post subject:  outputting a double to n decimal places

is there any command to do this? or is the only way to write a function specifically for it?

Author:  SJ [ Thu Dec 25, 2008 3:26 pm ]
Post subject:  RE:outputting a double to n decimal places

use printf

http://www.cplusplus.com/reference/clibrary/cstdio/printf.html

Author:  wtd [ Thu Dec 25, 2008 5:43 pm ]
Post subject:  RE:outputting a double to n decimal places

Using printf is exactly the wrong answer. "printf" is a C function. You're using C++, so you need to be using iostreams and setprecision.

Author:  DanielG [ Fri Dec 26, 2008 5:01 pm ]
Post subject:  RE:outputting a double to n decimal places

Thanks


: