PDA

View Full Version : c++ help



zerobinary
July 19th, 2007, 04:30 AM
what is setprecision this manipulator do and what is the header iomanip do

zerobinary
July 19th, 2007, 08:08 PM
any one knows

Rui Pais
July 19th, 2007, 08:18 PM
what is setprecision this manipulator do and what is the header iomanip do

Hi, use:

cout.precision(N);
(no iomanip header needed)

or:

#include <iomanip>
cout << "A number" << setprecision(N) << some_float_number;
where N is an integer with the precision digits desired.

Check this (http://www.cppreference.com/io_flags.html) and this (http://www.cppreference.com/cppio/precision.html).

zerobinary
July 19th, 2007, 09:31 PM
so what is setprecision actually do i don't quite get what do u mean
plz help me

Rui Pais
July 19th, 2007, 11:21 PM
They are 2 different ways for you to change precision of float numbers from default to the one you want.

For instance, if you want the output of 2.0/3.0 with 15 digits you can do the above with N=15.


cout.precision(15);
cout<<2.0/3.0;

zerobinary
July 20th, 2007, 12:29 AM
k thx