Connecting Tech Pros Worldwide Forums | Help | Site Map

scientific computation

Wing
Guest
 
Posts: n/a
#1: Sep 25 '06
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?

Thanks so much.


Victor Bazarov
Guest
 
Posts: n/a
#2: Sep 25 '06

re: scientific computation


Wing wrote:
Quote:
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?
You need to read about 'setprecision', my guess would be.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


Jacek Dziedzic
Guest
 
Posts: n/a
#3: Sep 25 '06

re: scientific computation


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".

HTH,
- J.
Marcus Kwok
Guest
 
Posts: n/a
#4: Sep 25 '06

re: scientific computation


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
Closed Thread


Similar C / C++ bytes