Jacek Dziedzic <jacek@no_spam.tygrys.no_spam.netwrote:
Quote:
Wing wrote:
Quote:
>Hello eveyone,
>>
>I am programming some scientific computation based on C++. I would like
>to set every output/input (e.g. cout, io file stream) to be a high
>precision.
>>
>What C++ command should I use?
>
First, #include<iomanip>.
>
Then choose fixed-point output (cout << fixed;)
or scientific-notation output (cout << scientific;).
>
Finally tell the output stream how many digits of precision
you require, eg. for 12 try
>
cout << setprecision(12);
>
That's basically it. For more details read up on "manipulators".
Also, the OP may want to investigate the use of
std::numeric_limits<T>::digits10 (requires #include <limits>), which
will give "the number of decimal digits that the type can represent
without change" (quote from Dinkumware documentation:
http://www.dinkumware.com/manuals/?m...its::digits10).
--
Marcus Kwok
Replace 'invalid' with 'net' to reply